Using static libraries in Swift with CocoaPods fails for Realm
从Xcode 9开始,可以通过省略Podfile中的
1 2 3 | [!] The following Swift pods cannot yet be integrated as static libraries: The Swift pod `RealmSwift` depends upon `Realm`, which do 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. |
遗憾的是,使用
我尝试过的其他内容包括:
- 使用最新的Realm版本(3.15.0)
- 使用Objective C版本并添加Swift支持,这将不会在RLMSupport.swift文件中生成并提供模块未找到错误。
- 为Objective C版本添加桥接头。
- 无休止的清理,重建,Xcode重新启动和"派生数据"文件夹清理。
绕过CocoaPods并以单独的方式安装此依赖关系不是最好的选择,因为这会使更新过程变得更加复杂。 我希望有一种可以与CocoaPods,Realm和Swift一起使用的解决方案。
我做了以下工作:
1 2 | pod 'RealmSwift', '~> 3.17', :modular_headers => true pod 'Realm', '~> 3.17', :modular_headers => true |
据我所知,添加use_modular_headers! 到Podfile的顶部。
据我所知,向.podspec添加s.pod_target_xcconfig = {'DEFINES_MODULE'=>'YES'}无效。 (Cocoapods 1.6.0-beta.2)
例:
1 2 3 4 | target 'Opportunity' do use_modular_headers! end |