Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: Apple Mach-O Linker Error (file too small for architecture x86_64)

Tags:

xcode

ios

swift

I'm creating a weather app which gets information from a web site. Everything was fine the last time I was coding (last night), I was able to compile and run the simulator with no errors. Just today when I launch the same project, without changing anything, I got a "Apple Mach-O Linker Error". Could you all help with this please?

Here's the details of the error:

Ld /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator/Haze\ Meter.app/Haze\ Meter normal x86_64     cd "/Users/Allister/Documents/XCODE/Haze Meter"     export IPHONEOS_DEPLOYMENT_TARGET=8.3     export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk -L/Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator -F/Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator -filelist /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze\ Meter.build/Debug-iphonesimulator/Haze\ Meter.build/Objects-normal/x86_64/Haze\ Meter.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze\ Meter.build/Debug-iphonesimulator/Haze\ Meter.build/Objects-normal/x86_64/Haze_Meter.swiftmodule -mios-simulator-version-min=8.3 -Xlinker -dependency_info -Xlinker /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze\ Meter.build/Debug-iphonesimulator/Haze\ Meter.build/Objects-normal/x86_64/Haze\ Meter_dependency_info.dat -o /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator/Haze\ Meter.app/Haze\ Meter 

and at the bottom:

ld: file too small (length=0) file '/Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze Meter.build/Debug-iphonesimulator/Haze Meter.build/Objects-normal/x86_64/ViewController.o' for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

I've checked other "Apple Mach-O Linker Error" on StackOverflow but they seem to be having a different "ld" with mine, albeit the same "clang".

like image 554
Allister Bah Avatar asked May 28 '15 04:05

Allister Bah


1 Answers

Try a full rebuild / clean. It's possible that the a previous build has been abnormally aborted, leaving the ViewController.o file corrupted or zero-size.

To clean: In Xcode "Product" menu, select "Clean" (shortcut: Cmd+Shift+K)

To rebuild: In Xcode "Product" menu, select "Build" (shortcut: Cmd+B)

If it doesn't work: In Xcode "Product" menu, hold down Option key, and select "Clean Build Folder"

reference from HERE.

like image 175
Dharmesh Kheni Avatar answered Sep 21 '22 03:09

Dharmesh Kheni