iOS 应用程序 xcode 构建错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50794391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:40:57  来源:igfitidea点击:

iOS App xcode build errors

iosxcodebuild

提问by Omanex Jeep Adventures

I am new to iOS development and struggling with few build errors. I looked up the web on how to fix these errors but could not get a hint. Using Xcode 9.4 with built in Swift.

我是 iOS 开发的新手,并且很少遇到构建错误。我在网上查找了有关如何修复这些错误的信息,但没有得到提示。使用内置 Swift 的 Xcode 9.4。

  1. 'LaunchOptionsKey' is not a member type of 'UIApplication'
  2. Instance member 'state' cannot be used on type 'UIControl'
  3. Instance member 'state' cannot be used on type 'UIControl'
  4. Type 'UIControl' has no member 'State'
  1. “LaunchOptionsKey”不是“UIApplication”的成员类型
  2. 实例成员 'state' 不能用于类型 'UIControl'
  3. 实例成员 'state' 不能用于类型 'UIControl'
  4. 类型“UIControl”没有成员“State”

Link is below as I was not allowed to include the screenshot in this post.

链接在下面,因为我不允许在这篇文章中包含屏幕截图。

Xcode build errors

Xcode 构建错误

回答by U. Benlice

It should be like this :

应该是这样的:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    return true
}

回答by swati patel

Neither the original question nor the accepted answer note that the code with the error is generated code when a project is created and as such generally shouldn't need to be changed.

原始问题和接受的答案都没有指出,在创建项目时生成的错误代码是生成的代码,因此通常不需要更改。

The problem is because of the version of Xcode. UIApplicationLaunchOptionsKey has been renamed to UIApplication.LaunchOptionsKey in the newer version of Xcode (10.2). I came across this when I tried to open my project in an older version of Xcode. This sucks because I now can't work on my project on my older computer that can't be updated to the latest version.

问题是因为 Xcode 的版本。在较新版本的 Xcode (10.2) 中,UIApplicationLaunchOptionsKey 已重命名为 UIApplication.LaunchOptionsKey。当我尝试在旧版本的 Xcode 中打开我的项目时,我遇到了这个问题。这很糟糕,因为我现在无法在无法更新到最新版本的旧计算机上处​​理我的项目。

回答by Val

I am running Xcode 9.3 and Android Studio 3.5.1.

我正在运行 Xcode 9.3 和 Android Studio 3.5.1。

All I did was remove the "." on the definition:

我所做的只是删除“。” 关于定义:

UIApplication.LaunchOptionsKey: Any

UIApplication.LaunchOptionsKey:任何

To:

到:

UIApplicationLaunchOptionsKey: Any

UIApplicationLaunchOptionsKey:任何

without the period. Works like a charm! Enjoy.

没有期间。奇迹般有效!享受。