symbol(s) not found for architecture i386 - objective-c

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.

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...

Sometimes there are source files which are missing from your target.
examine which symbols are missing
target->build phases->compile source
add the missing source files if they are not listed
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.

You are using ASIHTTPRequest so you need to setup your project. Read the second part here
https://allseeing-i.com/ASIHTTPRequest/Setup-instructions

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.

The problem is that target membership for the added filed is missing to the app target .So select the file and add the checkmark to the box of target membership
For example if the error shown in a method definition in common.m

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.

Make sure that the missing framework is actually listed under "Target/Build Phases/Link Binary With Libraries" if not just add it. As mentioned before it usually indicates a missing framework.
In my project there were two identical framework listed, when I removed one of them I had this error, because it also removed it form the the "Link Binary With Libraries" list.
I added back and the problem disappeared (and I still have two frameworks listed)

I fixed a similar error on my project by changing the Build Settings > Architectures for ALL of my targets.
The problem:
When I upgraded from Xcode 4.4 to Xcode 4.5, my project still compiled fine on the simulator but did not compile on devices. On devices it threw the error "symbol(s) not found for architecture armv7s," along with the misleading "Apple Mach-O Linker Error" and "clang: error: linker command failed with exit code 1 (use -v to see invocation)."
The cause (in my case):
My project had multiple targets, and even though the Build Settings > Architectures for the main target was set to include armv7s architecture, the main target depended on another target (listed under Build Phases > Dependencies), and I hadn't thought to reset the Build Settings > Architectures for that other target, and I had to change that to include armv7s.
I suppose the simulator and device run on different architectures, and that's why the simulator was OK while the device wasn't.

Does your project depend on another project, and is that a target in that project set up to be a direct dependency of your main target? If this is the case and the dependency isn't set up, the dependent target may not be getting built for all configurations (i.e. the simulator)
Just a wild guess.

Another situation that can cause this problem is if your code calls into C++, or is called by C++ code. I had a problem with my own .c file's utility function showing up as "symbol not found" when called from Obj-C. The fix was to change the file type: in Xcode 4, use the extended info pane to set the file type to "Objective-C++ Source"; in Xcode 3, use "Get Info" to change file type to "source.cpp.objcpp".

In my case none of the posted solutions worked. I had to delete the project and make a fresh checkout from the SVN server. Lucky me the project was hosted in a version control system. Don't know what I'd do otherwise.

In a C++ project using a defined templatized class, while receiving the same error, I selected .cpp file with the defined templatized class in the Project Navigator, then Delete > Remove Reference. Also the associated .h file, while still referenced in the project, needs to have a #include statement to the .cpp as follows:
#ifndef __CircularBuffer__CircularBufferT__
#define __CircularBuffer__CircularBufferT__
... snip ...
#include "CircularBufferT.cpp"
#endif /* defined(__CircularBuffer__CircularBufferT__) */
If you want to see, a simple project example is on github:
This is a little bit of indirection trickery and I don't recall the original source of this workaround.

If this error appears suddenly, it means the project is missing some frameworks. 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.
The other thing is if you added any classes in the compiled resources and removed that classes from the project then the error appears. The best thing to do is remove the classes from the compile resources(Build settings--> compile sources) which have removed from the project.
In my case i have added the admob classes in the project and compiled the project. In a later case i dont want to include admobs in my project so i deleted the references of the admob classes from my project. When this error occurred i deleted the .m class of my admob from compile resources solved this problem.

This happened to me while trying to copy over the PSPDFKIT demo library into my project. I followed all the instructions in the site + all the suggestions on this page.. for some reason it kept on giving the above error, the problem was that if i grepped the message in the error method.. it only appeared in the binary (obviously I have no access to the source code b/c I have to pay for it).
I noticed this in the instruction page though:
So I went to the guts of that config file and found this:
OTHER_LDFLAGS=$(inherited) -ObjC -fobjc-arc -lz -framework CoreText -framework CoreMedia -framework MediaPlayer -framework AVFoundation -framework ImageIO -framework MediaPlayer -framework MessageUI -framework CoreGraphics -framework Foundation -framework QuartzCore -framework AVFoundation -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -weak_framework UIKit
Then I went to the sample project provided by the author of the said library.. and noticed that the previous flags where copied verbatim to the other linker flags in my build settings.. however in my project.. they were not!.. So i simply copied and pasted them into my project's build settings other linker flags and everything worked!
take away point: if you are relying on some .xcconfig file on your setup, double check with a sample code source or something and make sure that it has actually been applied.. it wasn't applied properly in my case

