简体   繁体   English

Alamofire无法正常工作(Swift / Xcode 8)

[英]Alamofire not working (Swift/Xcode 8)

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). 尝试将Alamofire导入我的项目时,我遇到以下错误(Cocoapods不能为我工作,所以我必须手动导入它)。

Anyway, I'm using XCode 8 and Swift 2.3, and I'm getting these errors: 无论如何,我正在使用XCode 8和Swift 2.3,我收到这些错误:

使用未解析的标识符kSecTrustResultProceed

上下文类型AnyObject不能与数组文字一起使用

Update: I cleaned XCode, downloaded the latest version of Alamofire and restarted my computer. 更新:我清理了XCode,下载了最新版本的Alamofire并重新启动了我的电脑。 Now, XCode seems to be giving me conflicting errors (pictures for reference) 现在,XCode似乎给了我相互矛盾的错误(图片供参考) 无法强制解包非可选类型String的值 可选类型String的值?没有打开 Thanks! 谢谢!

As of early September '16, you need to use the following in your Podfile: 从16年9月初开始,您需要在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. 指向swift2.3分支不再有效,因为该分支已被删除。 The tag '3.5.0' points to the last revision on master that supports Swift 2.3. 标签“3.5.0”指向支持Swift 2.3的master上的最后一个版本。

Use Swift 2.3 in Xcode 8 在Xcode 8中使用Swift 2.3

在此输入图像描述

在此输入图像描述

Pod file Pod文件

    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

More information about Xcode 8 + Swift 2.3 support for Alamofire: https://github.com/Alamofire/Alamofire/pull/1313 有关Xcode 8 + Swift 2.3支持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) pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.5.0' (已更新)

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/ 更新:如果您对保持Xcode7兼容性感兴趣,并且仍能够针对iOS10 / swift 2.3进行开发,这是一个很好的指南: http ://radex.io/xcode7-xcode8/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM