升级 XCode 13.2.1 导致 iOS 12 以下设备崩溃

911 阅读1分钟

升级 XCode 13.2.1 导致 iOS 12 以下设备崩溃

把xcode 从 13.1 升级到了 13.2.1。在真机上运行 app,发现直接崩溃。

错误信息

dyld: Library not loaded: /usr/lib/swift/libswiftCore.dylib

 Referenced from: /private/var/containers/Bundle/Application/xxx/xxx.app/Frameworks/libswift_Concurrency.dylib

 Reason: image not found

swift 版本详情

% swift --version
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: x86_64-apple-macosx12.0

看到 swift 版本是5.5.2

排查

Alamofire 5.5 加入并发语法(swift concurrency feature)

github.com/Alamofire/A…

developer.apple.com/forums/thre…

此处,感谢群里的小伙伴 HelloWorld 帮忙排查问题。

原因

xcode 13.2.1 包含了 swift 5.5 添加了swift 并发库

解决方案

方案1. 提高最低支持系统版本

iOS 13 支持 Swift Concurrency 特性

方案2. 降级依赖库

Alamofire 版本降到 5.4.4

/// in podfile
pod 'Alamofire', '5.4.4'

/// in podspec
ss_network.dependency "Alamofire", "5.4.4"

总结

在项目中使用第三方库,最好还是固定版本号。避免开发环境改变时,带来不必要的影响。