ld: entry point (_main) undefined. for architecture x86_64 : Xcode 9
最近我下载了Xcode 9,并创建了一个示例iPhone应用程序,但该应用程序无法构建,因为它显示以下错误:
ld: entry point (_main) undefined. for architecture x86_64
我在网上进行了大致相同的搜索,并尝试了几种方法,例如删除派生数据,重新启动Xcode,但仍然无法解决问题。
有人遇到过类似的问题吗?
发现" AppDelegate"不属于"目标"成员。
添加@UIApplicationMain解决了该问题。
1 2 3 4 | @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { ... } |
我也遇到过同样的问题。这是我如何解决它:
选择您的项目,然后转到Build Setting-> Search Mach-O Type更改为-> Bundle
。希望对您有帮助!
就我而言,我错过了
请打开您的
下的此类中添加此行代码。
像这样:
@UIApplicationMain
类AppDelegate:UIResponder,UIApplicationDelegate {
...
}
添加
1 2 3 4 | import UIKit UIApplicationMain(CommandLine.argc, UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc)), nil, NSStringFromClass(AppDelegate.self)) |
确保" AppDelegate"是"目标"成员身份的一部分。
单击AppDelegate->属性检查器->检查目标成员资格
1 2 3 4 | @main class AppDelegate: UIResponder, UIApplicationDelegate { ... } |
雨燕5
确保在appDelegate类的开头有@main。
对于框架(动态库)
如果在构建框架时遇到此错误,请在"构建设置">" Mach-O类型"下选择"动态库"。
在Xcode版本11.6(11E708)上测试
最佳
只需在appDelegate
中添加此代码
1 | var window: UIWindow? |