iOS Xcode 12.0 Swift 5'AppDelegate'带有@main注释,并且必须提供类型为()->的主要静态函数.无效或()引发->空白 [英] iOS Xcode 12.0 Swift 5 'AppDelegate' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void
问题描述
在使用Swift 5和Catalina 10.15.5的Xcode 12.0中:当我将Mac标记为可部署目标(Apple Project Catalyst)并单击运行"时,它给我一个错误,显示:
In my Xcode 12.0 using Swift 5 and Catalina 10.15.5: When I tick Mac as deployable target (Apple Project Catalyst), and click Runs, it gives me an error showing:
'AppDelegate' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void.
在Internet上找不到任何内容...我已经检查了我的代码,没有任何问题,它可以在iOS设备和模拟器上运行.调试日志为空(duhh ...)
Can't find anything on Internet... I have checked my codes and nothing's wrong and it can be run on iOS devices and simulators. Debug log is empty (duhh...)
有人遇到这个问题吗?
推荐答案
将 @main
更改为 @UIApplicationMain
,并忽略所有由此产生的警告.
Change @main
to @UIApplicationMain
and ignore any resulting warnings.
来源: https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes
启用Mac Catalyst后,可能无法再使用Swift语言新建的iOS项目.(67885114)
A newly-created iOS project using the Swift language may no longer build after enabling Mac Catalyst. (67885114)
解决方法:将应用程序委托上的 @main
注释替换为 @UIApplicationMain
.
Workaround: Replace the @main
annotation on the App Delegate with @UIApplicationMain
.
这篇关于iOS Xcode 12.0 Swift 5'AppDelegate'带有@main注释,并且必须提供类型为()->的主要静态函数.无效或()引发->空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!