【问题标题】:Moving to Xcode 7/Swift 2.0 causes app to get stuck on launch screen迁移到 Xcode 7/Swift 2.0 会导致应用卡在启动屏幕上
【发布时间】: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


【解决方案1】:

检查你的故事板。 似乎您的屏幕包含 TextField(s),其中包含默认文本。 只需清除此 TextField 中的文本,然后重试。

【讨论】:

  • 我不知道你是怎么注意到的...但是我删除了detailViewController 中的UITextView 中的单词,它现在可以工作了吗?我很迷茫,却又欣喜若狂。非常感谢
  • 我已经为此绞尽脑汁好几个小时了,终于因为这个而工作了。知道为什么它不适用于默认文本吗?
猜你喜欢
  • 1970-01-01
  • 2019-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-19
  • 1970-01-01
相关资源
最近更新 更多