LinusG.
LinusG.

Reputation: 28892

Apple Mach-O Linker & Ditto Error - Xcode 8

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!

Upvotes: 18

Views: 57977

Answers (20)

Andy Rubin
Andy Rubin

Reputation: 25

Please make sure you have following changes in Workspace setting in your xcode:

Please go to your workspace setting and make the following changes:

Workspace Setting: Build System: Legacy Build System

Per -User Workspace DerivedData: Workspace relative location Build System Use User Setting

Hope it helps:

Upvotes: 0

JeremyF
JeremyF

Reputation: 745

For me it was a problem with react native haptic. I think it was because of a change in CocoaPods but also because of changing up file locations. I just removed it and re installed it. Hope this helps someone.

UPDATE

The build succeeded by when running it it would just crash. To solve this I used File > Add Files to Project for the GoogleService-Info.plist and it worked.

Upvotes: 0

Jignesh Rathod
Jignesh Rathod

Reputation: 1

Follow the below steps:

step1: Go to Build Phase Tab then only expand Link Binary with Library

step2: Then Go to General Tab then Expand Linked Framework & Library (because Yourprojectname.framework is disable)

Upvotes: -6

CaptainBluMagic
CaptainBluMagic

Reputation: 17

Also just check if you are importing a "*.m" implementation file in any of your classes, that can cause the same issue.

Removing the import statement can fix the issue

Upvotes: 0

vidalbenjoe
vidalbenjoe

Reputation: 975

If you're importing a framework through Build Phases, try to put it inside the folder of your project and add it into Link Binary with libraries. Actually, I've already experienced that problem before, I am very frustrated with that error until I knew that I have to put the .framework inside the folder of my project. Hope will help

Upvotes: 1

Lorenzo
Lorenzo

Reputation: 3387

I had the same problem when I changed Xcode from a previous version 7 to the new XCode 8. In the new Xcode (8.3.3 now) there are more settings in the compiler.

When you update the project settings into new Xcode (using Editor->Validate Settings), these new settings are applied and set to the default value YES. After this update I had the linker error!

In my project I compared the previous version of the file .pbxproj with the new one (after Settings validation) using Beyond compare (or similar).

In this way I can saw the new settings added in the new version of Xcode and I set the new Settings value to NO. After this update all was OK and the linker error disappear.

Upvotes: 1

CSawy
CSawy

Reputation: 924

I got the same problem because I had defined a class (using @interface), but did not provide an implementation (using @implementation) for it. It was a simple class so even an empty implementation resolved it.

Upvotes: 0

Rainer Niemann
Rainer Niemann

Reputation: 644

If the procedure of cleaning and the disabling of bitcode does not work, then it's possible that the reason for the errors simply is a more complex syntax error in your code.

Upvotes: 0

PiKa
PiKa

Reputation: 21

Turning Bitcode to "No" solved this issue. This is found in the Build Settings.

Upvotes: 1

Sandip Mahajan
Sandip Mahajan

Reputation: 11

Don't wory ,just go to your project targat and then build setting and search enable bitcode change it to YES to NO.

Upvotes: 1

Agu Dondo
Agu Dondo

Reputation: 13569

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

Upvotes: 27

Romain TAILLANDIER
Romain TAILLANDIER

Reputation: 1985

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

Upvotes: 11

RakeshDipuna
RakeshDipuna

Reputation: 1610

  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

Upvotes: 42

asimolmez
asimolmez

Reputation: 760

For my react native app, I deleted a folder of a test project inProject Navigator and Targets. It solved my problem.

Upvotes: 1

Ewerson
Ewerson

Reputation: 109

This is because at some point some project file was not compiled. In my case the AppDelegate.swift was not in the compiler. So I added it manually and it worked.

enter image description here

Upvotes: 4

Parth Changela
Parth Changela

Reputation: 955

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

Upvotes: 17

Darius Miliauskas
Darius Miliauskas

Reputation: 3504

The issue I found with XCode 8.2.1 (Version 8C1002) after I converted the project to Current Swift Syntax (Swift 3). I just needed to rebuild it after cleaning, and the errors disappeared.

Upvotes: 0

Carlos Linares
Carlos Linares

Reputation: 51

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

Upvotes: 5

Shijing Lv
Shijing Lv

Reputation: 6716

Clean XCode with following cmds and rebuild:

rm -rf ~/Library/Developer/Xcode/DerivedData/
killall Xcode 2> /dev/null
killall Instruments 2> /dev/null
killall 'iOS Simulator' 2> /dev/null
killall Simulator 2> /dev/null
killall 'Simulator (Watch)' 2> /dev/null
killall ibtoold 2> /dev/null
killall simctl 2> /dev/null
# There may be others
# Kill the service itself
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator

Upvotes: 1

Chris Mitchelmore
Chris Mitchelmore

Reputation: 6176

On top of cleaning derived data and the project and restarting xcode, I've found that re converting your project to current swift syntax and re installing pods if you have them also helps.

To re convert your project you will need to set swift_version build setting back to yes so that your target appears in the conversion list.

Upvotes: 0

Related Questions