How to Solve Mach-O-Linker Error in iOS7 & Xcode 5.0.1

How to solve Mach-O-Linker error in ios7 & Xcode 5.0.1

XCTest.framework needs to be linked only to the unit test target in your project. It should not be added to the UI application target.

What I have found is when adding XCTest.framework Xcode adds extra \ to Framework Search Paths

\"$(SDKROOT)/Developer/Library/Frameworks\"
\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"
$(DEVELOPER_FRAMEWORKS_DIR)

Sample Image

This causes linker issue,

ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To resolve this issue in XCode 5.1 goto the main ProjectWindow, Tab Build Settings -> Section Search Path -> Framework Search Paths and edit to remove \ appearing the paths.

Hope that helps!

Xcode gives Apple Mach-O linker error

Teaching a man (or women) how to fish:

Usually Mach-O Linker Error means you have not included a header file for a function you are using in your code.

Easiest way is to copy that function or method call and paste into Xcode quick search using shift+command+O. This will search all frameworks (and header files), find that function or method call and show you its location (the header in this case):

In this case, this call belongs to the Accelerate framework so on top of your file, enter:

#import <Accelerate/Accelerate.h>

When doing quick search, you might have to get rid of leading underscore. In other words, search for vImageBoxConvolve_ARGB8888

Hope this helps

Apple Mach-O Linker Error GoogleAnalyticslib

It seems you are not including the Google Analytics library.

In Xcode select target.

In the general tab, scroll down until the "Linked Frameworks and Libraries" .

Do you have libGoogleAnalyticsServices.a in the list ?
If not, this is your problem.

If you already have them, then the library might not contain the x64 symbols.

Download the latest library from google (they added support for x64 in January).

As a side note, x86_64 , the target you are compiling for, seems to be a simulator. arm64 and x86_64 are different platforms.

Mach-O Linker error

Most likely the library you are using has not been built for arm. For a library to work in the simulator, it must be compiled for i386 architecture. To work on the device, it must be compiled for armv architecture.

To work for both, you need what is called a "fat" binary that contains versions compiled for each of the above. If you don't have that, you will receive the linker errors.

To find out what architectures the library is compiled for, use the following command:

lipo -info mylibrary

Instant AR framework Apple Mach-O Linker Errors

please re add library file in your project folder and check with it in compile resource .

After deleting DerivedData folder, unittests fail to compile with 'Apple Mach-O Linker' error

If you want to build a pure Unit Test which just tests a Class independently of an application where it is used, you usually don't set a "Unit Test" target. In order to build the Unit Test bundle properly, you need to include the module you want to test, and possibly link to any other framework or library that will be needed. This kind of test will run independently of your app.

If you want to test several aspects of the application, you can set a "Unit Test target". This builds the application executable, and then the test bundle containing only unit test code. During the test, the "test code" will be "injected" into the application executable. Note that this kind of test will start your application.

You can set the "target" of a Unit Test bundle in the "General" tab of the target editor:

Select project in left hand navigation area, select the unit test target in the target editor, select "General" tab, select a target from the popup, or "None".

If you want to inject unit test code into a running application, you possibly need to adjust these settings as well (note: Xcode will setup this as default already):

  1. Open the Scheme Editor: Select Project, then command Product -> Scheme -> "YourProject".

    Then, select the "Build" scheme, check whether the corresponding Unit Test target is included in the "Targets" list. Check also that the check mark "Test" is set for the Unit Test's target.

  2. In the target editor, select the Unit Test, select "Build Phases" tab. Check if you have added the Unit Test's target as a "target dependency".

Trouble compiling libnet 1.1.7 for iOS7

Get libnet 1.1.7

Open a terminal window and go to libnet folder, next we need to compile libnet for iOS7 emulator:

export CC=clang
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH"
export CFLAGS="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -mios-simulator-version-min=7.0"
./configure
make
sudo make install

Begin by selecting the project in Xcode. Select Target and then select Build Settings. Scroll down in the Build Settings until you get to the Linking section. Under the Other Linker Flags option, add -lnet. Now scroll down until you reach the Search Paths section and add /usr/local/lib to Library Search Paths. Finally, add /usr/local/include to the header's search path.

build troubles when adding tests to XCode 5 project

From reading "I decided it was time to write some tests," I'm guessing it's been a while since you created the project. So maybe…

  • You created the project using Xcode 4. The test target would use SenTestingKit.
  • You added IsoDateTest.m using Xcode 5. The latest file template uses XCTest.

Check the list of libraries under the test target's build settings. Replace SenTestingKit.framework with XCTest.framework.



Related Topics



Leave a reply



Submit