繁体   English   中英

为什么我的应用程序可以在模拟器中运行,但是尝试在iPhone上启动时却崩溃了?

[英]Why does my app run in the simulator but crash trying to launch on my iPhone?

我正在使用Xcode 8.3.2在Swift 3中编写一个应用程序。 我的应用在模拟器中运行良好,但是当我尝试在iPhone(iOS 10.3.1)上运行该应用时,出现了一条难看的错误消息:

   libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
    0x1005203d0 <+0>:   stp    x26, x25, [sp, #-0x50]!
    0x1005203d4 <+4>:   stp    x24, x23, [sp, #0x10]
    0x1005203d8 <+8>:   stp    x22, x21, [sp, #0x20]
    0x1005203dc <+12>:  stp    x20, x19, [sp, #0x30]
    0x1005203e0 <+16>:  stp    x29, x30, [sp, #0x40]
    0x1005203e4 <+20>:  add    x29, sp, #0x40            ; =0x40 
    0x1005203e8 <+24>:  mov    x19, x6
    0x1005203ec <+28>:  mov    x20, x5
    0x1005203f0 <+32>:  mov    x21, x4
    0x1005203f4 <+36>:  mov    x22, x3
    0x1005203f8 <+40>:  mov    x23, x2
    0x1005203fc <+44>:  mov    x24, x1
    0x100520400 <+48>:  mov    x25, x0
    0x100520404 <+52>:  adr    x8, #0xf11fc              ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
    0x100520408 <+56>:  nop    
    0x10052040c <+60>:  add    x0, x8, #0x10             ; =0x10 
    0x100520410 <+64>:  mov    w1, #0x28
    0x100520414 <+68>:  orr    w2, wzr, #0x7
    0x100520418 <+72>:  bl     0x100520750               ; swift_rt_swift_allocObject
    0x10052041c <+76>:  mov    x8, x0
    0x100520420 <+80>:  stp    x22, x21, [x8, #0x10]
    0x100520424 <+84>:  strb   w20, [x8, #0x20]
    0x100520428 <+88>:  str    w19, [x8, #0x24]
    0x10052042c <+92>:  adr    x3, #0x40440              ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
    0x100520430 <+96>:  nop    
    0x100520434 <+100>: mov    x0, x25
    0x100520438 <+104>: mov    x1, x24
    0x10052043c <+108>: mov    x2, x23
    0x100520440 <+112>: mov    x4, x8
    0x100520444 <+116>: bl     0x1004014dc               ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
->  0x100520448 <+120>: brk    #0x1

我设置了一个异常断点,导致我看到以下代码:

    if let defaultFormula = dataManager.fetchDefaultFormula(moc) {
        self.formula = defaultFormula.first! <<< Unexpectedly found nil...
    }

这是它正在调用的函数:

  func fetchDefaultFormula(_ moc: NSManagedObjectContext) -> [Formula]? {
        let defaultFormulaID = UserDefaults.formula()
        let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Formula")
        let filterPredicate = NSPredicate(format: "uuid = [c] %@", defaultFormulaID)
        fetchRequest.predicate = filterPredicate

        do {
            return try moc.fetch(fetchRequest) as? [Formula]
        } catch {
            fatalError("There was an error fetching the lifts")
        }
        return nil
    }

提取请求返回0值,因此很清楚为什么在强制打开包装时会得到异常。 但是,对象属性“公式”必须具有一个值。 应用程序要做的第一件事是检查持久性存储中是否存在默认数据(如可用的公式),如果不存在,则将其添加。 我已经重置了模拟器,并忠实地添加了它们,但是看来这在iPhone上没有发生。 如果可以在iPhone上运行时确定是否将记录添加到商店中,请给我启发。

我发现了一些SO线程,其他线程在其中遇到了这种神秘的错误(一个大而丑陋的错误,而不是意外的nil),并且我尝试了所有建议的补救措施:

  • 清理项目,拔掉iPhone,然后重新插入
  • 重新启动所有设备
  • 将团队更改为“无”并回到我身边
  • 关闭自动管理签名并重新打开
  • 下载了我当前的证书
  • 在构建设置中将一些标志从否更改为是
  • 等等

我已经筋疲力尽了,我不知道从这里到哪里都可以找到。

任何建议,不胜感激。

好吧,我想我没有尝试过的一件事-首先从手机上卸载应用程序,然后在手机上构建并运行它。

所以我真的不知道根本原因是什么,但是至少这可以解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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