【问题标题】:I can't run Alamofire in Xcode 8我无法在 Xcode 8 中运行 Alamofire
【发布时间】:2017-06-14 19:58:41
【问题描述】:

我前段时间在 Xcode 7 中创建了一个项目。现在我必须对其进行一些更改。它是在Swift 2.3 中创建的,我在Alamofire 中使用它。现在我在Xcode 8.2.1 更新了Xcode,Swift Version3

我现在遇到了很多错误,我不知道如何让它再次工作。

我找到了相同的可能解决方案,但不适用于我。

我在1.2.0 更新了我的Cocoa Pods。不够。 我更新了Alamofire 版本到最后。结果相同。 我试图转换为当前的Swift Version。还是不好。

我发现该代码放在Podfile 的末尾。

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

这是我的Podfile。也许有帮助...

    # platform :ios, '9.0'

target 'LeTrans Swift' do

   pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.5.0'

   pod 'KRProgressHUD'

   pod 'SwiftyJSON'

   pod 'GoogleMaps'
   pod 'GooglePlaces'
   pod 'GooglePlacePicker'

end

【问题讨论】:

    标签: ios swift xcode cocoapods alamofire


    【解决方案1】:

    首先 如果你更新为使用 xcode8 和 swift3,你应该使用 Alamofire 4.x 版本而不是使用 Alamofire 3.x(这是 swift 2.x)

    Swift2.2 或 Swift2.3 使用的 3.5.0 版本,所以你应该升级版本到 4.x

    试试

    pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.5.0'

    改成

    pod 'Alamofire', '~> 4.3'

    【讨论】:

      【解决方案2】:

      从您的项目中完全删除 pod 文件并重新安装它。按照重新安装的步骤进行操作。我在这里附上了一个示例 pod 文件。我已经在 Xcode 8.2.1 中对其进行了测试。希望对你有帮助。

      1. 项目文件的cd路径
      2. pod 初始化
      3. open -a Xcode Podfile
      4. 如下所示输入您的 pod 文件名
      5. pod 安装

      请按照下面给出的示例 pod 文件进行操作。

      # Uncomment this line to define a global platform for your project
      
      source 'https://github.com/CocoaPods/Specs.git'
      platform :ios, '10.0'
      use_frameworks!
      
      target 'Ebook' do
        # Comment this line if you're not using Swift and don't want to use dynamic frameworks
      
        # Pods for Ebook
          pod 'Alamofire', '~> 4.0'
      
        target 'EbookTests' do
          inherit! :search_paths
          # Pods for testing
        end
      
        target 'EbookUITests' do
          inherit! :search_paths
          # Pods for testing
         end
      
      end
      
      post_install do |installer|
      installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
      end
      end
      end
      

      【讨论】:

        【解决方案3】:
          pod 'Alamofire', '~> 4.6'
        

        swift 3.0 和 Xcode 8 或更高版本中的最新 Alamofire pod 版本支持所有版本。

        【讨论】:

          猜你喜欢
          • 2018-04-06
          • 2017-01-27
          • 2015-12-15
          • 2017-02-27
          • 1970-01-01
          • 2016-11-08
          • 1970-01-01
          • 2017-01-27
          • 1970-01-01
          相关资源
          最近更新 更多