Apple Mach-O Linker errors and I don't know what to do
Asked Answered
S

12

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.

Sawicki answered 2/1, 2012 at 23:22 Comment(3)
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.Tantalum
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.Sawicki
for the (possibly unrelated) warning see this: #9459239Crosspurpose
S
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

Single answered 30/5, 2012 at 18:39 Comment(4)
If you are using a framework like Pixate, try doing the same thing for Framework Search Paths (leaving $(inherited) alone).Handling
But what if I don't have any items in path?Infuriate
I have got 17 errors and all have been removed using the above method, but , still having one error. Please tell me what to do..Glomma
Leaving only $(inherited) on Library Search Paths works for me :) Thanks!Cinematograph
H
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.

Herrington answered 16/9, 2014 at 7:25 Comment(3)
Fixed my issue after 4 days! HUZZAH!Indescribable
This was not quite my issue, rather there were a couple of frameworks listed where the actual frameworks behind were missing (these frameworks are shown with red text). I just had to delete those frameworks and rebuildCutshall
Glad to help :)Herrington
B
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.

Britannic answered 4/12, 2016 at 20:59 Comment(1)
Yes. Worked for me! I am using Cordova. Obviously Cordova uses CocoaPods. Thank you!Dowie
A
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).

Aeolipile answered 2/1, 2012 at 23:30 Comment(0)
H
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

Heng answered 15/10, 2014 at 10:12 Comment(0)
C
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)

Cathleencathlene answered 2/1, 2012 at 23:31 Comment(9)
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.Tantalum
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.Cathleencathlene
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.Sawicki
@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.Tantalum
@Cathleencathlene 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.Tantalum
@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 deviceCathleencathlene
@Cathleencathlene 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.Tantalum
@JasonCoco you are wrong. 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 yearCathleencathlene
@Cathleencathlene 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.Tantalum
C
0

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

Clorindaclorinde answered 7/3, 2013 at 14:7 Comment(0)
I
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

Infuriate answered 24/6, 2013 at 12:15 Comment(0)
D
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.

Desmund answered 8/1, 2014 at 9:48 Comment(0)
M
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.

Mackinaw answered 5/6, 2017 at 6:3 Comment(0)
B
0

I had the same problem,

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

Brottman answered 24/7, 2017 at 9:50 Comment(0)
S
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.

Smolensk answered 24/8, 2017 at 8:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.