Alamofire Xcode 8 Swift 3 results in 786 compile errors

前端 未结 10 2424
一个人的身影
一个人的身影 2020-12-29 20:00

I am using the Xcode 8.0 GM. I created a default single-view app with my deployment target set to 9.0.

In my Podfile I\'m targeting the bleeding edge Swift 3 branch:

相关标签:
10条回答
  • 2020-12-29 20:42

    I solved a similar issue by using

    pod 'Alamofire', '~> 4.0'
    

    in the pod file. I did have to adjust to a higher minimum deployment target.

    0 讨论(0)
  • 2020-12-29 20:44

    Not sure if this helps anyone but just in case.. I tried to add Alamofire to a sample quick app on Xcode 8.0 GM using the CocoaPods standalone app.. I kept getting the Convert to swift 2.3 or 3.0 window.. but then I tried from the command line to pod update and it worked. Have no idea why.. I assume the underlying commands for the standalone app are the same.. so not sure what made the difference. In any case after 30 minutes of wasted time mine works.

    This is the command line screenshot.. same pod file

    0 讨论(0)
  • 2020-12-29 20:48

    I was able to get it working:

    update:

    # Uncomment this line to define a global platform for your project
    # platform :ios, '9.0'
    
    target 'PROJECT NAME HERE' do
      # Comment this line if you're not using Swift and don't want to use dynamic frameworks
      use_frameworks!
      pod 'Alamofire',
        :git => 'https://github.com/Alamofire/Alamofire.git',
        :branch => 'swift3'
    
    end
    

    pod update Alamofire

    It should update to 4.0.0-beta.2

    There are a few changes when getting a request:

    old:

    Alamofire.request(URL_NAME_HERE, withMethod: .get).responseJSON { response in
         //Code here.
    }
    

    new:

    Alamofire.request(URL_NAME_HERE, method: .get).responseJSON { response in
         //Code here.
    }
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-29 20:50

    You need to use version 4.0pod 'Alamofire', '~> 4.0' notice that CocoaPods 1.1 is needed.

    0 讨论(0)
提交回复
热议问题