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

17,285

Solution 1

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

Solution 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\"/**",
);
Share:
17,285
Pau Senabre
Author by

Pau Senabre

I’m a Entrepreneurial Software Engineer, Full Stack iOS Developer & Consultant. Currently working at Soundbrenner Ltd as Software Engenieer/Senior iOS Developer.

Updated on June 04, 2022

Comments

  • Pau Senabre
    Pau Senabre almost 2 years

    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
    Pau Senabre about 10 years
    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
    Pau Senabre about 10 years
    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?
  • Ossir
    Ossir about 10 years
    You don't need any framework search paths in your main target except you explicitly use framework that require that.
  • Ossir
    Ossir about 10 years
    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
    Ossir about 10 years
    Try to set Build active architecture only to NO for dependency target, it will force build for every architecture that you suppoty
  • Pau Senabre
    Pau Senabre about 10 years
    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)
  • Ossir
    Ossir about 10 years
    CAShapeLayer is referenced in QuartzCore.framework. Add link to Quartz in your test target too.
  • Pau Senabre
    Pau Senabre about 10 years
    Thanks. Finally I solved by hiding the instances that were using _kCAFillRuleEvenOdd.
  • GraehamF
    GraehamF about 10 years
    had similar issue, had to clean and restart XCode for the changes to take effect and the project to build though :/