ios - Swift:iOS 12.2 应用程序在启动时崩溃

标签 ios swift xcode crash

更新 Xcode 和 swift 5 后,在 iOS 12.2 上启动模拟器后,我的应用程序在启动时崩溃。但在早期版本的 ios(如 12.0)中,应用程序可以正常工作。我在真实设备 ios 12.0.1 上启动应用程序并且应用程序正常运行,然后在 iOS 设备 12.2 上启动应用程序并且应用程序崩溃

我不知道它是否相关,但在控制台中我有这条消息:

objc[39432]: Swift class extensions and categories on Swift classes are not allowed to have +load methods

然后 Xcode 重定向到 0_abort_with_payload:

    libsystem_kernel.dylib`__abort_with_payload:
    0x11365200c <+0>:  movl   $0x2000209, %eax          ; imm = 0x2000209 
    0x113652011 <+5>:  movq   %rcx, %r10
    0x113652014 <+8>:  syscall 
->  0x113652016 <+10>: jae    0x113652020               ; <+20>
    0x113652018 <+12>: movq   %rax, %rdi
    0x11365201b <+15>: jmp    0x113634457               ; cerror_nocancel
    0x113652020 <+20>: retq   
    0x113652021 <+21>: nop    
    0x113652022 <+22>: nop    
    0x113652023 <+23>: nop    

最佳答案

您提到的错误非常相关:)

objc[39432]: Swift class extensions and categories on Swift classes are not allowed to have +load methods

我找不到它发生的原因,但问题似乎是你,或者你正在使用的某些依赖项正在使用不再允许的静态 load 方法。

有几件事你可以尝试

  1. 检查代码中的load 函数
  2. 查看您的依赖项,看看是否有任何可以解决此问题的更新

thread on twitter也可用于查明问题可能出在哪里。正如建议的那样,尝试在启动应用程序时添加 OBJC_PRINT_LOAD_METHODS=YES,因为这应该会为您提供更多线索。

希望对您有所帮助。

关于ios - Swift:iOS 12.2 应用程序在启动时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55450151/

相关文章:

swift - 引用作为 swift 字典中的键

iphone:如何在 webView 中放置主页按钮

macos - UILabel/NSTextView 与 CATextLayer

Swift 字符串 %d 格式化程序将大 Int 转换为负数

ios - 在运行时更改 iOS 模拟器的当前语言环境

swift - 在其他数组中使用 ForEach 的索引

ios - 使用 pod 中的测试代码在物理设备上运行 Xcode ui 测试

ios - @1x 大小的 iOS 中的图像资源

TableView 单元格中的 iOS swift UIButton

ios - (iOS) 当应用程序不再运行时取消所有本地通知