symbol(s) not found for architecture i386

185,852

Solution 1

You are using ASIHTTPRequest so you need to setup your project. Read the second part here

https://allseeing-i.com/ASIHTTPRequest/Setup-instructions

Solution 2

If you get this sort of thing appearing suddenly, it usually means the project is missing some frameworks it needs. Libraries and dependent projects can require frameworks, so if you've added one recently then that can cause this error.

To add frameworks, right click on the project name in the project view, select Add, then select Existing frameworks... from the list. Then find the framework with the symbols you're missing.

As to how you find which frameworks you need, I've found using google the easiest, though you could probably use the Xcode help search too. Search for one of the symbols, doing your best to work out the unmangled name (e.g., SCNetworkReachabilityGetFlags), and then the first documentation link you find at developer.apple.com is often the right one. You usually don't have to hunt very far. In this case, that's this page:

https://developer.apple.com/documentation/systemconfiguration/scnetworkreachability-g7d

Then at the top of the page, it tells you which framework to use, SystemConfiguration in this case. So add that to the project, and compile again.

Then just keep doing this until it works...

Edit: I've never used the simulator, but this is what you do on the device - I assume it's the same...

Solution 3

Sometimes there are source files which are missing from your target.

  1. examine which symbols are missing
  2. target->build phases->compile source
  3. add the missing source files if they are not listed
  4. command+b for bliss

You can select the files that seem to be "missing" and check in the right-hand utility bar that their checkboxes are selected for the Target you are building.

Solution 4

I solved it using the following method (for XCode 4):

1) Select the project in the project navigation window which will show project summary on right

2) Select 4th tab build phases

3) Select Link binary with library option

4) Add framework for which you are getting

5) Move the framework from main folder to the frameworks folder

6) Build it again and errors are gone.

Solution 5

Thought to add my solution for this, after spending a few hours on the same error :(

The guys above were correct that the first thing you should check is whether you had missed adding any frameworks, see the steps provided by Pruthvid above.

My problem, it turned out, was a compile class missing after I deleted it, and later added it back in again.

Check your "Compile Sources" as shown for the reported error classes. Add in any missing classes that you created.

Share:
185,852

Related videos on Youtube

Doz
Author by

Doz

Updated on July 17, 2020

Comments

  • Doz
    Doz almost 4 years

    When trying to compile with Xcode, I am getting the following error:

      **Ld /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher normal i386
        cd /Users/doronkatz/Sites/xCode/iKosher
        setenv MACOSX_DEPLOYMENT_TARGET 10.6
        setenv PATH "/Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Xcode4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator -L/Users/doronkatz/Sites/xCode/iKosher -F/Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator -filelist /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Intermediates/iKosher.build/Debug-iphonesimulator/iKosher.build/Objects-normal/i386/iKosher.LinkFileList -mmacosx-version-min=10.6 -all_load -ObjC -Xlinker -objc_abi_version -Xlinker 2 -lz -framework Security -framework CFNetwork -framework CoreData -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -o /Users/doronkatz/Library/Developer/Xcode/DerivedData/iKosher-bphnihrngmqtkqfgievrrumzmyce/Build/Products/Debug-iphonesimulator/iKosher.app/iKosher
    
    Undefined symbols for architecture i386:
      "_UTTypeCreatePreferredIdentifierForTag", referenced from:
          +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
      "_UTTypeCopyPreferredTagWithClass", referenced from:
          +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
      "_kUTTagClassMIMEType", referenced from:
          +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
      "_kUTTagClassFilenameExtension", referenced from:
          +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
      "_SCNetworkReachabilitySetCallback", referenced from:
          -[Reachability startNotifier] in Reachability.o
      "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
          -[Reachability startNotifier] in Reachability.o
      "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
          -[Reachability stopNotifier] in Reachability.o
      "_SCNetworkReachabilityCreateWithName", referenced from:
          +[Reachability reachabilityWithHostName:] in Reachability.o
      "_SCNetworkReachabilityCreateWithAddress", referenced from:
          +[Reachability reachabilityWithAddress:] in Reachability.o
      "_SCNetworkReachabilityGetFlags", referenced from:
          -[Reachability currentReachabilityStatus] in Reachability.o
          -[Reachability isReachable] in Reachability.o
          -[Reachability isConnectionRequired] in Reachability.o
          -[Reachability isConnectionOnDemand] in Reachability.o
          -[Reachability isInterventionRequired] in Reachability.o
          -[Reachability isReachableViaWWAN] in Reachability.o
          -[Reachability isReachableViaWiFi] in Reachability.o
          ...
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status**
    

    Not sure what it means.

  • Steven Hepting
    Steven Hepting almost 12 years
    This can often occur when merging two project files uncleanly and the target membership is lost.
  • GeneCode
    GeneCode almost 12 years
    THANKS... This works for me. I was implenting a custom class. Copied both the custom class. h and .m into the project. Did a #import on it, still the error comes out. Adding the custom class' .m into "Compile Sources" section solved it!
  • Souleiman
    Souleiman over 11 years
    Awesome! I had the same issue as Rocotilos, I imported a custom class, imported, but still had issue. This did the trick! Thanks a lot!
  • dreampowder
    dreampowder over 11 years
    Thank you so much, somehow xcode didnt added the required .m file into build phases stage!
  • Frank Yin
    Frank Yin over 11 years
    Thank you. I found this answer in search of MFMailCompose, and solved by adding the MessageUI.framework
  • user1105951
    user1105951 almost 11 years
    Thanks :) Add 2 files to the project and only after doing those steps everything was O.K
  • Will
    Will over 7 years
    I got this Symbol Not Found error but the situation was much simpler. I added a new module (file) with one new function that I needed to one of my Schemes. When I built a different scheme a few weeks later the call to that function was not found. Adding it to the target was all that was needed.