Swift Version NativeScript

Fau*_*man 4 ios cocoapods vue.js swift nativescript

使用NativeScript如何在iOS下运行项目?我跑的时候收到这些消息tns run iOS --bundle

Webpack compilation complete. Watching for file changes.
Webpack build done!
Copying template files...
Platform ios successfully added. v4.2.0
Executing before-shouldPrepare hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Installing pods...
Analyzing dependencies
Downloading dependencies
Installing Socket.IO-Client-Swift (11.1.3)
Installing StarscreamSocketIO (8.0.7)
Installing Toaster (2.0.4)
[!] Unable to determine Swift version for the following pods:

- `Socket.IO-Client-Swift` does not specify a Swift version and none of the targets (`Hybrid`) 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.
- `StarscreamSocketIO` does not specify a Swift version and none of the targets (`Hybrid`) 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.
- `Toaster` does not specify a Swift version and none of the targets (`Hybrid`) 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.
Unable to apply changes on device: 21FFE2BB-EB0D-48E3-A7AD-28CA08DD21E5. Error is: Command pod failed with exit code 1 Error output: 

[!] Automatically assigning platform `ios` with version `8.0` on target `Hybrid` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Run Code Online (Sandbox Code Playgroud)


有人可以帮我吗?

小智 14

刚遇到这些相同的错误,发现从可可足类1.6.0降级为1.5.3为我修复了它。

    sudo gem uninstall cocoapods
    sudo gem install cocoapods -v 1.5.3
Run Code Online (Sandbox Code Playgroud)


dre*_*ter 10

这里的问题似乎是Toaster(2.0.4),它似乎是为Swift 3开发的.

我这样做是为了解决这个问题:

  1. 转到nativescript项目的主文件夹

  2. 在你的bash shell中,执行:

    % export SWIFT_VERSION=3

  3. 然后按照惯例做:

    % tns build ios --bundle

  4. 然后在Xcode中打开项目:

    %cd platforms/ios

    %打开*.workspace

您将收到有关pods项目中的构建错误的警告,可能需要设置您的开发团队,但它应该可以正常工作.


小智 8

问题出在Cocoapods 1.6.x出现SWIFT_VERSION时有不同的行为。以前可以在Podfile的post_install挂钩中设置SWIFT_VERSION,但是现在该pod install命令在进入post_install之前就失败了。最好的解决方案是使用已经设置了SWIFT_VERSION的Cocoapod,例如,如果遇到错误,请尝试与Pod作者联系。同时,作为解决方法,您可以pre_install<path to App_Resources/iOS/Podfile文件中添加具有以下内容的脚本:

pre_install do |installer|
    installer.analysis_result.specifications.each do |s|
        if s.name == 'Socket.IO-Client-Swift' || s.name == 'Starscream' || s.name == 'StarscreamSocketIO' || s.name == 'Toaster'
            s.swift_version = '4.2'
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

对于每个Pod,您可以根据其需求设置不同的Swift版本。