DYLD,没有名称为 (@rpath/libswiftCore.dylib) 的缓存图像

DYLD, no cache image with name (@rpath/libswiftCore.dylib)

我在 tvOS 12.2 上遇到崩溃,详细信息如下:

Incident Identifier: 57DC9DA3-536C-438E-91A0-2A3BF5290302
CrashReporter Key:   336395bb8937c2da230441e7d0f77cf6ce5d29e2
Hardware Model:      AppleTV5,3
Process:             yospace-tvos-test [535]
Path:                /private/var/containers/Bundle/Application/8D86BE15-0069-48A0-A6CC-AF32ABCB718B/yospace-tvos-test.app/yospace-tvos-test
Identifier:          com.x..yospace-tvos-test
Version:             1 (1.0)
AppStoreTools:       11C504
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.x..yospace-tvos-test [856]


Date/Time:           2020-02-06 09:25:36.5008 +0000
Launch Time:         2020-02-06 09:25:36.2246 +0000
OS Version:          Apple TVOS 12.2 (16L5201d)
Baseband Version:    n/a
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, no cache image with name (@rpath/libswiftCore.dylib)
Triggered by Thread:  0

Thread 0 Crashed:
0   dyld                            0x00000001009b63b8 __abort_with_payload + 8
1   dyld                            0x00000001009b59f8 abort_with_payload_wrapper_internal + 100
2   dyld                            0x00000001009b5a28 fcntl + 0
3   dyld                            0x00000001009788fc dyld::fastBindLazySymbol+ 18684 (ImageLoader**, unsigned long) + 0
4   dyld                            0x000000010097b6e8 dyld::_main+ 30440 (macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 5396
5   dyld                            0x0000000100975044 _dyld_start + 68

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000006   x1: 0x0000000000000009   x2: 0x000000016f56a980   x3: 0x0000000000000014
    x4: 0x000000016f56a580   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000420
    x8: 0x0000000000000020   x9: 0x0000000000000009  x10: 0x0000000000000001  x11: 0x0000000100a34000
   x12: 0x0000000100a34000  x13: 0x0000000000000007  x14: 0x6172462f7070612e  x15: 0x00736b726f77656d
   x16: 0x0000000000000209  x17: 0x0000000000000010  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016f56a580  x21: 0x0000000000000014  x22: 0x000000016f56a980  x23: 0x0000000000000009
   x24: 0x0000000000000006  x25: 0x000000000000002f  x26: 0x00000001009cf5e0  x27: 0x00000001009cf000
   x28: 0x00000001009cfa00   fp: 0x000000016f56a550   lr: 0x00000001009b59f8
    sp: 0x000000016f56a510   pc: 0x00000001009b63b8 cpsr: 0x40000000

EOF

如果我通过 运行 应用程序 Xcode 没问题,但是当我将其导出为 IPA 并将其安装到 Apple TV 上时,它会在启动时立即崩溃。它在 tvOS 13 和 iOS 11-13 上的 IPA 中运行良好。我猜这与 tvOS 13 中的 Swift ABI 稳定性有关,因此它不需要 13 的 Swift 库,但需要 12,即使我说过它应该始终嵌入它正在努力寻找它们的 swift 标准库,或者根据崩溃日志末尾列出的二进制映像中缺少 Swift 库(由于以下原因未包含在上面)而确实包含它们体长限制)。

Apple TV 的控制台报告如下:

Attempt to add an app with insufficient id, info { BKSApplicationStateAppIsFrontmost = 1; BKSApplicationStateExtensionKey = 0; SBApplicationStateDisplayIDKey = "com.x..yospace-tvos-test"; SBApplicationStateKey = 8; SBApplicationStateProcessIDKey = 535; SBMostElevatedStateForProcessID = 8; }

应用程序是用 ObjC 编写的并且使用 Swift 框架可能(也可能不相关)。

我看过很多关于 libswiftCore 未加载的帖子,但这种情况发生在与 Xcode 连接时,而不是从 IPA 安装时。我没有运气找到任何人使用此崩溃消息,也没有找到 'Attempt to add an app with insufficient id' 消息(尽管人们似乎更频繁地点击它)。

我找到了解决此问题的方法。只需将一个虚拟 Swift 文件(其中包含一个虚拟 class)添加到 ObjC 应用程序项目即可解决该问题。不需要桥接头,也不需要在任何地方实际引用虚拟 class。

它没有回答为什么会发生这种情况,但也许 Xcode 中存在问题,这只会迫使它包含 Swift 标准库。