为什么我的应用程序在模拟器中运行,但试图在我的iPhone上启动时崩溃?
问题描述:
我正在使用Xcode 8.3.2编写Swift 3中的应用程序。我的应用程序运行在模拟器罚款,但是当我尝试在我的iPhone(iOS版10.3.1)运行它,我得到一个丑陋的错误消息:为什么我的应用程序在模拟器中运行,但试图在我的iPhone上启动时崩溃?
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线程和我已经尝试了所有的补救措施建议:
- 清洗该项目拔掉iPhone,在
- 重新启动所有设备插回
- 改变了球队为None,还给我
- 关闭自动管理签约,并把它重新
- 下载我目前的证书
- 转向一些标志由无到是在构建设置
- 等
我不知道从哪里何去何从已经用尽了所有的我已经能够找到的建议。
任何建议,非常感谢。
答
嗯,我想有一件事我没有尝试 - 先从手机上卸载应用程序,然后在手机上构建并运行它。
所以我不知道根本原因是什么,但至少可以解决问题。
不幸的是,它发生。 Upvoted。下次你可能会记得尝试一下! – Mozahler