gpt4 book ai didi

ios - ( swift )错误 : UIApplicationMain attribute cannot be used in a module

转载 作者:行者123 更新时间:2023-11-29 02:43:09 29 4
gpt4 key购买 nike

因此,作为我努力学习 Swift 的一部分,我接触到了 Apple 提供的开源“Adventure”项目(发现 HERE)。

尴尬的是,我没有走得太远就遇到了我的第一个困境。当我尝试编译项目时,出现以下错误:

'UIApplicationMain' attribute cannot be used in a module that contains top-level code'

具体来说,错误出现在AppDelegate.swift文件中,属性紧跟在import UIKit声明之后,如下所示:

import UIKit

@UIApplicationMain
class AppDelegate: NSObject, UIApplicationDelegate {
var window: UIWindow?
....
// a number of functions that I won't list here...
....
}

我对此进行了一些研究,但可以理解(?)似乎没有太多关于此问题的信息。我想知道是否有人遇到过同样的问题。

(顺便说一句,我使用的是Xcode6-beta5)

编辑 1 --------------

现在全新安装 Beta6,编译后出现以下错误:

Undefined symbols for architecture x86_64: "TFSs15_arrayForceCastU___FGSaQ__GSaQ0", referenced from: __TFC9Adventure13HeroCharacter20animationDidCompletefS0_FOS_14AnimationStateT_ in HeroCharacter.o __TFC9Adventure13HeroCharacter14fireProjectilefS0_FT_T_ in HeroCharacter.o __TFC9Adventure4Cave15applyCaveDamagefS0_FTSd10projectileCSo6SKNode_T_ in Cave.o __TFC9Adventure4Cave12performDeathfS0_FT_T_ in Cave.o __TFFC9Adventure4Cave16loadSharedAssetsFMS0_FT_T_U_FT_T_ in Cave.o __TFC9Adventure6Goblin20animationDidCompletefS0_FOS_14AnimationStateT_ in Goblin.o __TFFC9Adventure6Goblin16loadSharedAssetsFMS0_FT_T_U_FT_T_ in Goblin.o ... "__TFSsoi1aUSs17_RawOptionSetType_USs21BitwiseOperationsTypeSs9Equatable__FTQ_Q__Q_", referenced from: __TFC9Adventure21LayeredCharacterScene14handleKeyEventfS0_FTCSo7NSEvent7keyDownSb_T_ in LayeredCharacterSceneOSXEvents.o "__TFVSC6CGSizeCfMS_FT5widthSd6heightSd_S_", referenced from: __TFFC9Adventure6Archer16loadSharedAssetsFMS0_FT_T_U_FT_T_ in Archer.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1

我什至不打算尝试猜测这些错误的含义。

最佳答案

显然 Adventure 项目无法在 Xcode6-Beta5 中正确编译。然而,Xcode6-Beta6 编译和运行它都很好。

关于升级到Beta6后遇到的错误,修复方法是删除项目的派生数据。为此,打开管理器(“窗口”菜单 -> “管理器”),选择窗口左侧的“冒险”项目,然后单击与项目派生数据关联的“删除”按钮(应该是最右边最上面的那个)。

关于ios - ( swift )错误 : UIApplicationMain attribute cannot be used in a module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25495740/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com