1

I'm using Xcode 7.0 beta 4 (7A165t). I want to add the Alamofire library but it's always failing.

I am using the last Cocoapods version.

My Podfile is:

pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift-2.0'

Is it possible to use it in Xcode 7 with Swift 2.0?

UPDATE

When I run:

pod install

I get this:

Installing Alamofire (2.0.0-beta.1)
[!] Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add use_frameworks! to your Podfile or target to opt into using it. The Swift Pod being used is: Alamofire

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
user3163404
  • 359
  • 1
  • 4
  • 16
  • 1
    You've got a typo in your example. Check my answer here: http://stackoverflow.com/questions/31334205/getting-non-master-branch-from-cocoapods/31336908#31336908 – Eric Aya Aug 19 '15 at 01:15

2 Answers2

4

Do what the error message tells you to and add use_frameworks! to your Podfile. Here's mine as an example:

source 'https://github.com/CocoaPods/Specs.git'
platform :osx, '10.10'
use_frameworks!
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'swift-2.0'

For iOS instead of OS X, replace the platform line with platform :ios, '8.0' or equivalent.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • But should I use it in Xcode 6.4? Can I do this in Xcode 7 beta 5? – user3163404 Aug 19 '15 at 12:16
  • Your question was specific about Swift2/Xcode7... so my answer is for Xcode7, yes, whatever the beta number. But for using Alamofire with Swift1/Xcode6, you don't need to specifiy a branch, use a normal Podfile. This answer is for Swift2 specifically. – Eric Aya Aug 19 '15 at 12:22
  • 1
    Ok. Thank you. I did it. Add the podfile with the info you provied. Changed to platform: ios, '8.3'. Open xcworkspace and add import Alamofire to ViewController.swift. It gives back the error: "Cannot load underlying module for 'Alamofire'. Any idea? – user3163404 Aug 19 '15 at 12:28
  • Yes, this is Xcode freaking out because of cached data. Do "Product -> Clean" and restart Xcode. If this is not enough, search for "clear derived data" and do it too. But just cleaning product should work. – Eric Aya Aug 19 '15 at 12:31
  • It worked thank you very much. Just one more question please. If I want to add SwiftyJSON can I do it in the same Podfile? Or is there a better way? – user3163404 Aug 19 '15 at 12:44
  • You're welcome. :) For SwiftyJSON I don't use Cocoapods, I'm just using it by dropping the `SwiftyJSON.swift` file into my project. But I *guess* you can add the Cocoapods version to your Podfile, yes. – Eric Aya Aug 19 '15 at 12:46
  • I'll try it. But when add it to my project and import SwitfyJSON => 'No such module 'SwiftyJSON'... And the SwiftyJSON.swift has several errors. – user3163404 Aug 19 '15 at 12:51
  • Don't forget to download the specific Swift2 branch of SwiftyJSON for using with Xcode7 :) You can select the branch in GitHub before downloading. https://github.com/SwiftyJSON/SwiftyJSON/tree/xcode7 – Eric Aya Aug 19 '15 at 12:53
  • I didn't realize you were doing that: when using the simple SwiftyJSON.swift file, you *don't* have to declare `import SwiftyJSON`. Remove this import line and it will work by itself. :) – Eric Aya Aug 19 '15 at 13:02
  • 1
    upsss.. Sorry I am new to swift.. Thank you so much. No it's time to learn how to read a JSON.. ahaha. Thank you. – user3163404 Aug 19 '15 at 13:03
0

this is how mi CocoaPods file looks and im currently working in swift2.0 in Xcode7 Beta

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'RESTEST' do
pod 'Alamofire', '~> 2.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

I'm using both SwiftyJSON and Alamofire, if you have any trouble using both libraries we are here to help, Greetings

Yeis Gallegos
  • 444
  • 2
  • 14