我是归档应用程序中用于测试/分发的新手。我的MacOS可可应用仅在作为存档构建时崩溃。
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 MY.APP 0x000000010100532a specialized String._CharacterView.index(after:) + 250
1 MY.APP 0x0000000100f55ef9 specialized static TextCompletionNode.hasCommonPrefix(_:with:beyond:) + 153 (AttributeManager.swift:126)
2 MY.APP 0x0000000100f571f9 specialized TextCompletionNode.add(entry:for:) + 1161
3 MY.APP 0x0000000100f584a9 specialized closure #1 in AttributeManager.init(dataSource:loadingHandler:) + 3097
4 MY.APP 0x0000000100f5439e partial apply for closure #1 in AttributeManager.init(dataSource:loadingHandler:) + 30
5 MY.APP 0x000000010104d0a3 SearchQueryCommunicator.messageHandler(_:) + 451
6 MY.APP 0x000000010104d710 protocol witness for MessageHandler.messageHandler(_:) in conformance SearchQueryCommunicator + 16
7 MY.APP 0x000000010102ede8 Socket.handle(object:) + 456
8 MY.APP 0x0000000101031928 specialized Socket.readAvailableBytes(from:) + 1096
9 MY.APP 0x0000000101031c48 specialized Socket.stream(_:handle:) + 104 (Socket.swift:77)
10 MY.APP 0x000000010102ebff @objc Socket.stream(_:handle:) + 47
11 com.apple.CoreFoundation 0x00007fff49548dc4 _signalEventSync + 228
12 com.apple.CoreFoundation 0x00007fff49563736 _cfstream_solo_signalEventSync + 246
13 com.apple.CoreFoundation 0x00007fff49546ca4 _CFStreamSignalEvent + 484
14 com.apple.CFNetwork 0x00007fff48448a62 SocketStream::dispatchSignalFromSocketCallbackUnlocked(SocketStreamSignalHolder*) + 58
15 com.apple.CFNetwork 0x00007fff4844cff9 SocketStream::socketCallback(__CFSocket*, unsigned long, __CFData const*, void const*) + 145
16 com.apple.CFNetwork 0x00007fff4844cf2e SocketStream::_SocketCallBack_stream(__CFSocket*, unsigned long, __CFData const*, void const*, void*) + 70
17 com.apple.CoreFoundation 0x00007fff49546898 __CFSocketPerformV0 + 1016
18 com.apple.CoreFoundation 0x00007fff49527a11 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
19 com.apple.CoreFoundation 0x00007fff495e142c __CFRunLoopDoSource0 + 108
20 com.apple.CoreFoundation 0x00007fff4950a470 __CFRunLoopDoSources0 + 208
21 com.apple.CoreFoundation 0x00007fff495098ed __CFRunLoopRun + 1293
22 com.apple.CoreFoundation 0x00007fff49509153 CFRunLoopRunSpecific + 483
23 com.apple.HIToolbox 0x00007fff487f3d96 RunCurrentEventLoopInMode + 286
24 com.apple.HIToolbox 0x00007fff487f3b06 ReceiveNextEventCommon + 613
25 com.apple.HIToolbox 0x00007fff487f3884 _BlockUntilNextEventMatchingListInModeWithFilter + 64
26 com.apple.AppKit 0x00007fff46aa4a73 _DPSNextEvent + 2085
27 com.apple.AppKit 0x00007fff4723ae34 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
28 com.apple.AppKit 0x00007fff46a99885 -[NSApplication run] + 764
29 com.apple.AppKit 0x00007fff46a68a72 NSApplicationMain + 804
30 MY.APP 0x0000000100f40949 main + 9 (AppDelegate.swift:12)
31 libdyld.dylib 0x00007fff7134a015 start + 1
这是TextCompletionNode函数:
// we assume firstString and secondString are at least longer than beyond
private static func hasCommonPrefix(_ firstString:String, with secondString:String, beyond beyondIndex:String.Index) -> String? {
assert((firstString.endIndex >= beyondIndex) && (secondString.endIndex >= beyondIndex))
var commonPrefix = String(firstString[..<beyondIndex])
guard secondString.hasPrefix(commonPrefix) else {
return nil
}
var firstIndex = beyondIndex
let firstEndIndex = firstString.endIndex
var previousCommonPrefix: String
repeat {
previousCommonPrefix = commonPrefix
if firstIndex >= firstEndIndex {
break
}
//NSLog("firstString = \"\(firstString)\", firstIndex = \(firstIndex)")
firstIndex = firstString.index(after: firstIndex) // <-- Crashing?
commonPrefix = String(firstString[..<firstIndex])
} while secondString.hasPrefix(commonPrefix)
return previousCommonPrefix
}
从Xcode运行应用程序时,测试相同功能时,一切工作都很好。我已阅读到调试信息已从存档的应用程序中删除,因此您无法真正对其进行调试。我尝试添加NSLog语句以在控制台应用程序中编写一些调试信息,但没有显示任何内容。我还尝试从命令行(MyApp.app/Contents/MacOS/MyApp)启动该应用程序,终端上也没有显示任何内容。
我想了解更多有关坠机前情况的信息。我该怎么办?
编辑:我已经尝试根据另一篇文章的回答https://stackoverflow.com/a/5938021/301189刷新STDERR,甚至将STDERR重定向到文件中,但没有任何反应。只需将NSLog(_:_:)
替换为printf(_:)
就能帮助我在终端中获得一些输出。我仍然不知道为什么我无法从存档的应用程序中的STDERR中得到任何东西。
此外,在终端上输出某些输出时,也不会发生上述崩溃。如此奇怪的错误...