【问题标题】:iOS - Add Swift pod to Objective-C projectiOS - 将 Swift pod 添加到 Objective-C 项目
【发布时间】:2020-07-01 13:53:49
【问题描述】:

您好,我正在开发一个旧的 Objective-C 项目,它有 30 多个 pod 依赖项,全部用 Objective-C 编写。

我正在尝试添加一个 Swift pod,尤其是这个:

pod 'CSV.swift', '~> 2.4.3'
# ...
# other Objective-C pods ...
# ...

因为我想继续 Swift 的新发展。

但我不能让它工作。如果我添加 use_frameworks!,我会在 pod install 时收到错误:

The 'Pods-myProject' target has transitive dependencies that include static binaries: (/myProjectPath/Pods/ObjcPod/ObjcPod.framework)

如果我删除use_frameworks!,我会得到大量编译错误,这里有一些:

Undefined symbol: protocol descriptor for Swift.UnicodeCodec
Undefined symbol: dispatch thunk of Swift.UnicodeCodec.decode<A where A1: Swift.IteratorProtocol, A.CodeUnit == A1.Element>(inout A1) -> Swift.UnicodeDecodingResult

我不知道我可以尝试什么,任何帮助将不胜感激!

【问题讨论】:

    标签: ios objective-c swift cocoa cocoapods


    【解决方案1】:

    这样你就可以在objective c项目中使用swift pod试试这个解决方案。

    写入你的 pod 文件

    target 'YourProjectName' do
    use_frameworks!
    
    pod 'CSV.swift', '~> 2.4.3'
    // Here you can add mode pod as per your requirement Like
    pod 'Firebase/Core'
    pod 'Fabric'
    pod 'Crashlytics'
    
    end
    

    然后运行 ​​Pod 安装。

    为了导入写这个

    @import CSV;
    

    然后您就可以访问您的 CSV pod 文件了。

    【讨论】:

    • 如果我添加use_frameworks!如问题中所述,我在 pod install 时遇到错误
    • 我已经尝试过我的代码及其工作,可能是项目有其他问题。
    猜你喜欢
    • 2014-11-27
    • 2018-06-18
    • 2018-12-10
    • 2016-03-22
    • 1970-01-01
    • 2013-12-15
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    相关资源
    最近更新 更多