8

So , i have two problems with Xcode . I'm new in the iPhone app development so that any help would be useful . I'm creating an app with a mapView , so first i did everything as it should be . Declaration , view did load , delegates and so on . After that i connected it the property to the map view , and it turned out 28 errors..On the simulator it works , including the map , but on the phone it always breaks . And after that i deleted all the code that's for the map view, it stayed the same .

Some ideas what could this be ? how to make a map view for iPhone ?

"_OBJC_CLASS_$_NSBundle", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_NSFileManager", referenced from:
      objc-class-ref in AppDelegate.o
  "_objc_msgSendSuper2", referenced from:
      -[AppDelegate dealloc] in AppDelegate.o
      -[MainViewController didReceiveMemoryWarning] in MainViewController.o
      -[MainViewController viewDidLoad] in MainViewController.o
      -[MainViewController viewDidUnload] in MainViewController.o
      -[MainViewController viewWillAppear:] in MainViewController.o
      -[MainViewController viewDidAppear:] in MainViewController.o
      -[MainViewController viewWillDisappear:] in MainViewController.o
      ...
  "_objc_setProperty", referenced from:
      -[AppDelegate setWindow:] in AppDelegate.o
      -[MainViewController setManagedObjectContext:] in MainViewController.o
      -[MainViewController setOdaberiTaxi:] in MainViewController.o
      -[MainViewController setIzbornik:] in MainViewController.o
      -[MainViewController setTaxiPicker:] in MainViewController.o
      -[MainViewController setListaTaxiZG:] in MainViewController.o
      -[MainViewController setToolbar:] in MainViewController.o
      ...
  "__objc_empty_vtable", referenced from:
      _OBJC_CLASS_$_AppDelegate in AppDelegate.o
      _OBJC_METACLASS_$_AppDelegate in AppDelegate.o
      _OBJC_CLASS_$_MainViewController in MainViewController.o
      _OBJC_METACLASS_$_MainViewController in MainViewController.o
      _OBJC_CLASS_$_FlipsideViewController in FlipsideViewController.o
      _OBJC_METACLASS_$_FlipsideViewController in FlipsideViewController.o
  "_OBJC_CLASS_$_UIResponder", referenced from:
      _OBJC_CLASS_$_AppDelegate in AppDelegate.o
  "_objc_msgSend", referenced from:
      _main in main.o
      -[AppDelegate dealloc] in AppDelegate.o
      -[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
      -[AppDelegate applicationWillTerminate:] in AppDelegate.o
      -[AppDelegate saveContext] in AppDelegate.o
      -[AppDelegate managedObjectContext] in AppDelegate.o
      -[AppDelegate managedObjectModel] in AppDelegate.o
      ...
  "_OBJC_CLASS_$_UIActionSheet", referenced from:
      objc-class-ref in MainViewController.o
  "_OBJC_CLASS_$_UIViewController", referenced from:
      _OBJC_CLASS_$_MainViewController in MainViewController.o
      _OBJC_CLASS_$_FlipsideViewController in FlipsideViewController.o
  "_objc_autoreleasePoolPop", referenced from:
      _main in main.o
  "__objc_empty_cache", referenced from:
      _OBJC_CLASS_$_AppDelegate in AppDelegate.o
      _OBJC_METACLASS_$_AppDelegate in AppDelegate.o
      _OBJC_CLASS_$_MainViewController in MainViewController.o
      _OBJC_METACLASS_$_MainViewController in MainViewController.o
      _OBJC_CLASS_$_FlipsideViewController in FlipsideViewController.o
      _OBJC_METACLASS_$_FlipsideViewController in FlipsideViewController.o
  "_UIApplicationMain", referenced from:
      _main in main.o
  "_OBJC_METACLASS_$_UIResponder", referenced from:
      _OBJC_METACLASS_$_AppDelegate in AppDelegate.o
  "_OBJC_CLASS_$_UIView", referenced from:
      objc-class-ref in MainViewController.o
  "_OBJC_CLASS_$_UIApplication", referenced from:
      objc-class-ref in MainViewController.o
  "_OBJC_CLASS_$_NSArray", referenced from:
      objc-class-ref in MainViewController.o
  "_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
      objc-class-ref in AppDelegate.o
  "___CFConstantStringClassReference", referenced from:
      CFString in AppDelegate.o
      CFString in AppDelegate.o
      CFString in AppDelegate.o
      CFString in AppDelegate.o
      CFString in MainViewController.o
      CFString in MainViewController.o
      CFString in MainViewController.o
      ...
  "_OBJC_CLASS_$_UIAlertView", referenced from:
      objc-class-ref in MainViewController.o
  "_OBJC_METACLASS_$_UIViewController", referenced from:
      _OBJC_METACLASS_$_MainViewController in MainViewController.o
      _OBJC_METACLASS_$_FlipsideViewController in FlipsideViewController.o
  "_NSSQLiteStoreType", referenced from:
      -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  "_objc_autoreleasePoolPush", referenced from:
      _main in main.o
  "_NSStringFromClass", referenced from:
      _main in main.o
  "_NSLog", referenced from:
      -[AppDelegate saveContext] in AppDelegate.o
      -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  "_OBJC_CLASS_$_NSManagedObjectModel", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_NSURL", referenced from:
      objc-class-ref in MainViewController.o
  "_OBJC_METACLASS_$_NSObject", referenced from:
      _OBJC_METACLASS_$_AppDelegate in AppDelegate.o
      _OBJC_METACLASS_$_MainViewController in MainViewController.o
      _OBJC_METACLASS_$_FlipsideViewController in FlipsideViewController.o
  "_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rob mayoff
  • 375,296
  • 67
  • 796
  • 848
dsafa
  • 783
  • 2
  • 8
  • 29
  • See my answer. It works only if you have Apple-mac o linker error with lib file http://stackoverflow.com/questions/11312915/apple-mach-o-linker-error-using-core-data-classes-in-ocunit/17275174#17275174 – Gajendra K Chauhan Jun 24 '13 at 12:17

3 Answers3

41

I had a similar error and this solved my problem : Click "TARGETS" > Build Phases >Link Binary With Libraries > Click "+" > CoreData.framework. > Add.

DevonDahon
  • 7,460
  • 6
  • 69
  • 114
9

If in 2022 you're hitting a large number of Xcode linker errors of the type

Undefined symbols for architecture arm64: "_objc_msgSend$X"

where X is an method internal to the library being linked, then you have likely struck a new Xcode 14 feature, Objective-C msgsend selector stubs. This optimisation will prevent a library built with default Xcode 14 settings being correctly linked via Xcode 13 and earlier.

If linking of a static library built with Xcode 14 with an earlier version of Xcode is required, the selector stub generation can be disabled during compilation by adding -fno-objc-msgsend-selector-stubs to the compiler flags:screenshot of xcode project settings compiler flags

bleater
  • 5,098
  • 50
  • 48
  • dont work for me (I get a wierd symbol _objc_-sgSendSuper2) Undefined symbols for architecture arm64: "_objc_-sgSendSuper2", referenced from: ... ld: symbol(s) not found for architecture arm64 – Berte Colin Dec 12 '22 at 06:46
  • Thanks for this @bleater - I'm on an Intel Mac, so Xcode 31.2.1 is the last version I'm allowed and I believe my project was built with XCode 14. I'm not 100% clear on how to add that `-fno-objc-msgsend-selector-stubs` line of code to the C Flags - I keep getting errors. Would it be OK to give more details? – Desmond May 05 '23 at 07:12
  • @Desmond If the library has been built with Xcode 14 with msgsend selector stubs, then there are only two options: either link it using Xcode 14, or ask the developer to rebuild it with selector stubs disabled, as per the build option in my answer. – bleater Aug 08 '23 at 22:01
  • @Desmond My Intel Mac is running Xcode 14.3 just fine. But I'm also running macOS 13.4 Ventura. I'm even running Xcode 15.0 beta just fine on macOS 13.4. – HangarRash Aug 08 '23 at 23:26
0

You are missing symbols like __objc_msgSend which are fundamental parts of the Objective-C runtime. These symbols are found in libobjc.dylib, which Xcode should link with automatically for any Objective-C project. Furthermore, you're missing symbols from the Foundation framework (e.g. _OBJC_CLASS_$_NSBundle) and UIKit (e.g. _OBJC_CLASS_$_UIView). These frameworks are automatically included when you create a new Objective-C project in Xcode.

The fact that you are getting these errors indicates that your project is seriously messed up. While it is probably possible for an expert to fix your problem, you probably don't have an expert around.

So the simplest solution for you is to just create a new project in Xcode and copy your source files over to the new project. And in the new project, be careful not to change or delete build settings unless you understand what they are for. It is easy to accidentally change a build setting, without even realizing it, and start getting inscrutable error messages.

If that doesn't fix your problem, then it is possible that your Xcode installation is damaged, and you may have to reinstall Xcode.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
  • and that's what i did.. i started a new project , and after i did include the MapKit and CoreLocation , it just crashed . By then everything worked well . But what i also don't understand is why is then the app running on the simulator ? – dsafa Dec 01 '11 at 23:02
  • Xcode creates separate builds for the simulator and for the device. I don't know what happened to your project to make those two builds come out different. – rob mayoff Dec 01 '11 at 23:08
  • But the interesting thing is also that when i create a simple project which includes only map view.h and a MKMapView , without any other code , it displays on the simulator , but breaks on the phone... – dsafa Dec 01 '11 at 23:11
  • It's possible that you have damaged your developer tools installation. You might try reinstalling Xcode. – rob mayoff Dec 01 '11 at 23:15
  • I’m sorry but this is not very helpful. The other suggested answer actually helped me. – sam hocevar Feb 28 '13 at 13:43
  • In the original question, the linker cannot find the symbols in the Objective-C runtime (e.g. `_objc_msgSend`). Adding the Core Data framework (or any other framework) will not solve that problem. – rob mayoff Feb 28 '13 at 20:33
  • @LoungeKatt It is not necessary to link Core Data or any other framework to link the Objective-C runtime. Xcode should **always** link the Objective-C runtime if the target includes any Objective-C code. See the “Implicitly Link Objective-C Runtime Support” build setting (which defaults to Yes). I agree that dsafa wasn't linking with some frameworks he needed, but that is in addition to the problem that Xcode was not linking the Objective-C runtime, which led me to believe his project was broken. – rob mayoff Nov 15 '14 at 03:14
  • @robmayoff Adding CoreData **will** solve the _OBJC_CLASS_$_NSFileManager error, which will then allow the Objective-C runtime to properly link to the file. I am skeptical about why, after pointing this out originally, you edited the original question, though. Seems odd to have done so two years later when your answer was disputed. – Abandoned Cart Jan 01 '15 at 03:07
  • I fixed the formatting and made the title more specific. I didn't change the meaning of the question. I had no reason to revisit the question until Sam Hocevar commented on my answer, and in those two years I became more comfortable editing questions. – rob mayoff Jan 01 '15 at 04:52