26

I cannot compile my project for the device or simulator anymore. I get 13 Apple Mach-O-Linker errors. It all started after I failed attempt to use sharekit. Here is the log from the error:

ld: warning: directory not found for option '-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks'
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_NSURLRequest", referenced from:
      objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
      objc-class-ref in Brandsonic_Web_mobileViewController.o
  "_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
      objc-class-ref in main.o
  "_objc_msgSendSuper2", referenced from:
      -[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileViewController didReceiveMemoryWarning] in Brandsonic_Web_mobileViewController.o
      -[Brandsonic_Web_mobileViewController dealloc] in Brandsonic_Web_mobileViewController.o
  "_objc_setProperty", referenced from:
      -[Brandsonic_Web_mobileAppDelegate setWindow:] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileAppDelegate setViewController:] in Brandsonic_Web_mobileAppDelegate.o
  "__objc_empty_vtable", referenced from:
      _OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
      _OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
      _OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
      _OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
      _OBJC_METACLASS_$_SecondView in SecondView.o
      _OBJC_CLASS_$_SecondView in SecondView.o
  "_objc_msgSend", referenced from:
      _main in main.o
      -[Brandsonic_Web_mobileAppDelegate application:didFinishLaunchingWithOptions:] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileAppDelegate GOOGLE] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileAppDelegate YOUTUBE] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileAppDelegate WIKI] in Brandsonic_Web_mobileAppDelegate.o
      -[Brandsonic_Web_mobileViewController webView:shouldStartLoadWithRequest:navigationType:] in Brandsonic_Web_mobileViewController.o
      ...
  "__objc_empty_cache", referenced from:
      _OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
      _OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
      _OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
      _OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
      _OBJC_METACLASS_$_SecondView in SecondView.o
      _OBJC_CLASS_$_SecondView in SecondView.o
  "_OBJC_CLASS_$_NSObject", referenced from:
      _OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
  "___CFConstantStringClassReference", referenced from:
      CFString in Brandsonic_Web_mobileAppDelegate.o
      CFString in Brandsonic_Web_mobileAppDelegate.o
      CFString in Brandsonic_Web_mobileAppDelegate.o
      CFString in Brandsonic_Web_mobileViewController.o
      CFString in Brandsonic_Web_mobileViewController.o
      CFString in Brandsonic_Web_mobileViewController.o
      CFString in Brandsonic_Web_mobileViewController.o
      ...
  "_OBJC_CLASS_$_NSKeyedUnarchiver", referenced from:
      objc-class-ref in Brandsonic_Web_mobileViewController.o
  "_OBJC_CLASS_$_NSUserDefaults", referenced from:
      objc-class-ref in Brandsonic_Web_mobileViewController.o
  "_OBJC_CLASS_$_NSURL", referenced from:
      objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
      objc-class-ref in Brandsonic_Web_mobileViewController.o
  "_OBJC_METACLASS_$_NSObject", referenced from:
      _OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
      _OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
      _OBJC_METACLASS_$_SecondView in SecondView.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
'

How do I fix this? Please help.

Sega dude
  • 1,103
  • 3
  • 12
  • 29
  • 1
    How is your project set up? It looks like you have 2 major problems, but you need to provide a lot more information about your project. First, are you using some kind of crack library? That's what it looks like... you downloaded the iOS SDK and tried to link directly to it. The errors are because it can't find the iOS 4 SDK you were using from a non-standard place and therefore cannot link the Foundation library. If you're using a valid version of Xcode with iOS 5 support (Xcode 4.2.1), delete your old, bogus framework, add Foundation and AppKit and re-compile. – Jason Coco Jan 02 '12 at 23:32
  • Thank you!! It turned out that I didnt have the foundation framework in my project. I added it and now I can compile! I still get 2 Apple Mach-0 Linker errors but aleast I can compile and don't have to rewrite my app. Thanks Jason Coco, without your suggestion, I would have never thought of checking for the proper frameworks. – Sega dude Jan 03 '12 at 21:08
  • for the (possibly unrelated) warning see this: http://stackoverflow.com/questions/9458739/ld-warning-directory-not-found-for-option – CodeSmile Sep 03 '13 at 08:59

12 Answers12

49

For every one with an similar error. If that happens you normally can remove the "Path" under Point

target->Build Settings->Library Search Paths enter image description here

crashbus
  • 1,678
  • 18
  • 37
18

This error can occur when a framework is added to a project more than once.

  • You can fix this by removing the duplicate. To find it, select the framework in the Xcode project navigator and choose Show in Finder. Then clean and build your project.

This can also be caused if you're missing framework header files or a reference to them.

  • In that case, you should trying removing the SDK or framework and adding it again.

Good luck.

zekel
  • 9,227
  • 10
  • 65
  • 96
Divine_Code
  • 259
  • 2
  • 4
5

If you installed dependencies using CocoaPods, make sure you open your XCode project by clicking on your .xcworkspace file, and not the .xcodeproj file.

Chris Chute
  • 3,229
  • 27
  • 18
  • Yes. Worked for me! I am using Cordova. Obviously Cordova uses CocoaPods. Thank you! – hol Aug 24 '17 at 13:40
2

It seems like the project file may have been corrupted somehow.

The most sure way to fix this is to create a new project, and move your files and old info.plist over on top of it.