Another reason this could be happening is when you UPGRADE an SDK.
If you simply delete the group, and then drag and drop the new folder to project, the "Library Search Path" would have both the SDKs. To solve, simply delete the old SDK path.

I had used a CLGeocoder without adding a Core.Location Framework. Basically this error can mean multiple things. I hope this helps someone else.

I've been stumped by this one before only to realize I added a data-only #interface and forgot to add the empty #implementation block.

Came across this issue in Xcode 11, fix was changing the Minimum Deployment Target from 10.0 to 11.0, hope this helps someone :)

Related

Do not use -ObjC flag for linked library in XCode

I need to link two libraries in a project, Cordova and a library from a hardware manufacturer. The hardware manufacturer's library gives an error if you compile with -ObjC but Cordova requires -ObjC flag.
Is there a way to force the -ObjC flag for a library and not for the other (or vice-versa)?
Thanks!
Specific error: Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_MPMusicPlayerController", referenced from:
objc-class-ref in libdtdev.a(AudioStream.o)
It looks like a posted the question just before I figured it out (like always). Instead of deleting the post, someone might want to know what the solution was...
If I keep the -ObjC flag in place and add the frameworks it's complaining about to the "Link Binary With Libraries" section (in my case "MediaPlayer.framework").

ObjC Lbrary Usage: Undefined symbols for architecture armv7

I have XCode library I wrote which I use inside Unity3D application.
The library works and now I need to make a change in the implementation, not the interface.
The problem is that in the XCode project created from Unity3D, when I use my library .a file I get this error (I've remove the specific class names).
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ABNUnityativeController", referenced from:
_OBJC_CLASS_$_ABUnityNativeController in libABSDK_Unity_NativeController_iOS.a(ABUnityNativeController.o)
"_OBJC_METACLASS_$_ABNativeController", referenced from:
_OBJC_METACLASS_$_ABUnityNativeController in libABSDK_Unity_NativeController_iOS.a(ABUnityNativeController.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm pretty sure the problem is how I compile my library.
I find that my project settings were bad.
When I choose the main project (I also have sub XCode project in it) inside Build Phases -> Link Binary With Libraries I had to add my sub-project which was listed under Workspace directory.

Error with iOS 5.1 when i use ASIHTTPRequest and SBJSON

i am getting this error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ASIHTTPRequest", referenced from:
objc-class-ref in FirstViewController.o
"_OBJC_CLASS_$_SBJsonParser", referenced from:
objc-class-ref in FirstViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Note i have added the frameworks core graphics,system configuration,mobile core services,libz.dylib,libz.1.2.5.dylib,CF Network,UI Kit and Foundation.
I have searched all the forums and spend almost 4 days but just don't find the cause.
When i comment my ASIHTTPRequest and SBJSON code lines,it works fine.
I have added all the classes for ASIHTTPRequest and SBJSON and checked thrice.
Could anyone suggest what am i doing wrong?
I would take a look at the Build Phases section in your Target. Under "Compile Sources", make sure you see the .m files for ASIHTTPRequest and for SBJson. Sometimes when you drag external classes into a project, even if you check the box to copy the files into your project, they don't make it into these compile sources. When you drag a file into Xcode, there is a check box to add the file to the target. If this isn't checked, the file won't make it into the Compile Sources. Delete the files and re-add them, ensuring this file is checked (or you can add the .m files manually if you'd like).
For ASIHTTP Request add the following frameworks:
libz.1.2.5.dylib
SystemConfiguration
UIKit
Foundation
CoreGraphics
MobileCoreServices
CFNetworks
If you are using ASIHttp classes in iOS 5 or later, you need to turn ARC off for the ASIHttpRequest classes in Project-> Build Phases -> Compile Sources by using -fno-objc-arc for the ASI API classes.
Hope it solves the problem.
i had this same problem , but when i included the following frame-work
its working fine now..Don't forget to include -fno-objc-arc in the compile source
Best Wishes.......
For the ASIHTTPRequest error, it sounds like you've not added ASIHTTPRequest.m to your project.
(Or you have added ASIHTTPRequest.m, but have forgotten to mention the 4 billion errors xcode is emitting about ARC - see Why are my ASIHTTPRequest files showing ARC errors? )

MailCore Errors IOS

I try to use MailCore in my project, but I get these error:
Undefined symbols for architecture armv7:
"_MailCoreEnableLogging", referenced from:
-[ImapSync run] in ImapSync.o
"_OBJC_CLASS_$_CTCoreMessage", referenced from:
l_OBJC_$_CATEGORY_CTCoreMessage_$_CTCoreMessageBuisnessMail in CTCoreMessage+BuisnessMail.o
"_OBJC_IVAR_$_CTCoreMessage.myFields", referenced from:
-[CTCoreMessage(CTCoreMessageBuisnessMail) libetpanDateTime] in CTCoreMessage+BuisnessMail.o
-[CTCoreMessage(CTCoreMessageBuisnessMail) senderDate] in CTCoreMessage+BuisnessMail.o
"_OBJC_CLASS_$_CTCoreAccount", referenced from:
objc-class-ref in AttachmentDownloader.o
objc-class-ref in ImapSync.o
"_MailCoreDisableLogging", referenced from:
-[ImapSync run] in ImapSync.o
"_IfTrue_RaiseException", referenced from:
-[ImapFolderWorker fetchFrom:to:seqDelta:syncingNew:progressOffset:progressTotal:alreadySynced:] in ImapFolderWorker.o
ld: symbol(s) not found for architecture armv7
but all of these methodes are there, I can see them in the MailCoreProject!
I hope someone can help me!
First, I would check if you have added libMailCore-ios.a to your list of "Linked Frameworks and Libraries".
If so, then the problem could be that the MailCore project was compiled for one device while your main project was compiled for a different device. For instance,
the MailCore project was compiled for simulator ... the symbols of MailCore were generated for x86 architecture
your main project was compiled for real iOS device ... so the linker was looking for MailCore symbols for armv7 architecture
Thus, the linker complained, symbols for armv7 architecture not found
To solve the problem, rebuild the MailCore subproject (build-clean and build) with the same device (or same simulator) as your main project.
These could be number of things. How You added MailCore to Your project? As a static library?
You are missing compiled files for armv7 architecture. Make sure that it's added in "build settings" in MailCore project and then try to build it.
You probably build MailCore for the simulator and now You are trying to run it on device. These have to be separated.
Also, You have to be sure that all libraries which MailCore is using, such as libetpan are compiled properly.
PS: adding MailCore to Your project isn't simple process, but it's worth it. :)

