简体   繁体   English

iOS 应用程序 xcode 构建错误

[英]iOS App xcode build errors

I am new to iOS development and struggling with few build errors.我是 iOS 开发的新手,并且很少遇到构建错误。 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.使用内置 Swift 的 Xcode 9.4。

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

Link is below as I was not allowed to include the screenshot in this post.链接在下面,因为我不允许在这篇文章中包含屏幕截图。

Xcode build errors Xcode 构建错误

It should be like this :应该是这样的:

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

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.问题是因为 Xcode 的版本。 UIApplicationLaunchOptionsKey has been renamed to UIApplication.LaunchOptionsKey in the newer version of Xcode (10.2). UIApplicationLaunchOptionsKey 已在较新版本的 Xcode (10.2) 中重命名为 UIApplication.LaunchOptionsKey。 I came across this when I tried to open my project in an older version of Xcode.当我尝试在旧版本的 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.这很糟糕,因为我现在无法在无法更新到最新版本的旧计算机上处​​理我的项目。

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.享受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM