【发布时间】:2015-10-07 14:37:02
【问题描述】:
最近我迁移到 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' 但从我搜索的内容来看,这不是我最大的问题。我不知道该怎么办了。
如果您需要我的部分代码或其他任何内容,请告诉我,我会发布它:)
谢谢!
编辑:将故事板更改为以常规 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
}
【问题讨论】:
-
转到 > 调试 > 创建断点并选择异常断点,运行应用程序并让我知道你得到了什么,你是对的,警告你得到的不应该给予补偿。
-
还是一样的。应用程序卡在启动屏幕上,没有断点停止应用程序,但感谢我从来不知道该选项存在!暂停它显示相同的
objc_msgSend -
尝试清理您的项目,这是您在转换为 swift 2.0 后第一次运行该项目,很高兴吗?
-
清理了几次。也尝试更改代码 - 它运行
application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)我已经测试过,但是一旦运行,什么也没有发生。当我迁移到 Xcode 7 和 Swift 2.0 后,我无法运行我的应用程序。 -
应该有,
didFinishLaunchingWithOptions里面有代码吗?
标签: ios xcode swift swift2 xcode7