菜鸟教程小白 发表于 2022-12-12 12:13:41

ios - Podfile 没有下载最新的 Swift 3 版本的 pod


                                            <p><p>自从更新到 Swift 3 后,我在安装 Swift 3 版本的 pod 时遇到了麻烦。例如,ReadabilityKit 在 master 分支上支持 Swift 3。在他们的自述文件中,他们声明要支持 Swift 3,您必须简单地执行以下操作:</p>

<pre><code>platform :ios, &#39;8.0&#39;
use_frameworks!

target &#39;MyApp&#39; do
    pod &#39;ReadabilityKit&#39;
end
</code></pre>

<p>我还包括以下行:
<code>source 'https://github.com/CocoaPods/Specs.git'</code> 在 podfile 的顶部。</p>

<p>我看到的问题是,我在一个全新的 Swift 3 项目中复制了这个问题,当我执行 <code>pod install</code> 时,我得到了旧版本的 repo。因此,当在 Xcode 中打开项目时,它提供将 pod 的代码转换为 Swift 3,或者如果我构建它会引发一堆错误,因为它不在 Swift 3 中。我最终不得不像这样在 podfile 中列出它:</p>

<pre><code>pod &#39;ReadabilityKit&#39;, :git =&gt; &#39;https://github.com/exyte/ReadabilityKit.git&#39;, :branch =&gt; &#39;master&#39;`
</code></pre>

<p>这是默认设置 - 主分支上的常规 repo。但是直到现在,一旦我运行 <code>pod install</code>,它是否表明它已经升级了 pod,并且它可以正常工作。这不是 ReadabilityKit 独有的——它发生在我迄今为止尝试过的每个支持 Swift 3 的 Pod 上。</p>

<p>我在 Ruby 2.3.0 上使用 Cocoapods 1.0.1。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以尝试将此行添加到您的 podfile 的末尾:</p>

<pre><code>post_install do |installer|
installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings[&#39;SWIFT_VERSION&#39;] = &#39;3.0&#39;
    end
end
end
</code></pre>

<p>或者尝试将 cocoapods 更新到预发布版本:</p>

<pre><code>sudo gem install cocoapods --pre
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Podfile 没有下载最新的 Swift 3 版本的 pod,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/39805660/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/39805660/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Podfile 没有下载最新的 Swift 3 版本的 pod