Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this mean: Undefined symbols for architecture x86_64 "_main"

Tags:

xcode

macos

swift

I keep getting errors upon building my application on Xcode:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
    implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64

None of my code is erroring and the errors are weird errors and anything I do does not resolve it. I don't think the code is relevant to the issues because it isn't referenced in the error.

This is a screenshot of the error.enter image description here

like image 772
Adam S. Avatar asked Oct 18 '14 05:10

Adam S.


2 Answers

The linker has not been able to find any file in the linking process with the main swift entry point. This can be due to the file not existing at all in your project, or that it exists but has not been included in the compile or link build phases.

In Swift, the main swift entry point is defined in a main.swift module, or (for iOS) in the AppDelegate.swift file there needs to be a @UIApplicationMain declaration. I don't see a Compile main.swift in your log, perhaps its missing or not included in the build phases?

like image 178
Some Developer Avatar answered Oct 16 '22 15:10

Some Developer


Just in case, check if your AppDelegate app target is selected on the File Inspector.

( Select AppDeletage > Show the Utility > Show the file Inspector > under Target Membership, select your target.)

It happened to me after renaming an existing file.

like image 2
tsnkff Avatar answered Oct 16 '22 15:10

tsnkff