Skip to content

[WIP] Swift 3.0 Migration  #1316

@kcharwood

Description

@kcharwood
Contributor

Alamofire - Swift 3.0

The initial migration to Swift 3.0 has been completed, and can be found in the swift3 branch. Many thanks to the Apple Engineers in the labs at WWDC who assisted with some of the migration issues. 🍻

Please file Github issues for any problems discovered while using this branch.

This branch should be considered a work in progress, and will be updated as future Xcode 8 and Swift 3 seeds are released by Apple.

Official support for Swift 3.0 and Xcode 8 will be not available until the fall when Apple releases both.

Migration Notes

  • Many Foundation types are now value types, instead of reference types. Please audit your code to ensure all references to NSMutableURLRequest are now properly handled as var and are of type URLRequest.

  • Due to the Swift 3.0 naming conventions, many Alamofire API parameters that referenced an object in the URL Foundation loading system and began with capital letters now begin with lowercase letters. For example, URLRequest parameter names are now urlRequest to prevent confusion.

    More notes will be added as issues are discovered.

Radars

The following radars were filed as a result of this migration and are currently being tracked by the ASF team.

  • 26850776: CharacterSet crashes when attempting to remove an item from the set in Swift 3.0
  • 26849668: NSURLProtocol APIs still contain NSMutableURLRequest parameter types and do not support the Swift 3.0 value types
  • 26870455: NSURLSession with background configuration does not function on the iOS simulator inside of test targets

TODO

  • Update Project Recommended Settings
    Update Example
    Travis CI Support
    Update Documentation/README

Activity

agates4

agates4 commented on Jun 19, 2016

@agates4

install compatibility with cocoapods? @kcharwood

EDIT: use

  pod 'Alamofire',
  :git => 'https://github.com/Alamofire/Alamofire.git',
  :branch => 'swift3'
connormlewis

connormlewis commented on Jun 23, 2016

@connormlewis

Using the provided code on the Alamofire page, when creating a generic ResponseObjectSerializable, I get the following error: Member 'failure' in 'Result<T, NSError>' produces result of type 'Result<Value, Error>', but context expects 'Result<T, NSError>'. This occurs on the following line: return .failure(.ObjectSerialization(reason: "JSON could not be serialized into response object")). I am using the swift 3.0 branch.

enagorny

enagorny commented on Jul 14, 2016

@enagorny

Could it be installed via carthage? As I'm getting compile errors

chriscombs

chriscombs commented on Jul 14, 2016

@chriscombs

I am able to install using carthage, have you set the correct version of XCode in Terminal?

sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/

enagorny

enagorny commented on Jul 14, 2016

@enagorny

Indeed. Forgot to switch XCode version. All works fine.
Cartfile:
github "Alamofire/Alamofire" "swift3"

fancytapsio

fancytapsio commented on Jul 14, 2016

@fancytapsio

I am stuck with "error: Found an unexpected Mach-O header code: 0x72613c21" because of the pod, ideas will be highly appreciated.

fancytapsio

fancytapsio commented on Jul 15, 2016

@fancytapsio

@ronaldmannak Thank you, I needed that, it finally worked!

dipang90

dipang90 commented on Jul 18, 2016

@dipang90

I have installed Cocoa pods in xcode 8.1. I add like this:
pod 'Alamofire',
:git => 'https://github.com/Alamofire/Alamofire.git',
:branch => 'swift3'
when I complie my app, Its getting so many error.

jshier

jshier commented on Jul 19, 2016

@jshier
Contributor

Branch has been updated for beta 3.

@dipang90 You likely need to update your version of Xcode 8 to the latest beta.

vladgon

vladgon commented on Jul 19, 2016

@vladgon

Xcode Beta3, using pod and getting ...
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

grosch

grosch commented on Jul 19, 2016

@grosch

Can you explain how to use this please? I created a brand new project and used the Pod configuration that @dipang90 showed. When Xcode starts it immediately wants to do a conversion to Swift 3, and I get 346 issues in Alamofire framework.

I'm using Xcode 8 Beta 3

70 remaining items

gabrielPeart

gabrielPeart commented on Aug 31, 2016

@gabrielPeart

@thebluepotato you are right!

fprosper

fprosper commented on Aug 31, 2016

@fprosper

Thank you @thebluepotato, just noted, thanks!

cnoon

cnoon commented on Sep 7, 2016

@cnoon
Member

I'm going to go ahead and close this issue out. Thank you everyone for all your feedback and reporting and especially you @kcharwood 🍻 for kicking all this off in the first place! We're getting really close to having everything locked down and will be starting on all the documentation updates here shortly.

AF 4 is coming!!! 🎉🎉🎉

added this to the 4.0.0 milestone on Sep 7, 2016
mychaelgo

mychaelgo commented on Sep 15, 2016

@mychaelgo

@thebluepotato but i get error :

 Type 'Method' (aka 'OpaquePointer') has no member 'get'

any suggestion?

jshier

jshier commented on Sep 15, 2016

@jshier
Contributor

@mychaelgo Method has been renamed to HTTPMethod, to disambiguate it from the type you're seeing.

mychaelgo

mychaelgo commented on Sep 15, 2016

@mychaelgo

@jshier oh thank you for mention it!

Rahulpatil710

Rahulpatil710 commented on Sep 18, 2016

@Rahulpatil710

How to call POST method with encoding as JSON, with some header and Passing some parameter

screen shot 2016-09-19 at 1 30 29 am

How can I call this method with JSON response?

Thanks for any help in advance

sonysum

sonysum commented on Sep 19, 2016

@sonysum

[!] /usr/bin/git clone https://github.com/Alamofire/Alamofire.git /var/folders/_2/cfgf2q2x7n7g3881kmbqvh4m0000gp/T/d20160919-5162-1u99gbn --template= --single-branch --depth 1 --branch swift3

Cloning into '/var/folders/_2/cfgf2q2x7n7g3881kmbqvh4m0000gp/T/d20160919-5162-1u99gbn'...
warning: Could not find remote branch swift3 to clone.
fatal: Remote branch swift3 not found in upstream origin

locked and limited conversation to collaborators on Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @jshier@funkenstrahlen@cnoon@gabrielPeart@kcharwood

      Issue actions

        [WIP] Swift 3.0 Migration · Issue #1316 · Alamofire/Alamofire