简体   繁体   中英

Xcode 6.0.1 - Either gets stuck on the Launch Screen xib or just shows a black screen. Error came out of nowhere

I have an iOS app that I'm building in Xcode 6.0.1 on Yosemite 10.10 . I've been working on this for a couple weeks now and all of the sudden today everything has gone wrong.

When I first started the project, I just deleted the Launch Screen xib that's auto generated by Xcode, and then I set my initial view controller in Storyboard and its been working fine.

For some reason today, everything changed. Now, if I try to run the app on my iPhone 4s or any of the simulators, it just shows a black screen.

So I figured maybe I could fix it by adding a launch screen. I created a xib file called Launch Screen, and set it as the "Launch Screen File" in the target's general settings.

Now when I run the app, it shows the Launch Screen, but it gets stuck there and never moves to the initial view controller. Then it just times out and Xcode gives me the following prompt:

 Lost connection to [insert device name here] 

I had this happen due to bad code in the viewDidLoad of my initial view controller that neither the compiler nor the static analyzer caught. I am using Swift. This code was the culprit:

var image = UIImage(named: "LoginUsernameIcon")
var iconImageView = UIImageView(frame: CGRectMake(
    0.0, 0.0, 26.0, 26.0
))
iconImageView.image = image
usernameField.leftView = iconImageView

image = UIImage(named: "LoginPasswordIcon")
iconImageView.image = image
passwordField.leftView = iconImageView

Reinitializing iconImageView allowed my app to launch again:

var image = UIImage(named: "LoginUsernameIcon")
var iconImageView = UIImageView(frame: CGRectMake(
    0.0, 0.0, 26.0, 26.0
))
iconImageView.image = image
usernameField.leftView = iconImageView

image = UIImage(named: "LoginPasswordIcon")
iconImageView = UIImageView(frame: CGRectMake(   // <<<<<
    0.0, 0.0, 26.0, 26.0                         // <<<<<
))                                               // <<<<<
iconImageView.image = image
passwordField.leftView = iconImageView

So FWIW, I would double check your code to see if you have anything that looks off-kilter. I am not sure why an error is not produced by Xcode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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