【问题标题】:Nativescript Algolia iOS Build FailNativescript Algolia iOS 构建失败
【发布时间】:2019-08-04 20:20:17
【问题描述】:

我正在尝试构建nativescript-algolia,但它在 iOS 上失败了。这是我得到的错误:

[!] Unable to determine Swift version for the following pods:

- `AlgoliaSearch-Client-Swift` does not specify a Swift version 
and none of the targets (`appname`) integrating it have the 
`SWIFT_VERSION` attribute set. Please contact the author
or set the `SWIFT_VERSION` attribute in at least one of the 
targets that integrate this pod.

我已经尝试了从谷歌搜索这个问题中看到的所有内容。我似乎无法正确设置 Swift 版本。

【问题讨论】:

标签: nativescript angular2-nativescript nativescript-angular nativescript-plugin


【解决方案1】:

降级到1.5.3 不是一个合适的解决方法,并且在未来将不可持续。事实上,这个错误是由于 Cocoapods 1.6.0 版本中引入的一种新行为,它迫使开发人员为他们的项目设置一个 Swift 版本。事实上,目标是让库开发人员在他们的podspec 中指定一个 Swift 版本,这样库用户就不必手动执行此操作(例如,感谢post_install 脚​​本)。你可以看到my discussion about this with a Cocoapods maintainer here。我确实同意这种行为有点误导,因为我们尝试在post_install 脚本中设置 Swift 版本,但之前返回错误......

事实上,正如维护人员告诉我的,解决此问题的正确方法是在项目级别(而不是在 Pod 级别)设置 Swift 版本。为此,只需在Build Settings 中添加一个新的User Defined Setting,键为SWIFT_VERSION 和值4.0(例如,如果您还使用post_install 脚本在Pod 级别设置版本,则任何值都可以在此处使用)。

长话短说,解决方法是添加此键/值:

请注意,当您使用 NativeScript 时,您可能希望在构建之前通过在项目文件夹中运行命令 export SWIFT_VERSION=4 来设置 Swift 版本。

【讨论】:

    【解决方案2】:

    App_Resources/iOS 中创建一个名为Podfile 的文件并添加以下行,

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '4.0'
         end
       end
    end
    

    【讨论】:

    • 你尝试过干净的构建吗?
    【解决方案3】:

    在插件创建者的帮助下,我能够通过降级我的 Cocoapods 版本来解决这个问题。

    sudo gem uninstall cocoapods
    sudo gem install cocoapods -v 1.5.3
    

    参考资料:

    https://github.com/arpit2438735/nativescript-algolia/issues/19#issuecomment-472847392

    Swift Version NativeScript

    【讨论】:

    • 降级 Cocoapods 版本不是一个合适的解决方法,您将无法永远坚持使用 1.5.3 版本。请在下面查看我的答案。
    猜你喜欢
    • 2019-02-25
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多