开发者

Apple Mach-O Linker Error when compiling for device

I've just upgraded to xcode 4.0 and I can no longer deploy to iPhone, I get a Apple Mach-O Linker Error, it still works for the simulator though.

    Ld /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel normal armv7
    cd /Users/yveswheeler/iParcel
    setenv IPHONEOS_DEPLOYMENT_TARGET 3.2
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -F/Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos -filelist /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel.LinkFileList -dead_strip -all_load -ObjC -lxml2 -miphoneos-version-min=3.2 -framework UIKit -framework CoreGraphics -framework QuartzCore /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Core.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Network.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Style.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UI.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iPa开发者_StackOverflow社区rcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework AddressBook -lz.1.2.3 -framework Foundation -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -framework MessageUI -framework AudioToolbox -o /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Intermediates/iParcel.build/Debug-iphoneos/iParcel.build/Objects-normal/armv7/iParcel

arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Core.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Network.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20Style.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UI.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UICommon.a: No such file or directory
arm-apple-darwin10-g++-4.2.1: /Users/yveswheeler/Library/Developer/Xcode/DerivedData/iParcel-fkeqjcjcbbhjwhdssjptkdxzzzxh/Build/Products/Debug-iphoneos/libThree20UINavigator.a: No such file or directory
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 failed with exit code 1


Here is permanent solution.Generally overwriting project may cause this prolems.Try this method.

-UPDATE - Clang error - Mach-O Linker error

In some case error log window displaying .xctest error, to fix it

-> Select your project

-> Beside this(just before General tab) select your projectTest file from dropdown

-> There is one option (like ProjNameTests)

-> In Host Application, select your project from dropdown only if it show custom

DONE!

Apple Mach-O Linker Error when compiling for device

Old method deleted


I had the same problem and the issue was that I have accidently imported a .m file instead of .h in an implementation file.


Just ran into the same issue.

The solution (for me) = check your frameworks.

In my case I had added classes related to CoreData without "CoreData.framework". Adding it solved the MACH_O complaining.


open .xcworkspace file not .xcodeproj. I repeat open .xcworkspace file. All of your errors will go away.


Re: Problem as outlined in title:

Just in case anyone else missed the obvious...

I came across this error after installing a new version of Xcode4 and dragging existing files into a new project. I had failed to spot that the 'add to targets' checkbox was left unchecked in the 'Choose options for adding files:' dialog. Correcting my omission in Targets>Build Phases>Compile Sources solved the problem.


Menu > Product > Clean, this is what made it work. I'm not sure about everyone else. I added pic to show.

Apple Mach-O Linker Error when compiling for device


Bizarre error. For me, I just cleaned and restarted Xcode and the problem went away.


Fix: Build Settings > Enable Bitcode > No

Apple Mach-O Linker Error when compiling for device


None of these answers helped me. Then I tried to reinstall Cocoapods:

pod deintegrate

pod install

Problem solved!


The problem was that in XCode 4, the dependencies do not assume the architecture settings of the main project, as they previously did in XCode 3. I had to go through all of my dependencies setting them for the correct architecture.


I had the same and managed to solve it.

In xcode preferences, location tab change value under build location to "Place build products in locations specified by targets".


I struggled with this for a little while, and in my case it ended up being the Build Setting under Search Paths called FRAMEWORK_SEARCH_PATHS. It helped that I selected the "Levels" button, which seemed to compare my project, target and "Resolved" settings. I saw that my target setting somehow overrode the default of "$(inherited)", and the overridden value was what XCode "resolved" the setting to be. When I removed the override, which in this case specified the 3.2 sdk, the linker errors went away -- as did some recently appeared warnings about any classes where I called post-4.0 methods.

About those warnings -- I never saw them before I added the MessageUI framework for a recent change. I suspect, but don't know for sure, that when I added that framework, XCode tried to do something clever by adding that override to my target. I didn't do it explicitly at any point. The warnings were,for example, about the URLByAppendingPathComponent method of NSURL, which did not appear until sdk 4.0. Prior to adding the MessageUI framework, I never got that warning. And since I removed the override, I no longer get them.


I had this issue and importing QuartzCore fixed it.


Changing "Build Active Architectures Only" to Yes in CordovaLib.xcodeproj -> Build Settings did the trick for me. earlier the app was running on simulator, but not on the device.


You may need to update your build settings.

Verify the iOS target version and the processor architectures, as you may not have the old SDKs with XCode 4.

You may see «Missing SDK» on the build settings. Change that to whatever applies.


I had the same issue: just accidentally deleted a .m file, while .h was in the project. The problem disappeared when I've restored the .m file.


Check to make sure that you don't have a specific framework search path specified. if you go to the info on the target and just remove the framework search path entries it should use the defaults for your specified deployment version.


I just try to create a category class file and got this weird issue..and finally....

Wrong way to create category class that causes the issue:

New File -> Cocoa Touch -> Objective-C class, then I modified the name of files to Category Class like name.. (i.e. OriginalClass_CategoryName.h/m to OriginalClass+CategoryName.h/m, and also modified the contents in the file).

Right way here:

New File -> Cocoa Touch -> Objective-C category, and it'll auto generate files (OriginalClass+CategoryName.h/m).

Oh, how stupid I am!!


If you are using CoreData, and you use XCode to generate NSManagedObject subclasses for your entities, make sure you only generate one for each entity.

My problem was that it generated multiple NSManagedObject subclasses for the same entity (and put them in different folders).

I just deleted all of them and regenerated the NSManagedObject subclasses.


To add onto the list of weird stuff that fixed this issue...

I had some const CGFloat variables in a global header file like so

const NSInteger  globalInteger1 = 2;
const NSInteger  globalInteger2 = 3;

The moment I removed these, all was fine :)


I had exactly the same problem just because I had two same constants in different classes. You also can have this problem if you import .m file not .h file


Not sure if it's related, but seeing that you're running some three20 libraries, you may want to check this post on their website: http://three20.info/article/2011-03-10-Xcode4-Support


I had the same problem, and I solved it. In my case, "architectures" setting caused the problem. In my project file, Build Settings tab, Architectures were set to armv6. I changed it to Standard(armv7), do clean and build. Then it worked!


In my case the problem was having different architectures specified under different targets. I was building my application target with armv6, armv7 and cocos2d with Standard (amrv7). Go into build settings and make sure your architectures agree for all targets.


I solved this problem too weird !

Go to Target > Build Phases > Link Binary with libraries :

Remove all your frameworks and add them again !

Hope it works for you !


For Swift language ...

I am getting this error " ld: file too small (length=0) .... "

In my case I just clean the project and then rebuild it ..

Steps:-

1) goto Project -> Clean

2) goto Project -> Build

Hope this helps..


This did a trick for me:

Go to

1) Products > clean

2) Windows > Projects

3) Select your project and click on "Delete" derived Data

4) Products > Build


One possibility: Turn on "Dead code stripping" in the Xcode 4 build settings.

Another possibility: It could be that you switched to using LLVM for some framework that was previously using GCC. Moving back to GCC (or LLVM GCC) may get rid of those warnings.


I mistakenly defined a new constant with the same name as an existing constant in a different file and it caused this error for me using xCode 4.3.1. xCode didn't complain but the compiler doesn't like it.


I was able to fix this error by editing "Library Search Paths"

It cropped up in the first place because I had moved a couple folders around, and that ended up giving my build settings two different search paths because they are are automatically added to your build settings when you link a library/framework, but they are not always removed.

So if you move a linked library/framework to a different directory and re-link it, you'll have to manually edit the search path.

You might be able to dodge this by removing the library/framework before moving it, but I haven't tested that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