ios 13.3.1 Alamofire 5 提示Library not loaded

1,620 阅读1分钟

正在做的应用,原来是基于iOS 14的 现在要适配到ios13上,在模拟器上没有问题,但是在真机测试的时候遇到问题,应用加载到开屏界面变crash了,多次排查发现是alamofire的库无法载入,在网上搜索到相关信息

stackoverflow 上 After updating iOS, all applications using the framework stopped running on the device, but they run on the simulator](stackoverflow.com/questions/6…)

Alamofire issue 上 # iOS 13.3.1 dyld: Library not loaded

我尝试的方案,根据上述两处网页的指引,我首先是 注释掉 Podfile 的 use_frameworks!

# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'
target 'MyApp' do
  # Comment the next line if you don't want to use dynamic frameworks
#  use_frameworks!
  # Pods for MyApp
  pod 'EFQRCode', '~> 6.1.0'
  pod "ToastViewSwift"
  pod 'Alamofire', '~> 5.0'
  pod 'SnapKit', '~> 5.0.0'
  pod 'PKHUD', '~> 5.0'
  pod 'SwiftyJSON'
  pod 'RealmSwift', '~>10'
  pod 'SwiftyGif'
  pod 'Kingfisher', '~> 7.0'
  pod 'R.swift'
  pod 'lame'
  pod 'TagListView', '~> 1.0'
  pod 'ZLPhotoBrowser'
  pod 'Eureka', '~> 5.3'
end

然后删掉 Pods 文件夹 重新执行 pod install

Analyzing dependencies
Downloading dependencies
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `RealmSwift` depends upon `Realm`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

可以看出 因为使用了 RealmSwift 需要开启 modular_headers 选项,结合网页中的指引在 Podfile 中,增加开启项

use_modular_headers!

重新执行 一切OK

指引中还说明 这是由于免费开发者账号引起的,可以更换账号试一下