Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 786
Pau Senabre Avatar asked Apr 15 '14 19:04

Pau Senabre


People also ask

Can I use Bluetooth in iOS simulator?

This is expected, in general iOS simulator does not support bluetooth/BLE) devices, you would need to use a device in order to test anything related to Bluetooth.

Is iOS simulator arm64?

The iOS simulator's architecture is x86_64 (the latest Xcode doesn't support an i386-based simulator that the answer refers to), whereas a real iOS device (such as an iPhone or iPad) can be arm64 or arm64e. So when building an app for the simulator you need to specify x86_64, not an ARM architecture.

What is build active architecture only?

The "build active architecture only" setting causes everything except the current Mac's architecture to be ignored (and the current one is of course valid), hiding the problem. Instead, you should look up a row or two in the settings, and change the "Architectures" setting to "Standard".


2 Answers

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

like image 197
Ossir Avatar answered Sep 19 '22 21:09

Ossir


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\"/**",
);
like image 37
aUser Avatar answered Sep 22 '22 21:09

aUser