18

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:

Use of unresolved identifier kSecTrustResultProceed

Contextual type AnyObject cannot be used with array literal

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) Cannot force unwrap value of non-optional type String Value of optional type String? not unwrapped Thanks!

Michael Lee
  • 303
  • 3
  • 8

3 Answers3

15

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.

TotoroTotoro
  • 17,524
  • 4
  • 45
  • 76
  • swift2.3 does NOT exit and it is correct. But it is Not solving the issue. Still having the error of Unresolved identifier !! – mythicalcoder Oct 17 '16 at 14:19
4

Use Swift 2.3 in Xcode 8

enter image description here

enter image description here

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
1

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/

raf
  • 2,569
  • 20
  • 19
  • I'm not sure if your solution works, but I basically realised that all pods written in Swift were causing me errors, so I switched from Alamofire to AFNetworking and so on. – Michael Lee Aug 02 '16 at 04:15
  • It does work, I'm doing this. I had to do the same for 'AlamofireImage'; but they have a 'swift2.3' branch for it too. – raf Aug 03 '16 at 19:26
  • Worked for me! Just need to make sure you use Swift 2.3, not 2.2, and pull the right branch from Alamofire – You Speak So Well Aug 11 '16 at 00:56
  • The podfile needed to be `pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift2.3'` for me – Brynjar Aug 15 '16 at 14:15
  • No Upstream branch ! – mythicalcoder Oct 17 '16 at 14:16
  • 2
    this solution is NOT working for me. XCode 8. Alamofire 3.5.0 and Swift 2.3. There is NO upstream branch for swift2.3 and or swift3 as of Oct 17 2016 !! Is there another way ? – mythicalcoder Oct 17 '16 at 14:17