6

I'm having a issue compiling my app for Simulator. In the device runs perfectly but once I tried it to compile in simulator I get the following error:

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)

I checked before posting this question, but the answers I found in stackoverflow, like to run this,

export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xct‌oolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH

or

The problem was that Xcode 5 replaces gcc with clang and adds in a "-triple" option that specifies OSX as the target. If you pass "-miphoneos-version-min=7.0" on both gcc command lines it works. You can see the clang command line if you pass "--verbose" to gcc. It's also necessary to add to the PATH for Xcode 5 so that cmake can find the necessary tools: export PATH=/Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xct‌​oolchain/usr/bin:/Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:$PATH None of this is official.. but works for me so far.

I dont really understand how to to do this. Any help, please?

Pau Senabre
  • 4,155
  • 2
  • 27
  • 36
  • I guess your problem is fat static library problem. You need to compile your static library for both device and simulator. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4 this link might help. Also you need to search for static fat library. – Güngör Basa Apr 15 '14 at 19:14
  • Thanks Güngör, but there is not an easier way without having to create and compile in command tool makefiles? – Pau Senabre Apr 15 '14 at 19:54
  • I had the same problem on iOS6 with different library. It know it is hard to do. Unfortunately, that is the only way I know – Güngör Basa Apr 15 '14 at 20:03

2 Answers2

10

Check Build Settings for your test target. This values should look similar:

enter image description here

If you have any escaped symbol, consider to fix it. I had here : \". I just removed them

Also notice: order is important!

P.S. from GraehamF It's always a good thing to Build -> Clean and restart Xcode, so the changes to take affect

Ossir
  • 3,109
  • 1
  • 34
  • 52
  • Ok, now my error changed to this-> ld: warning: ignoring file p\342D\323\375, missing required architecture i386 in file p\342D\323\375 (3 slices) – Pau Senabre Apr 15 '14 at 19:22
  • Ok, the error that I had before came back. Should I add any framework search path to my main target!? the same as my test target? – Pau Senabre Apr 15 '14 at 19:48
  • You don't need any framework search paths in your main target except you explicitly use framework that require that. – Ossir Apr 16 '14 at 06:13
  • Missing architecture - means you don't build your dependency with required architecture or you don't have it in static library that you use – Ossir Apr 16 '14 at 06:14
  • 1
    Try to set `Build active architecture only` to NO for dependency target, it will force build for every architecture that you suppoty – Ossir Apr 16 '14 at 06:16
  • I tried build active architecture to NO, but still the same. I took off the XCTest, and seems that the problem is somewhere else. Here is the error I'm getting now -> "_OBJC_CLASS_$_CAShapeLayer", referenced from: objc-class-ref in AMTagView.o "_kCAFillRuleEvenOdd", referenced from: -[AMTagView drawRect:] in AMTagView.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) – Pau Senabre Apr 16 '14 at 06:20
  • `CAShapeLayer` is referenced in `QuartzCore.framework`. Add link to Quartz in your test target too. – Ossir Apr 16 '14 at 09:08
  • Thanks. Finally I solved by hiding the instances that were using _kCAFillRuleEvenOdd. – Pau Senabre Apr 16 '14 at 09:40
  • had similar issue, had to clean and restart XCode for the changes to take effect and the project to build though :/ – GraehamF May 27 '14 at 16:07
2

When I faced this error with an XCode project, I open the file ???.xcodeproj (in a SubLime Text editor) and removed the below lines. The warning will no longer be there!

LIBRARY_SEARCH_PATHS = (
    "\"${PROJECT_DIR}/../../../../../usr/lib\"/**",
    "\"${PROJECT_DIR}/../../../../../usr/lib\"/**",
);
Roy Scheffers
  • 3,832
  • 11
  • 31
  • 36
aUser
  • 21
  • 1