The next most likely way to fix this is to create a new target in your current project, and see if that will compile (if you have any special flags from the old target you'll want to copy them).

Also you could try compiling for Release vs. Build and if one of them works look at all of the compiler options and see what is different.

If you added a header search path for Sharekit, perhaps try clearing out the whole header search path and see if that fixes things. Also make sure your project is still including frameworks that a brand new project includes (UIKit and NSFoundation, possibly others).

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
1

Add the .m file to compile source page.

steps:-

  1. clicking on he project in the navigation menu
  2. select the target
  3. select build phases
  4. Select the + button and add the file in compile sources.

Hope that helps anyone with this problem

Neenu
  • 6,848
  • 2
  • 28
  • 54
0

I too had the same problem with 45 same kind errors, when I add the libxml2.dylib into my project the errors disappeared.

Easwaramoorthy Kanagaraj
  • 3,925
  • 8
  • 36
  • 62
0

In some cases your library Search Path is empty.Because there are many Apple-mac-o linker errors.

See my answer also at.

Apple Mach-O Linker Error using Core Data classes in OCUnit

Community
  • 1
  • 1
Gajendra K Chauhan
  • 3,387
  • 7
  • 40
  • 55
0

I had this issue, now for my circumstances selecting a more recent iOS version as the deployment target rectified this for me. My project was set to deploy to iOS 5 by default and changing this to 7 (the most recent) did the trick.

For anyone new to iOS development this can be done by clicking on your XCode project file in the navigator > deployment info > deployment target and selecting the appropriate version from the drop down menu.

I'm sceptical that this will solve some of the issues that others are having but there may be a few people out there in the same boat as me.

user3032314
  • 61
  • 1
  • 2
0

It's because the project inserted the core data's xcdatamodeld file in compile sources. Select your project -> Build Phases -> Compile Sources and delete projectName.xcdatamodeld file. And also check if you have imported .m file instead of .h file, it also gives the same linker error. Check all the #import codes. And check if you have added core data frame work in library and imported core data .h file. Check for creation of NSManagedObject and import it's file. Just try it and reply me if still any error.

0

I had the same problem,

I just simply set the Build Option -> Enable Bitcode to NO

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130
0

I faced this problem with my self developed cocoapod.

Error was: Apple Mach-O Linker errror

It turned out, that I had defined a protocol and implemented a protocol extension. One method of the protocol extension was public, but the protocol itself was not. And this caused the Apple Mach-O Linker error.

Example:

protocol MyProtocol { var field: String { get} }

extension MyProtocol { public func giveMeSomething() -> String }

public class MyClass: MyProtocol {}

In the description the error mentioned MyClass referenced from MyProtocol -> MyProtocol referenced from giveMeSomething()...

So, the solution was to make Myprotocol also public

Hope that helps someone.

scrat84
  • 185
  • 1
  • 8
0

The problems are the spaces in your path:

xcode uses the following switch for the linker:

-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks

and since it is not quoted it won't work. ( It is looking for the folder "/Users/bbrandy95/Documents/Broken"

You should rename the directories, or look through the project settings and add quotes to the directories. (But this might be tricky to find)

Bastian
  • 10,403
  • 1
  • 31
  • 40
  • It's not an issue of quotes. The full path is visible as part of the "option" so when it was passed to the linker, it was properly escaped and/or quoted. The problem is he probably moved or deleted his pirated SDK. – Jason Coco Jan 02 '12 at 23:42
  • 1
    how do you pirate a sdk you can download for free ? the error is written in the first line... it should be `-F"path with spaces"` if it contains spaces. – Bastian Jan 02 '12 at 23:49
  • 1
    I DID NOT pirate my SDK. I repeat, I DID NOT pirate my SDK. I BOUGHT and PAID FOR Xcode 4 from the mac app store when it was $4.99 for snow leopard. Then when I bought lion from the mac app store I downloaded xcode 4.1 and updated to 4.2 when it came out. I haven't been able to update to 4.2.1 due to an error. I have to fake code sign my work because I am a jailbreak developer. I'm offended that I would be accused of such a thing. – Sega dude Jan 03 '12 at 20:55
  • @Segadude Sorry, my bad, I shouldn't have used the word 'pirate'. Usually having things in non-standard locations is because you downloaded the SDK from some other location rather than paying the $99 for the dev program. I should have written 'non-standard' SDK rather than 'pirated'. I apologize. – Jason Coco Jan 03 '12 at 23:18
  • @Bastian Prior to iOS 5, the iOS SDK was *not* free. It was free to developers who paid the $99/year developer fee. As part of accepting the SLA to receive the SDK, you agreed not to transfer the SDK to anyone else for any reason and to remove the iOS SDK if you stopped developing as part of a paid dev program (team or individual). With Lion, they've made it available and you only need to pay if you release anything to either of the app stores. – Jason Coco Jan 03 '12 at 23:22
  • 2
    @JasonCoco that's not true. You could always download the xcode 3.x sdk for free but you did not get provisioning so you could only use it in the simulator or with jailbroken devices. xcode 4 was a $4.99 download in the appstore. you have only to pay the $99 if you want to do the legit development on the device – Bastian Jan 07 '12 at 21:47
  • @Bastian You could download Xcode 3 for free but it didn't come with the iPhone SDK. It came only with the Mac OS X SDK unless you downloaded it from the (then) iPhone Development Center site rather than the ADC Downloads Site. – Jason Coco Jan 07 '12 at 23:04
  • 1
    @JasonCoco you are wrong. http://en.wikipedia.org/wiki/IOS_SDK The SDK was released on March 6, 2008, and allows developers to make applications for the iPhone and iPod Touch, as well as test them in an "iPhone simulator". However, loading an application onto the devices is only possible after paying an iOS Developer Program fee, which is $99.00 USD per year – Bastian Jan 09 '12 at 12:05
  • @Bastian You are right and I am wrong. I was mis-remembering it. You were able to get access to the iOS stuff with just an ADC membership, just not the beta SDKs or (as you pointed out) the provisioning stuff to test on the device or publish. – Jason Coco Jan 09 '12 at 16:57