Apple Mach-O Linker & Ditto Error - Xcode 8

57,654

Solution 1

  1. Quit Xcode
  2. Restart the System
  3. Select Xcode -> Preferences.
    This will open a pop-up window. Select 'Locations'. In Locations, you will see 'Derived Data'. Click on the arrow icon right next to the path.
    This will open a folder containing 'Derived Data', delete it.
  4. Clean the Product and Run

Solution 2

Make sure you open the project from the .xcworkspace file instead of the .xcodeproj

Solution 3

step 1 = clicking on the project in the navigation menu

step 2 = select the project

step 3 = build settings

step 4 = search enable bitcode if bitcode is yes than change to No

Solution 4

None of the previous answer have solve my problem. I think it come from changes in the cocoapods podFile, from using frameworks to not using them

Frameworks was still remind in Target>General Properties>Linked Frameworks. I removed them I also remove the -framework and corresponding frameworks from other linker flags (saving inherited and objC flags)

Hope that could help

Solution 5

This happened to me after I delete my app while it was running.

I solved it cleaning the project.

Product > Clean or Shift + Command + K

Share:
57,654

Related videos on Youtube

LinusGeffarth
Author by

LinusGeffarth

I'm co-founder & CTO at Funeral Marketplace, a B2B2C online marketplace connecting every player in the funeral industry. I'm also head of software development at CONVELA and have my own little development studio for side projects: ögli{codes}. I've started out as project manager building a little app with my uncle; then began developing for iOS my own (for iPad using Obj-C at the time); made some iPhone and iPad apps (Swift). Eventually we founded the Funeral Marketplace, for which I led the iOS development (Swift) and managed the web (react.js) & backend (php, laravel) development. I then began developing for the frontend and backend as well, while also building my knowledge in server-side swift using the Vapor framework making me full-stack. #SOreadytohelp Stack Overflow to me, means endless possibilities. I feel like I can do anything using all the never-ending source of knowledge people share on SO. I am #SOreadytohelp because I want to give back exactly what I got and much more. I want to share my knowledge as much as possible to help people around the world progress and create beautiful things. I want to thank Stack Overflow for teaching me to code & helping me out every day. ♡

Updated on July 09, 2022

Comments

  • LinusGeffarth
    LinusGeffarth almost 2 years

    I have just updated my Xcode to Xcode 8 and am now trying to convert my project's code to Swift 2.3. I was able to build a couple times using Xcode 8 without any errors. Now, the following errors came up:

    Error #1: Apple Mach-O Linker Error: Linker command failed with exit code 1

    ld: file not found: /Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbegcsbcipdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/DownloadsViewController.o
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I don't even know what a .o file is. The swift file of DownloadsViewController is there, though.

    Error #2: Ditto Error: Command /usr/cin/ditto failed with exit code 1

    ditto: can't get real path for source '/Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbbciegrfdpdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp-Swift.h'
    Command /usr/bin/ditto failed with exit code 1

    The ditto error occurs 3 times: for MyApp.swiftdoc, MyApp.swiftmodule, and MyApp-Swift.h.

    Thanks in advance!

    • Bhavin Bhadani
      Bhavin Bhadani almost 8 years
      in project navigator , search for DownloadsViewController file .. I think there is duplicate file with same name .. check it once
    • LinusGeffarth
      LinusGeffarth almost 8 years
      Nope, no duplicate file.
  • LinusGeffarth
    LinusGeffarth almost 8 years
    "Have you tried turning it off and on again?" - Thanks for the effort, didn't help though.
  • RakeshDipuna
    RakeshDipuna almost 8 years
    Have you tried those procedures what I have mentioned above ?
  • RakeshDipuna
    RakeshDipuna almost 8 years
    If you have the project back up ,then delete DownloadsViewController file and then do copy from the back up to your target
  • RakeshDipuna
    RakeshDipuna almost 8 years
    Have you copied ?
  • LinusGeffarth
    LinusGeffarth almost 8 years
    No I mean I have followed your steps. What do you mean by "copy from the back up"?
  • RakeshDipuna
    RakeshDipuna almost 8 years
    Oky let me explain ! your project might not get your DownloadsViewController file path during linking time after upgrading to Xcode8 .So better delete the that file and add it again from your back up .
  • LinusGeffarth
    LinusGeffarth almost 8 years
    Ok but wouldn't that mean I couldn't even open the file in Xcode?
  • RakeshDipuna
    RakeshDipuna almost 8 years
    stackoverflow.com/questions/15189913/…. Delete your file and and add how it is being added using this link .clean the project and run .Oh ..your xcode fixes the error itself .sorry then
  • EFE
    EFE about 7 years
    i just select product->clean and run error gone xcode 8 macos 10.11
  • Miroslav Hrivik
    Miroslav Hrivik about 7 years
    While ago I had changed name of my app target to new app name. I had to change it also in pod file. But the old pods framework was still listed in linked frameworks and libraries. After I removed it, build started to work.
  • TheBrockEllis
    TheBrockEllis about 7 years
    I had added a Cordova plugin that required me to install CocoPods. It looks like if you open the .xcodeproj file it doesn't pull in those dependencies. If you open up the .xcworkspace file, it does and is able to build successfully. Thanks for the tip @Agu Dondo!
  • Sooraj
    Sooraj about 7 years
    Where is this located?
  • Graeme Rock
    Graeme Rock about 7 years
    How do I create a .xcworkspace from a .xcodeproj then?
  • asimolmez
    asimolmez about 7 years
    @SoorajChandran You can see in Project Navigator.
  • Romain TAILLANDIER
    Romain TAILLANDIER almost 7 years
    @Graeme Rock. In this particular case, you have to make a 'pod install'. please refer to CocoaPods community. it is a dependency manager from the community, that should have been part of Xcode ...
  • regina_fallangi
    regina_fallangi almost 7 years
    this did it for me
  • Babken Vardanyan
    Babken Vardanyan about 6 years
    This was the answer for me. I added the file using AppCode.