迁移到Xcode 7 / Swift 2.0会导致应用程序卡在启动屏幕上

时间:2015-10-07 14:37:02

标签: ios xcode swift swift2 xcode7

最近我转移到Xcode 7和Swift 2.0,因为我的应用程序无法在iOS 9(任何设备)上编译,但是在iOS 8.x.x上它按预期运行。

我查看了Xcode并试图找到一些原因,但我发现只有当它卡在启动屏幕上时,在Xcode调试器中按下暂停会告诉我代码在objc_msgSend上。 CPU使用率也达到100%(在8.x.x上仅使用~10-20%)。

CPU usage

Thread where app gets stuck on

objc_msgSend code

没有别的与众不同。在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'但是从我用Google搜索的内容来看,这不是我遇到的最大问题。我不知道该怎么做了。

如果您需要我的部分代码或其他任何只是让我知道,我会发布它:)

谢谢!

修改:将故事板更改为从常规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
}

1 个答案:

答案 0 :(得分:3)

检查故事板。 看起来您的屏幕包含TextField,其中包含默认文本。 只需清除此TextField中的文本,然后重试。