Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS App xcode build errors

Tags:

xcode

ios

build

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.

  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'

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

Xcode build errors

like image 294
Omanex Jeep Adventures Avatar asked Jun 11 '18 09:06

Omanex Jeep Adventures


People also ask

Why is my build failing in Xcode?

Build operation failed without specifying any errors. Individual build tasks may have failed for unknown reasons. One possible cause is if there are too many (possibly zombie) processes; in this case, rebooting may fix the problem.

How do I see errors in Xcode?

cmd+7. click on the top-most "Build $APP" section. locate the warning or error. click the buttons on the right to see the full details of the step you are interested in.

How do I do a clean build in Xcode?

To clean the build folder you can use the shortcut Command+Option+Shift+K or Menu Bar → Product → Hold Option Key → Clean build Folder .


2 Answers

It should be like this :

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    return true
}
like image 117
U. Benlice Avatar answered Oct 11 '22 14:10

U. Benlice


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.

like image 34
sp_nz Avatar answered Oct 11 '22 12:10

sp_nz