【问题标题】:What does this mean: Undefined symbols for architecture x86_64 "_main"这是什么意思:架构x86_64“_main”的未定义符号
【发布时间】:2014-10-18 05:31:10
【问题描述】:

在 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

我的代码都没有错误,错误是奇怪的错误,我所做的任何事情都不能解决它。我认为代码与问题无关,因为它没有在错误中引用。

这是错误截图。

【问题讨论】:

    标签: xcode macos swift


    【解决方案1】:

    链接器无法在链接过程中找到任何带有主 swift 入口点的文件。这可能是由于该文件在您的项目中根本不存在,或者它存在但未包含在编译或链接构建阶段。

    在 Swift 中,主要的 swift 入口点定义在 main.swift 模块中,或者(对于 iOS)在 AppDelegate.swift 文件中需要有 @UIApplicationMain 声明。我在您的日志中没有看到 Compile main.swift,可能是它丢失或未包含在构建阶段?

    【讨论】:

    • @NSApplicationMain 添加回我的AppDeletage.swift 对我有用。
    【解决方案2】:

    以防万一,请检查您的 AppDelegate 应用程序目标是否在文件检查器中被选中。

    (选择AppDeletage > 显示Utility > 显示file Inspector > 在Target Membership 下,选择你的目标。)

    重命名现有文件后发生在我身上。

    【讨论】:

      【解决方案3】:

      有些时候从项目中删除 AppDelegate.swift 的引用,然后在项目中再次添加 AppDelegate.swift 会起作用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-21
        • 2012-01-16
        • 2023-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-07
        • 2012-07-20
        相关资源
        最近更新 更多