xcode "_OBJC_CLASS_$_Name", referenced in .... error, 4 days and cant figure out

I am new to programming, but have worked very hard to try and figure out why I am getting the above error. I have read and tried everything I have found online, the program is from Head First iPhone Development book Chapter 7 (their forum does not address this error and few questions on that forum every get answered).
I have tried and or confirmed:
Target is checked in the app target (by this I mean the main app name is the only one that shows and it is checked as target)
I have tried changing versions of the simulator and sdk
I have added #import of the class it is looking for (my code is EXACTLY as the books)
My gut is telling me it is something in the IB, but no posts suggest that could be the problem (maybe something wired wrong?)
Any help would be greatly appreciated!!
update:
the CoreData framework is there - not missing that. Thank you though, any other thoughts?
Sorry for posting in "answers", only option available (wrote and posted question prior to creating an account - sorry for being a laaaamo)
Here is the full error:
Ld build/Debug-iphonesimulator/iBountyHunter.app/iBountyHunter normal i386
cd /Users/Home/Desktop/iBountyHunter
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk -L/Users/Home/Desktop/iBountyHunter/build/Debug-iphonesimulator -F/Users/Home/Desktop/iBountyHunter/build/Debug-iphonesimulator -filelist /Users/Home/Desktop/iBountyHunter/build/iBountyHunter.build/Debug-iphonesimulator/iBountyHunter.build/Objects-normal/i386/iBountyHunter.LinkFileList -mmacosx-version-min=10.5 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreData -o /Users/Home/Desktop/iBountyHunter/build/Debug-iphonesimulator/iBountyHunter.app/iBountyHunter
Undefined symbols:
"_OBJC_CLASS_$_FugitiveDetailViewController", referenced from:
objc-class-ref-to-FugitiveDetailViewController in FugitiveListViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Thoughts? And thank you so much for the help!
I had this error when I accidentally had #import file.m instead of .h
It sounds like, for whatever reason, your FugitiveDetailViewController.m file isn't added to the target. Select the file in Xcode, Get Info, and ensure that the checkbox next to your target is checked.
try this
Remove the reference for the files from xcode
Right click in project explorer (in xcode)
Add New Files..
Select the files again and hit enter.
It seems in the newer xcodes if you drag the files they (.m) sometimes do not get added in the Compile Source under Build Phases.
You are missing the CoreData.framekwork.