-->

Apple Mach -O Linker command failed

2019-02-21 09:21发布

问题:

After updating my POD install, Xcode sprouted a new issue:

回答1:

Make sure you open the .xcworkspace file rather than the project file (.xcodeproj) when working with pods. That should solve the issue with linking.



回答2:

Some times you need just clean build. It helped me. To clean build go Product -> Clean



回答3:

There are several cases that cause this issue. At the moment, this question has no any accepted answer and also I found another solution for the same issue, I am posting my answer/experience here.

In you application, go to Target -> Build Settings, then you will find following attributes.

  • CLANG_WARN_INFINITE_RECURSION
  • CLANG_WARN_SUSPICIOUS_MOVE
  • GCC_NO_COMMON_BLOCKS

Set values for those as NO, then clean and build the project.



回答4:

Following steps helped me to get rid of this problem:

  1. Go to project path and remove Pods folder and Podfile.lock file.
  2. Reinstall pods again using "pod install" command.
  3. Open xcworkspace and clean it before running.

Hope it will save someone's time like it did for me.



回答5:

Close you project and go to project path and select your project with .xcworkspace instead of .xcodeproj. Reason your existing project doesn't contain any library you linked.



回答6:

Remove the local files of WikitudeSDK from target. Xcode is getting confused between the paths of library, which one to chose- pod or local.

Also try reinstalling podfile and remove wikitude from pod file to. IN linker search path settings, in build settings, check the paths mentioned to find the required library.

Lastly install gems before updating pods



回答7:

You have to check Link Binary With Libraries option. Sometimes you build pod that is not in your project anymore.

On the left panel click on your project name, then under Targets again (click on name), then Build Phases > Link Binary With Files. Delete everything that you dont use.



回答8:

Solved - Best Way

pod deintegrate  
pod install

Open xcworkspace and clean it before running.



回答9:

I got same error like duplication of "variable name". You need to check all variable and function name for all .m file and make sure it's not same in any other file.Then clean and build.

It's working for me.



回答10:

the solution for me was open the .xcworkspace file insted of .xcodeproj located inside my '/platforms/ios' folder.



回答11:

I had a similar problem and I just had to make sure to enable the "copy if necessary" checkbox when adding the framework into the project. Reference only didn't work for me...



回答12:

I have no clue why the error occurred in my case, I was reusing some code from another project I created a while ago and after I adapted the code, then I always got the "Apple Mach -O Linker command failed"- Message. My best guess is, that it happened because I created/deleted some files from the project.

The thing that solved it for me was this:

  • Create a new Project
  • copy all the necessary files from the old project to the new one (Drag and Drop, don't forget the "Copy if needed" Checkbox)
  • Build and see that it works

Sounds stupid and I have no idea why, but it worked.



回答13:

I am using XCode for compiling ionic 3 app.

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.10.1
    ionic (Ionic CLI) : 3.10.1

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 ios 4.5.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    ios-sim : 5.0.8 
    Node    : v8.4.0
    npm     : 5.4.0 
    OS      : OS X Yosemite
    Xcode   : Xcode 7.2 Build version 7C68 

There was not write permission in most of the file of ios, which was main issue.
I just changed the permission of ios file and got issue resolved by using command.

sudo chmod -R 775 platforms/ios/ 

Worked great.



回答14:

I experienced the error when overwriting project.

Still encountered the error after:

  • Changing the clang settings

  • ionic cordova platform remove ios rather than just delete ios platform folder before each new build (and of course add the platform again)

  • updating ruby as per instructions: https://forum.ionicframework.com/t/x-code-8-beta-2-apple-mach-o-linker-id-error/71998

Error was solved after changing to a different branch in github but perhaps one of the other troubleshooting methods played a part. Now all branches run on xcode without the Mach -O Linker Error.



回答15:

I had faced the same issue. I declared two classes with same name. Therefore it was conflicting with the class name. It worked for me after updation of class name.



回答16:

First thing you have to do is to delete the files in /Users/Yourname/Library/Developer/Xcode/DerivedData/YourAppName-xxxx and then restart your Xcode. That is no joke!

If you got an error like "duplicate symbol_OBJC_CLASS_$_Pod in:", you should go to TARGETS->Build Phases->Compile Sources and delete extra file.