25

Changed my deployment target to from 8.0 to 7.0.

Using Xcode 6 with latest iOS8 as base sdk. Getting this error when building for iOS7.1 device:

ld: can't link with a main executable file '/Users/Name/Library/Developer/Xcode/DerivedData/Clumsy_Bird-gotvuaeuyvrkzvfqpzsuxpmifimu/Build/Products/Debug-iphoneos/Clumsy Bird.app/Clumsy Bird' for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

enter image description here

How to solve this?

user1872384
  • 6,886
  • 11
  • 61
  • 103
  • 5
    I'm having the same issue when building on Xcode 6 for an iPad. I was able to workaround this by visiting the "Edit Scheme" panel for my target, selecting the "Build" category, and unchecking the "Run" checkbox for my unit test target. – Craig Otis Sep 29 '14 at 19:30
  • Thx Craig Otis... I'll try it next time... Manage to fix it by deleting the "test" target... – user1872384 Sep 30 '14 at 02:48

4 Answers4

78
  1. Click your project in Navigator.
  2. Select your test target. Switch to general tab if not there.
  3. Select your application name from Host Application dropdown.

enter image description here

Evgenii
  • 36,389
  • 27
  • 134
  • 170
  • What was the need for Apple to do like this? I am completely frustrated with the XCode settings change. I have resolved the problem after i googled it and got the above solution. – Biranchi Dec 15 '14 at 03:39
  • 1
    In my case, this happened when I renamed the product; this solved it immediately :) – Ja͢ck Jan 13 '15 at 04:29
  • Hi Evgenii and all, I have a binary file that I generated by compiling C++ console program. When I am running it using terminal, it runs fine. When I am running it using NSTask in Xcode, I am getting error ld: can't link with a main executable file. Code: NSTask *terminalOperation = [[NSTask alloc] init]; terminalOperation.launchPath = @"/usr/bin/g++"; NSArray *argumentsArray = [NSArray arrayWithObjects:filePath, nil]; [terminalOperation setArguments:argumentsArray]; [terminalOperation launch]; [terminalOperation waitUntilExit]; Can you please help – JMD Aug 19 '15 at 01:54
  • This is still, believe it or not, a problem in Xcode 7. Apple: I'm not upset, just disappointed. – HughHughTeotl Sep 28 '15 at 15:34
27

I had a mismatch in values between on "Build Active Architecture Only" which was "Yes" for my test app, but "No" for my unit test target. Make sure these values are identical.

Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
25

Build settings > IOS deployment target Make sure these values are identical in app and test app targets. Works for me. screen here

Ann
  • 772
  • 1
  • 9
  • 17
10

I followed steps provided by "Evgeny" above, but my project build only when I unchecked "Allow testing Host Application APIs". Thanks "Evgeny"!

Mak
  • 131
  • 1
  • 4