Alamofire not working (Swift/Xcode 8)

烈酒焚心 提交于 2019-12-20 10:32:38

问题


I am getting the following errors when trying to import Alamofire into my project (Cocoapods isn't working for me, so I have to manually import it).

Anyway, I'm using XCode 8 and Swift 2.3, and I'm getting these errors:

Update: I cleaned XCode, downloaded the latest version of Alamofire and restarted my computer. Now, XCode seems to be giving me conflicting errors (pictures for reference) Thanks!


回答1:


As of early September '16, you need to use the following in your Podfile:

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

Pointing to the swift2.3 branch no longer works, as that branch has been deleted. The tag '3.5.0' points to the last revision on master that supports Swift 2.3.




回答2:


Use Swift 2.3 in Xcode 8

Pod file

    source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!


target 'ProjectName' do
    pod 'Alamofire'
    pod 'Contentful'
    pod 'ContentfulDeliveryAPI'
end

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



回答3:


More information about Xcode 8 + Swift 2.3 support for Alamofire: https://github.com/Alamofire/Alamofire/pull/1313

Try updating your pod to
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.5.0' (Updated)

Update: This is a good guide to follow if you're interested in keeping Xcode7 compatibility, and still be able to target iOS10/swift 2.3 for development: http://radex.io/xcode7-xcode8/



来源:https://stackoverflow.com/questions/38222229/alamofire-not-working-swift-xcode-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!