移动到 Xcode 7/Swift 2.0 会导致应用卡在启动屏幕上
Moving to Xcode 7/Swift 2.0 causes app to get stuck on launch screen
最近我转移到 Xcode 7 和 Swift 2.0,因为我的应用程序无法在 iOS 9(任何设备)上编译,但是在 iOS 8.x.x 它 运行 符合预期。
我环顾四周 Xcode 并试图找到一些原因,但我所能找到的只是当它卡在启动屏幕上时,在 Xcode 调试器中按暂停告诉我代码在 objc_msgSend
。 CPU 使用率也达到 100%(在 8.x.x 上使用率仅为 ~10-20%)。
没有其他异常。在 Xcode 6.4 上一切正常。我将所有代码迁移到 swift 2.0 - 我没有任何编译错误 - 除了 ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
但从我用谷歌搜索的结果来看,这不是我最大的问题。我不知道该怎么办了。
如果您需要我的部分代码或其他任何内容,请告诉我,我会post :)
谢谢!
编辑:将故事板更改为从常规 ViewController
和标签开始,并且运行良好。好像跟我用UISplitViewController
有关系。这是来自 AppDelegate.swift:
的一些代码
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//get split VC
let splitViewController = self.window!.rootViewController as! UISplitViewController
splitViewController.delegate = self
//Configure the master part
let masterNavigationController = splitViewController.viewControllers[0] as! UINavigationController
masterNavigationController.navigationBar.tintColor = UIColor(red: 236/255, green: 240/255, blue: 241/255, alpha: 1)
masterNavigationController.navigationBar.barTintColor = UIColor(red: 40/255, green: 162/255, blue: 47/255, alpha: 1)
let controller = masterNavigationController.topViewController as! NoteListViewController
controller.context = self.managedObjectContext!
//configure the detail
let detailNavController = splitViewController.viewControllers.last as! UINavigationController
let detailViewController = detailNavController.topViewController as! NoteDetailViewController
detailViewController.navigationItem.leftItemsSupplementBackButton = true
detailViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
detailNavController.navigationBar.barTintColor = UIColor(red: 40/255, green: 162/255, blue: 47/255, alpha: 1)
//configure the data for detail
controller.delegate = detailViewController
let firstNote = fetchFirstResult(inContext: controller.context)
if firstNote != nil{
detailViewController.note = firstNote
detailViewController.context = self.managedObjectContext!
controller.tableIsEmpty = false
controller.appHasLoadedOnce = false
}
return true
}
检查你的故事板。
似乎您的屏幕包含带有默认文本的 TextField。
只需清除此 TextField 中的文本,然后重试。
最近我转移到 Xcode 7 和 Swift 2.0,因为我的应用程序无法在 iOS 9(任何设备)上编译,但是在 iOS 8.x.x 它 运行 符合预期。
我环顾四周 Xcode 并试图找到一些原因,但我所能找到的只是当它卡在启动屏幕上时,在 Xcode 调试器中按暂停告诉我代码在 objc_msgSend
。 CPU 使用率也达到 100%(在 8.x.x 上使用率仅为 ~10-20%)。
没有其他异常。在 Xcode 6.4 上一切正常。我将所有代码迁移到 swift 2.0 - 我没有任何编译错误 - 除了 ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
但从我用谷歌搜索的结果来看,这不是我最大的问题。我不知道该怎么办了。
如果您需要我的部分代码或其他任何内容,请告诉我,我会post :)
谢谢!
编辑:将故事板更改为从常规 ViewController
和标签开始,并且运行良好。好像跟我用UISplitViewController
有关系。这是来自 AppDelegate.swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//get split VC
let splitViewController = self.window!.rootViewController as! UISplitViewController
splitViewController.delegate = self
//Configure the master part
let masterNavigationController = splitViewController.viewControllers[0] as! UINavigationController
masterNavigationController.navigationBar.tintColor = UIColor(red: 236/255, green: 240/255, blue: 241/255, alpha: 1)
masterNavigationController.navigationBar.barTintColor = UIColor(red: 40/255, green: 162/255, blue: 47/255, alpha: 1)
let controller = masterNavigationController.topViewController as! NoteListViewController
controller.context = self.managedObjectContext!
//configure the detail
let detailNavController = splitViewController.viewControllers.last as! UINavigationController
let detailViewController = detailNavController.topViewController as! NoteDetailViewController
detailViewController.navigationItem.leftItemsSupplementBackButton = true
detailViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
detailNavController.navigationBar.barTintColor = UIColor(red: 40/255, green: 162/255, blue: 47/255, alpha: 1)
//configure the data for detail
controller.delegate = detailViewController
let firstNote = fetchFirstResult(inContext: controller.context)
if firstNote != nil{
detailViewController.note = firstNote
detailViewController.context = self.managedObjectContext!
controller.tableIsEmpty = false
controller.appHasLoadedOnce = false
}
return true
}
检查你的故事板。 似乎您的屏幕包含带有默认文本的 TextField。 只需清除此 TextField 中的文本,然后重试。