ld: building for iOS Simulator, but linking against dylib?

Pau Senabre picture Pau Senabre · Apr 15, 2014 · Viewed 15.7k times · Source

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?

Answer

Ossir picture Ossir · Apr 15, 2014

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