ios - 如何使用 Swift 3 中的 Pod 使用 Swift 4.0 构建 xcode 9 项目?

标签 ios swift3 cocoapods xcode9-beta swift4

我希望我的 iOS 应用程序的主模块编译 Swift 4.0,而 CocoaPods 模块编译 swift 3。

PS:使用 Xcode 9 beta 2。

最佳答案

如果您使用的一些 pod 是用 Swift 4 编写的,但有些是 Swift 3.2,您可以通过以下方式为它们指定 SWIFT_VERSION 值:

swift_32 = ['Pod1', 'Pod2', 'Pod3'] # if these pods are in Swift 3.2
swift4 = ['Pod4', 'Pod5', 'Pod6'] # if these pods are in Swift 4

post_install do |installer|

    installer.pods_project.targets.each do |target|
        swift_version = nil

        if swift_32.include?(target.name)
            swift_version = '3.2'
        end

        if swift4.include?(target.name)
            swift_version = '4.0'
        end

        if swift_version
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = swift_version
            end
        end

    end

end

关于ios - 如何使用 Swift 3 中的 Pod 使用 Swift 4.0 构建 xcode 9 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45198857/

相关文章:

ios - 使用证书连接到 VPN - iOS/Swift

iOS Swift,返回 View Controller 的同一实例

swift - 使用 URLSession 从 URL 读取数据

ios - 如何通过 UITableViewCell 打开 URL

ios - Xcode 8/Swift 3 - 如何将按钮约束锁定为缩放图像,以便它们随图像一起放大和缩小?

ios - 从 AWSiOSSDK - 1.7.1 到 AWSiOSSDKv2 - 2.0.8 的 Amazon Web 服务更新问题

ios - 在 swift 中将 String 转换为 NSData 时数据损坏

ios - UIView 上的 inputAccessoryView

swift - FIRAuth 文件与 FirebaseUI 不兼容 : use of undeclared identifier 'FIRAuthErrorUserInfoUpdatedCredentialKey'

swift - Alamofire 和 GoogleMaps pod