Elegant HTTP Networking in Swift

Overview

Alamofire: Elegant Networking in Swift

Build Status CocoaPods Compatible Carthage Compatible Platform Twitter Gitter Open Source Helpers

Alamofire is an HTTP networking library written in Swift.

Features

  • Chainable Request / Response Methods
  • Combine Support
  • URL / JSON Parameter Encoding
  • Upload File / Data / Stream / MultipartFormData
  • Download File using Request or Resume Data
  • Authentication with URLCredential
  • HTTP Response Validation
  • Upload and Download Progress Closures with Progress
  • cURL Command Output
  • Dynamically Adapt and Retry Requests
  • TLS Certificate and Public Key Pinning
  • Network Reachability
  • Comprehensive Unit and Integration Test Coverage
  • Complete Documentation

Component Libraries

In order to keep Alamofire focused specifically on core networking implementations, additional component libraries have been created by the Alamofire Software Foundation to bring additional functionality to the Alamofire ecosystem.

  • AlamofireImage - An image library including image response serializers, UIImage and UIImageView extensions, custom image filters, an auto-purging in-memory cache, and a priority-based image downloading system.
  • AlamofireNetworkActivityIndicator - Controls the visibility of the network activity indicator on iOS using Alamofire. It contains configurable delay timers to help mitigate flicker and can support URLSession instances not managed by Alamofire.

Requirements

  • iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
  • Xcode 11+
  • Swift 5.1+

Migration Guides

Communication

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Alamofire', '~> 5.2'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "Alamofire/Alamofire" ~> 5.2

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but Alamofire does support its use on supported platforms.

Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.2.0"))
]

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate Alamofire into your project manually.

Embedded Framework

  • Open up Terminal, cd into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:

    $ git init
  • Add Alamofire as a git submodule by running the following command:

    $ git submodule add https://github.com/Alamofire/Alamofire.git
  • Open the new Alamofire folder, and drag the Alamofire.xcodeproj into the Project Navigator of your application's Xcode project.

    It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.

  • Select the Alamofire.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.

  • Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.

  • In the tab bar at the top of that window, open the "General" panel.

  • Click on the + button under the "Embedded Binaries" section.

  • You will see two different Alamofire.xcodeproj folders each with two different versions of the Alamofire.framework nested inside a Products folder.

    It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Alamofire.framework.

  • Select the top Alamofire.framework for iOS and the bottom one for macOS.

    You can verify which one you selected by inspecting the build log for your project. The build target for Alamofire will be listed as Alamofire iOS, Alamofire macOS, Alamofire tvOS, or Alamofire watchOS.

  • And that's it!

    The Alamofire.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.

Open Radars

The following radars have some effect on the current implementation of Alamofire.

  • rdar://21349340 - Compiler throwing warning due to toll-free bridging issue in the test case
  • rdar://26870455 - Background URL Session Configurations do not work in the simulator
  • rdar://26849668 - Some URLProtocol APIs do not properly handle URLRequest
  • FB7624529 - urlSession(_:task:didFinishCollecting:) never called on watchOS

Resolved Radars

The following radars have been resolved over time after being filed against the Alamofire project.

  • rdar://26761490 - Swift string interpolation causing memory leak with common usage.
    • (Resolved): 9/1/17 in Xcode 9 beta 6.
  • rdar://36082113 - URLSessionTaskMetrics failing to link on watchOS 3.0+
    • (Resolved): Just add CFNetwork to your linked frameworks.

Workarounds

  • Collection of URLSessionTaskMetrics is currently disabled on watchOS due to FB7624529.

FAQ

What's the origin of the name Alamofire?

Alamofire is named after the Alamo Fire flower, a hybrid variant of the Bluebonnet, the official state flower of Texas.

Credits

Alamofire is owned and maintained by the Alamofire Software Foundation. You can follow them on Twitter at @AlamofireSF for project updates and releases.

Security Disclosure

If you believe you have identified a security vulnerability with Alamofire, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.

Donations

The ASF is looking to raise money to officially stay registered as a federal non-profit organization. Registering will allow Foundation members to gain some legal protections and also allow us to put donations to use, tax-free. Donating to the ASF will enable us to:

  • Pay our yearly legal fees to keep the non-profit in good status
  • Pay for our mail servers to help us stay on top of all questions and security issues
  • Potentially fund test servers to make it easier for us to test the edge cases
  • Potentially fund developers to work on one of our projects full-time

The community adoption of the ASF libraries has been amazing. We are greatly humbled by your enthusiasm around the projects and want to continue to do everything we can to move the needle forward. With your continued support, the ASF will be able to improve its reach and also provide better legal safety for the core members. If you use any of our libraries for work, see if your employers would be interested in donating. Any amount you can donate today to help us reach our goal would be greatly appreciated.

paypal

License

Alamofire is released under the MIT license. See LICENSE for details.

Issues
  • [WIP] Swift 3.0 Migration

    [WIP] Swift 3.0 Migration

    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. :beers:

    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

    • [x] Update Project Recommended Settings
    • [x] Update Example
    • [x] Travis CI Support
    • [ ] Update Documentation/README
    swift 
    opened by kcharwood 85
  • dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire on my iPhone(iOS8) while debuging

    dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire on my iPhone(iOS8) while debuging

    dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
      Referenced from: /private/var/mobile/Containers/Bundle/Application/XXX/Anachronos.app/Anachronos
      Reason: image not found
    

    Xcode6 GM

    I've read all the issues about this kind of problem, but couldn't solve the problem.

    Also, there is the same issue in iOS Example project:

    dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
      Referenced from: /private/var/mobile/Containers/Bundle/Application/CEA6C4C1-C211-460C-8ECF-4FD9C66F1016/iOS Example.app/iOS Example
      Reason: image not found
    
    opened by imWildCat 58
  • iOS 13.3.1 dyld: Library not loaded

    iOS 13.3.1 dyld: Library not loaded

    I'm getting this error when trying to run my app with Alamofire 5.0.0-rc3:

    dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire Referenced from: /private/var/containers/Bundle/Application/CC8FF01F-CB03-4D92-ADDE-8B458EDF3D74/SupremeYou.app/SupremeYou Reason: no suitable image found. Did find: /private/var/containers/Bundle/Application/CC8FF01F-CB03-4D92-ADDE-8B458EDF3D74/SupremeYou.app/Frameworks/Alamofire.framework/Alamofire: code signature invalid for '/private/var/containers/Bundle/Application/CC8FF01F-CB03-4D92-ADDE-8B458EDF3D74/SupremeYou.app/Frameworks/Alamofire.framework/Alamofire'

    /private/var/containers/Bundle/Application/CC8FF01F-CB03-4D92-ADDE-8B458EDF3D74/SupremeYou.app/Frameworks/Alamofire.framework/Alamofire: stat() failed with errno=25
    /private/var/containers/Bundle/Application/CC8FF01F-CB03-4D92-ADDE-8B458EDF3D74/SupremeYou.app/Frameworks/Alamofire.framework/Alamofire: code signature invalid for '/private/var/containers/Bundle/Application/CC8FF01F-CB03-4D92-ADDE-8B458EDF3D74/SupremeYou.app/Frameworks/Alamofire.framework/Alamofire'
    

    I've been tested my app on an iPhone 11 Pro 13.3 and it was working fine until I decided to update the phone. So I update the iPhone 11 to the 13.3.1 version, and the error started to appear.

    it works fine on an iPhone 8 Plus with iOS version 13.3.

    Also it doesn't work on an iPhone 6s with iOS 13.3.1.

    support 
    opened by Wasa22 55
  • AlamoFire full IPv6 support

    AlamoFire full IPv6 support

    Hello,

    Due to http://9to5mac.com/2016/05/04/apple-will-require-ios-app-store-apps-to-support-ipv6-only-networks-from-june-1/

    I am opening this for raising a small issue, but also to ask a question.

    Is alamofire fully supporting IPv6? referencing the doc from Apple https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1

    I haven't found any hardcoded IP address or reference to low level api apart those:

    NetworkReachabilityManager.swift
    is using IPv4 only: AF_INET and sockaddr_in

    Apple suggest to support also IPv6 counterparts: https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW12

    If your code handles IPv4 types, make sure the IPv6 equivalents are handled too.

    IPv4 IPv6 AF_INET AF_INET6 PF_INET PF_INET6 struct in_addr struct in_addr6 struct sockaddr_in struct sockaddr_in6 kDNSServiceProtocol_IPv4 kDNSServiceProtocol_IPv6

    Thanks

    reachability 
    opened by racer1988 47
  • Xcode 13 betas: Build fails in Combine

    Xcode 13 betas: Build fails in Combine

    Facing below error: SourcePackages/checkouts/Alamofire/Source/Combine.swift:25:5: Failed to build module 'Combine'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5 (swiftlang-1300.0.24.14 clang-1300.0.25.10)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.24.13 clang-1300.0.25.10)'). Please select a toolchain which matches the SDK.

    What did you expect to happen?

    it should build project successfully.

    What happened instead?

    Its throwing error. Same problem was in Kingfisher GitHub repository, They created new branch with fix, changed deployment target from v10 to 12

    Alamofire Environment

    Alamofire Version: 5.2.1 Dependency Manager: Swift Package Manager Xcode Version: Version 13.0 beta 3 (13A5192i) Swift Version: Swift 5 Platform(s) Running Alamofire: iOS macOS Version Running Xcode: 12.0 Beta (21A5284e)

    support 
    opened by phiren 45
  • Feature - MultipartFormData

    Feature - MultipartFormData

    This pull request adds support for uploading MultipartFormData to Alamofire. I would love feedback from the community to make sure everything here is in tip-top shape before rolling it in. Any feedback would be much appreciated.

    MultipartFormData

    The general idea is that you append body parts to the larger MultipartFormData object, then encode it when you want the cumulative result. Encoding can be performed in two different ways:

    1. Encoding In-Memory
    2. Encoding Data by Streaming to Disk

    Encoding In-Memory

    Encoding in-memory should only be used with small datasets. If the contentLength of the MultipartFormData is too large, you run the risk of your app being terminated due to memory usage.

    Encoding Data by Streaming to Disk

    Sometimes you need to upload a very large dataset to a server such as a bundle of large images or videos. In these cases, your dataset is too large to perform the encoding in-memory. For these cases, the MultipartFormData class supports encoding the data using a combination of input and output streams keeping the memory footprint very small.

    Uploading from Manager

    The upload methods for uploading MultipartFormData support the idea of a memory threshold. To make it as easy as possible, the memory threshold is used to determine whether the MultipartFormData can be encoded in-memory or whether it needs to be written to disk first. The default value for the memory threshold is currently set to 10MB.

    In order to make the encoding process asynchronous, the upload methods could not return a Request object directly. To handle this case, the MultipartFormDataEncodingResult enumeration was added and exposed in an encodingCompletion closure. The resulting Request object is contained as an associated value in the .Success case which can then be used to chain additional methods against. While this is a bit different than the other public APIs, it still is quite simple to use.

    Alamofire.upload(
        .POST,
        URLString: "http://httpbin.org/post",
        multipartFormData: { multipartFormData in
            multipartFormData.appendBodyPart(fileURL: unicornImageURL, name: "unicorn")
            multipartFormData.appendBodyPart(fileURL: rainbowImageURL, name: "rainbow")
        },
        encodingCompletion: { encodingResult in
            switch encodingResult {
            case .Success(let upload, _, _):
                upload.responseJSON { request, response, JSON, error in
                    println(JSON)
                }
            case .Failure(let encodingError):
                println(encodingError)
            }
        }
    )
    

    Summary

    This was a fairly complicated feature to put together, so I'd really love to gather everyone's feedback. If you have a solid grasp of RFC 2388 and 2045, then please take the time to review these changes before we merge it in.

    help wanted feature request multipart form data needs feedback 
    opened by cnoon 45
  • How to debug crash in SessionDelegate.urlSession(URLSession, dataTask : URLSessionDataTask, didReceive : Data)?

    How to debug crash in SessionDelegate.urlSession(URLSession, dataTask : URLSessionDataTask, didReceive : Data)?

    I'm seeing a fairly common EXC_BREAKPOINT crash in Crashlytics caused by a delegate handler in Alamofire. See below for the stack trace. The app in question is iOS 10 only, and the crash seems to happen on all devices and 10.x versions.

    Crashed: NSOperationQueue 0x170034f60 :: NSOperation 0x1708519a0 (QOS: DEFAULT)
    0  libswiftFoundation.dylib       0x100dc2e4c static Data._unconditionallyBridgeFromObjectiveC(NSData?) -> Data (__hidden#3516_:1698)
    1  Alamofire                      0x10061388c @objc SessionDelegate.urlSession(URLSession, dataTask : URLSessionDataTask, didReceive : Data) -> () + 184
    2  CFNetwork                      0x185672b1c __67-[NSURLSession delegate_dataTask:didReceiveData:completionHandler:]_block_invoke.242 + 36
    3  Foundation                     0x185993fb0 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
    4  Foundation                     0x1858d8aa8 -[NSBlockOperation main] + 96
    5  Foundation                     0x1858c90a4 -[__NSOperationInternal _start:] + 620
    6  Foundation                     0x18599635c __NSOQSchedule_f + 228
    7  libdispatch.dylib              0x183d2e1bc _dispatch_client_callout + 16
    8  libdispatch.dylib              0x183d3c3dc _dispatch_queue_serial_drain + 928
    9  libdispatch.dylib              0x183d319a4 _dispatch_queue_invoke + 652
    10 libdispatch.dylib              0x183d3e34c _dispatch_root_queue_drain + 572
    11 libdispatch.dylib              0x183d3e0ac _dispatch_worker_thread3 + 124
    12 libsystem_pthread.dylib        0x183f372a0 _pthread_wqthread + 1288
    13 libsystem_pthread.dylib        0x183f36d8c start_wqthread + 4
    

    Due to the crash being EXC_BREAKPOINT I'm assuming it's a failing assertion somewhere and may actually be happening in the Swift/Obj-C compatibility layer before the actual delegate code is even called. But I'm not sure how to debug this and was hoping someone on here has an idea why this would happen.

    I use Alamofire for standard HTTPS requests to a JSON backend. I have one standard session manager and one background session manager. I'm setting the backgroundCompletionHandler in the app delegate as well.

    needs investigation 
    opened by blixt 44
  • Self-Signed Certificate not accepted

    Self-Signed Certificate not accepted

    Hi,

    I'm using Alamofire for a https connection. I use a nodejs https server. When using curl and providing the CA using --cacert <ca-file> it works just fine. However when testing in Alamofire I get this error:

    Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x60c000047980>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, NSErrorPeerCertificateChainKey=<CFArray 0x60600015e840 [0x10c05b7b0]>{type = immutable, count = 1, values = (
        0 : <cert(0x61600007e680) s: localhost i: localhost>
    )}, NSUnderlyingError=0x6040000abe90 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x60c000047980>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, kCFStreamPropertySSLPeerCertificates=<CFArray 0x60600015e840 [0x10c05b7b0]>{type = immutable, count = 1, values = (
        0 : <cert(0x61600007e680) s: localhost i: localhost>
    )}}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.
    

    My source looks like this:

    class Networking {
      static let manager: Manager = {
        let serverTrustPolicies: [String: ServerTrustPolicy] = [
          "localhost": .DisableEvaluation
        ]
    
        let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        configuration.HTTPAdditionalHeaders = Alamofire.Manager.defaultHTTPHeaders
    
        return Alamofire.Manager(configuration: configuration,
          serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies))
      }()
    
      func test() {
        Networking.manager.request(.GET, "https://localhost:3000/", parameters: nil)
          .responseJSON { (response: Response<AnyObject, NSError>) in
            // nothing interesting
        }
      }
    

    I'm using Alamofire from the xcode7.1 branch.

    security 
    opened by moritzsternemann 39
  • Cannot load underlying module for 'Alamofire'

    Cannot load underlying module for 'Alamofire'

    Unable to successfully use/import Alamofire. Xcode 6.3 with a clean project and cocoapods install. screen shot 2015-04-21 at 2 40 00 am

    support cocoapods 
    opened by n2b8 39
  • Multiple encoding methods in single request

    Multiple encoding methods in single request

    I need to make a POST request with an HTTP Body with a JSON object, but I also need to use url query parameters in the same request.

    POST: http://www.mysite.com/api/create?param1=value&param2=value
    HTTP Body: { foo : [ bar, foo], bar: foo}
    

    Is this supported? How would I go about doing this?

    Thanks

    opened by AnthonyMDev 37
  • Bug: EXC_BREAKPOINT --> valueForHTTPHeaderField

    Bug: EXC_BREAKPOINT --> valueForHTTPHeaderField

    What did you do?

    We noticed random crashes within our App related to Network issues. Looking into the stack trace provided by our crash report tool we noticed that we always end up in the Alamofire -> HTTPHeaders.swift -> Validation.swift (Line:110).

    What did you expect to happen?

    App should not crash for an Api Call which has been successful.

    What happened instead?

    For a random Api Call the App crashes.

    Alamofire Environment

    Alamofire Version:

    • Alamofire (5.4.3)
    • AlamofireImage (4.2.0):
    • Alamofire (~> 5.4)

    Dependency Manager:

    • CocoaPods

    Xcode Version: 13.1

    Swift Version: 5

    Platform(s) Running Alamofire: iOS

    macOS Version Running Xcode: BigSur 11.5.2

    Stack Trace

    OS Version: iOS 14.7.1 (18G82)
    Report Version: 104
    
    Exception Type: EXC_BREAKPOINT (SIGTRAP)
    Crashed Thread: 11
    
    Application Specific Information:
    _inner > valueForHTTPHeaderField:
    
    Thread 11 Crashed:
    0   CoreFoundation                  0x3269d405c         CFRelease
    1   CFNetwork                       0x3278fac94         [inlined] cfnTranslateCFError
    2   CFNetwork                       0x3278fac94         cfnTranslateCFError
    3   Alamofire                       0x10dab1350         Request.validate<T> (Validation.swift:110)
    4   Alamofire                       0x10dab11b0         Request.validate<T> (Validation.swift:102)
    5   Alamofire                       0x10dab28cc         DataRequest.validate<T> (Validation.swift:175)
    6   Alamofire                       0x10da43bb8         DataRequest.validate (Request.swift:1154)
    7   Alamofire                       0x10da6c628         [inlined] <redacted>
    8   Alamofire                       0x10da6c628         thunk for closure
    9   Alamofire                       0x10da407f8         [inlined] <redacted>
    10  Alamofire                       0x10da407f8         [inlined] <redacted> (Request.swift:469)
    11  Alamofire                       0x10da407f8         [inlined] <redacted>
    12  Alamofire                       0x10da407f8         [inlined] forEach
    13  Alamofire                       0x10da407f8         Request.didCompleteTask (Request.swift:469)
    14  Alamofire                       0x10daa69e8         SessionDelegate.urlSession (SessionDelegate.swift:214)
    15  Alamofire                       0x10da9c098         Session.didCompleteTask (Session.swift:1240)
    16  Alamofire                       0x10daa68cc         SessionDelegate.urlSession (SessionDelegate.swift:213)
    17  Alamofire                       0x10daa6adc         SessionDelegate.urlSession
    18  CFNetwork                       0x327a0a5bc         _CFNetworkHTTPConnectionCacheSetLimit
    19  Foundation                      0x32920af84         __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
    20  Foundation                      0x3290f8624         -[NSBlockOperation main]
    21  Foundation                      0x32920d3ac         __NSOPERATION_IS_INVOKING_MAIN__
    22  Foundation                      0x3290f82ac         -[NSOperation start]
    23  Foundation                      0x32920de50         __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
    24  Foundation                      0x32920d8dc         __NSOQSchedule_f
    25  libdispatch.dylib               0x326409480         _dispatch_block_async_invoke2
    26  libdispatch.dylib               0x3263fa818         _dispatch_client_callout
    27  libdispatch.dylib               0x326402000         _dispatch_lane_serial_drain
    28  libdispatch.dylib               0x326402bfc         _dispatch_lane_invoke
    29  libdispatch.dylib               0x32640d4b8         _dispatch_workloop_worker_thread
    30  libsystem_pthread.dylib         0x3be5017a0         _pthread_wqthread
    
    opened by MohamedAymenHADDAD 0
  • Alamofire (5.4.4) -> org.alamofire.session.rootQueue

    Alamofire (5.4.4) -> org.alamofire.session.rootQueue

    What did you do?

    We updated several Pods, including Alamofire, in our last release. We went from 5.4.3 to 5.4.4 and experienced by today 525 crash events affecting 432 users. All crashes have the same signature and happen across multiple OSs as well as device types.

    What did you expect to happen?

    To have a seamless switch from Alamofire (5.4.3) -> Alamofire (5.4.4)

    What happened instead?

    Hundreds of our users crashed with the same cause Crashed: org.alamofire.session.rootQueue.

    Alamofire Environment

    Alamofire Version: 5.4.4 Dependency Manager: Cocoapods Xcode Version: 12.4 (12D4e) & 13.0 (13A233) Swift Version: Swift 5 Platform(s) Running Alamofire: iOS macOS Version Running Xcode: macOS Big Sur 11.6 and others

    Demo Project

    We can so far not reproduce the issue. We have analyzed it with TSan but without any luck.

    image

    Example Stacktrace:

    Crashed: org.alamofire.session.rootQueue
    0  CoreFoundation                 0x6b5dc CFDictionaryGetValue + 100
    1  Foundation                     0x108c94 _NSSetLongLongValueAndNotify + 92
    2  CFNetwork                      0x1da35c _CFNetworkHTTPConnectionCacheSetLimit + 152148
    3  Foundation                     0x132f88 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    4  Foundation                     0x20628 -[NSBlockOperation main] + 104
    5  Foundation                     0x1353b0 __NSOPERATION_IS_INVOKING_MAIN__ + 24
    6  Foundation                     0x202b0 -[NSOperation start] + 808
    7  Foundation                     0x135e54 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24
    8  Foundation                     0x1358e0 __NSOQSchedule_f + 184
    9  libdispatch.dylib              0x13484 _dispatch_block_async_invoke2 + 148
    10 libdispatch.dylib              0x481c _dispatch_client_callout + 20
    11 libdispatch.dylib              0xc004 _dispatch_lane_serial_drain + 620
    12 libdispatch.dylib              0xcc00 _dispatch_lane_invoke + 404
    13 libdispatch.dylib              0x174bc _dispatch_workloop_worker_thread + 764
    14 libsystem_pthread.dylib        0x37a4 _pthread_wqthread + 276
    15 libsystem_pthread.dylib        0xa74c start_wqthread + 8
    
    needs investigation 
    opened by johannes-codes 3
  • AuthenticationInterceptor blocks the refresh token request

    AuthenticationInterceptor blocks the refresh token request

    What did you do?

    Create AuthenticationInterceptor to manage the refresh token.

    private struct CustomCredential: AuthenticationCredential {
        
        var authRepository: AuthRepository
        var requiresRefresh: Bool { true }
    }
    
    // MARK: - Authenticator.
    
    private final class CustomAuthenticator: Authenticator {
        
        // MARK: - Authenticator.
        
        func apply(_ credential: CustomCredential, to urlRequest: inout URLRequest) { }
    
        func refresh(_ credential: CustomCredential,
                     for session: Session,
                     completion: @escaping (Result<CustomCredential, Error>) -> Void) {
            
            let authRepository = credential.authRepository
            
            guard let refreshToken = authRepository.refreshToken else {
                completion(.failure(AuthenticatorError.noRefreshTokenStored))
                return
            }
            
            let request = RefreshTokenRequest(refreshToken: refreshToken)
            _ = credential.authRepository.refreshToken(with: request) { result in
                switch result {
                case .success(let response):
                    completion(.success(CustomCredential(authRepository: authRepository)))
                case .failure:
                    completion(.failure(AuthenticatorError.requestRefresToken))
                }
            }
        }
    
        func didRequest(_ urlRequest: URLRequest,
                        with response: HTTPURLResponse,
                        failDueToAuthenticationError error: Error) -> Bool {
            return response.statusCode == 401
        }
    
        func isRequest(_ urlRequest: URLRequest, authenticatedWith credential: CustomCredential) -> Bool {
            return credential.authRepository.refreshToken != nil
        }
    }
    
    enum AuthenticatorError: Error {
        case noRefreshTokenStored
        case requestRefresToken
    }
    
    

    What did you expect to happen?

    The response of the refresh token request.

    What happened instead?

    When the refresh method is called and it execute the refreshToken request the request is block. No finish and no is executed.

    Alamofire Environment

    Alamofire Version: 5.4.4 with Moya 14.0.1 Dependency Manager: Swift Package Manager Xcode Version: 13.1 Swift Version: 5.5 Platform(s) Running Alamofire: iOS macOS Version Running Xcode: macOS 11.6

    Demo Project

    ℹ Please link to or upload a project we can download that reproduces the issue.

    opened by ginesdeka 0
  • Session.swift Alamofire 5.4.3 - Session.deinit

    Session.swift Alamofire 5.4.3 - Session.deinit

    The below crash has occurred only when we update 5.4.2 and 5.4.3 and we don’t get any crashes regarding session in below 5.4.1 version. I have updated the version details and code below:

    Session create:

    func sessionManager() -> Session {
      	//SSL pining
            instantiateTrustKit()
            if let manage = self.manager {
                return manage
            }
            else {
                let configuration = URLSessionConfiguration.default
                configuration.timeoutIntervalForRequest = 30
                self.manager = Session(configuration: configuration, delegate: CustomSessionDelegate())
                guard let sessionManager = manager else {
                    return Session.default
                }
                return sessionManager
            }
        }
    

    Cancel ongoing request:

    func cancelAllActiveRequests() {
            sessionManager().session.getTasksWithCompletionHandler { dataTasks, uploadTasks, downloadTasks in
                dataTasks.forEach {
                    $0.cancel() }
                uploadTasks.forEach {
                    $0.cancel() }
                downloadTasks.forEach {
                    $0.cancel() }
            }
    }

    
    

    **Crash Stack trace:**


    Crashed: com.apple.root.background-qos
    0  libobjc.A.dylib                0x25dd0 objc_release + 16
    1  Alamofire                      0xb4b90 Session.deinit + 204 (Session.swift:204)
    2  Alamofire                      0xb4c2c Session.__deallocating_deinit + 202 (Session.swift:202)
    3  libswiftCore.dylib             0x383c98 _swift_release_dealloc + 40
    4  libswiftCore.dylib             0x384b90 bool swift::HeapObjectSideTableEntry::decrementStrong<(swift::PerformDeinit)1>(unsigned int) + 288
    5  SampleApp                       0x115648 sessionManager() + 46 
    

    Alamofire version: Alamofire 5.4.3 Xcode version: Version 12.5 Swift version: 5.4 Crash occured device OS: iPhone14.5 above Crash Title: Session.swift line Crashed: com.apple.root.background-qos EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000431c70a0

    1. While sending requests we called the sessionManager function to get the current session.
    2. When the user opens the app for the first time and the user navigates to the main screen the cancel request function will be called.

    Could anyone know the above issue?

    NOTE: Can't able to reproduce this issue.

    needs investigation 
    opened by HKarthick 2
  • Add throwing support to MultipartFormData builders

    Add throwing support to MultipartFormData builders

    Problem

    When creating a multipart form data request, there is no place for custom encoding errors using Alamofire's APIs. Sometimes we need to convert images into data which can potentially return nil. In these scenarios it would be convenient to throw an error at this layer rather than wrapping AFError to use our own custom error type.

    Feature Request

    Add throws to MultipartFormData building closures on the session's upload functions. This also requires adding a case customEncodingFailed(error: Error) to MultipartEncodingFailureReason for capturing any errors that are thrown via the closure.

    Value to Alamofire

    I think this is something missing from Alamofire, as the other request / upload functions support throws via ParameterEncoder's encode function. However, there is no equivalent mechanism for MultipartFormData.

    feature request 
    opened by zzt4 0
  • Enable Manual Response Caching

    Enable Manual Response Caching

    ℹ Please fill out this template when filing a feature request. All lines beginning with an ℹ symbol instruct you with what info we expect. You can delete those lines once you've filled in the info.

    Feature requests should code examples whenever possible.

    Per our *CONTRIBUTING guidelines, we use GitHub for bugs and feature requests, not general support. Other issues should be opened on Stack Overflow with the tag alamofire.

    Please remove this line and everything above it before submitting.

    Problem

    I would like to retrieve the response returned by the webservice and modify its header before it is interpreted by the Alamofire library such as a Response Interceptor. This functionality seems to be present using a ResponseCacher to modify a response before caching it. However, if you want to modify the headers to allow the response to be cached, there is currently no solution.

    Feature Request

    Have the ability to intercept the response and modify any header. This feature is available with the OkHttp library on Android https://square.github.io/okhttp/interceptors/#rewriting-responses.

    Value to Alamofire

    As mentioned above, this would allow the behavior of the response to be changed on the client side and, for example, to be able to cache the response.

    feature request 
    opened by Alexandredenis35 7
  • Super slow uploads (10x time) on 1% packet loss connection

    Super slow uploads (10x time) on 1% packet loss connection

    I'm running two different network connections. One is over WIFI with 25MBit/s upload at 1% packet loss. One is over mobile with 24MBit/s upload at 0% packet loss. The first connection takes 10x as long to upload files to a Django server, while the mobile connection is a lot faster. This app is the only place where I'm experiencing slowdowns. I use this connection every day for everything else. As far as I can tell, Alamofire is the only part of the chain that could cause these slowdowns.

    Alamofire Environment

    Alamofire Version: 5.4.3 Dependency Manager: SPM Xcode Version: 12.5.1 Swift Version: 5 Platform(s) Running Alamofire: iOS 14.6 macOS Version Running Xcode: 11.4

    Demo Project

    ℹ Please link to or upload a project we can download that reproduces the issue.

      public static func uploadVideo(
        from url: URL, progress: ((Double) -> Void)? = nil, completion: ((String?) -> Void)?
      ) -> UploadRequest {
        let ext = url.absoluteString.split(separator: ".").last ?? ".binary"
        return AF.upload(multipartFormData: {
          $0.append(url, withName: "video", fileName: "video.\(ext)", mimeType: "application/octet-stream")
        }, to: "\(server)file_upload/")
        .uploadProgress {
          progress?($0.fractionCompleted)
        }
        .response {
          let data = $0.data ?? Data()
          let string = String(data: data, encoding: .utf8) ?? ""
          let json = JSON(parseJSON: string)
          completion?(json["url"].array?.compactMap { $0.string }.first)
        }
      }
    
    needs investigation 
    opened by yspreen 1
  • Swift Concurrency Support

    Swift Concurrency Support

    Goals :soccer:

    This PR tracks the implementation of Swift Concurrency support as an extension to Alamofire. This ensures it remains buildable on all platforms.

    Implementation Details :construction:

    Additions:

    • DataTask, which encapsulates the originating DataRequest and a Task which tracks an underlying continuation for async work. It also provides async access to the response, result, and value properties, as well as read-only access to the properties of the underlying DataRequest.
    • DownloadTask, which does the same for DownloadRequest.
    • DataStreamTask, which encapsulates a DataStreamRequest and vends AsyncStreams for the stream output. Unlike the data and download cases, this task doesn't trigger the request immediately, only once a stream has been requested.

    Testing Details :mag:

    Tests added but not yet fully passing, pending cancellation testing.

    opened by jshier 10
  • Crashed: org.alamofire.session.rootQueue EXC_BREAKPOINT 0x0000000195995fb0

    Crashed: org.alamofire.session.rootQueue EXC_BREAKPOINT 0x0000000195995fb0

    What did you do?

    ℹ Work normally.

    What happened instead?

    Crashed: org.alamofire.session.rootQueue
    0  libswiftCore.dylib             0x195995fb0 _assertionFailure(_:_:file:line:flags:) + 488
    1  libswiftFoundation.dylib       0x1958777a8 Data.InlineSlice.append(contentsOf:) + 1152
    2  libswiftFoundation.dylib       0x19587f00c Data._Representation.append(contentsOf:) + 408
    3  Alamofire                      0x1028940d4 $s9Alamofire11DataRequestC10didReceive4datay10Foundation0B0V_tF + 400
    4  Alamofire                      0x10290f500 $s9Alamofire15SessionDelegateC03urlB0_8dataTask10didReceiveySo12NSURLSessionC_So0i4DataF0C10Foundation0J0VtF + 344
    5  Alamofire                      0x10290f69c $s9Alamofire15SessionDelegateC03urlB0_8dataTask10didReceiveySo12NSURLSessionC_So0i4DataF0C10Foundation0J0VtFTo + 124
    6  CFNetwork                      0x192744838 _CFNetworkHTTPConnectionCacheSetLimit + 155056
    7  Foundation                     0x193249cc8 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
    8  Foundation                     0x193146b18 -[NSBlockOperation main] + 100
    9  Foundation                     0x19324bf80 __NSOPERATION_IS_INVOKING_MAIN__ + 20
    10 Foundation                     0x1931467d4 -[NSOperation start] + 784
    11 Foundation                     0x19324c978 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 20
    12 Foundation                     0x19324c444 __NSOQSchedule_f + 180
    13 libdispatch.dylib              0x191b9193c _dispatch_block_async_invoke2 + 104
    14 libdispatch.dylib              0x191be2280 _dispatch_client_callout + 16
    15 libdispatch.dylib              0x191b8afa8 _dispatch_lane_serial_drain$VARIANT$mp + 612
    16 libdispatch.dylib              0x191b8ba84 _dispatch_lane_invoke$VARIANT$mp + 424
    17 libdispatch.dylib              0x191b95518 _dispatch_workloop_worker_thread + 712
    18 libsystem_pthread.dylib        0x1d7d175a4 _pthread_wqthread + 272
    19 libsystem_pthread.dylib        0x1d7d1a874 start_wqthread + 8
    

    Alamofire Environment

    **Alamofire Version: 5.4.3 Dependency Manager: **Xcode Version: 12.5 **Swift Version: 5.3 **Platform(s) running Alamofire: iOS **macOS version running Xcode: macOS Big Sur 11.4

    Demo Project

    Unfortunately I haven't repeatable test case to reproduce this crash

    needs investigation 
    opened by hson252850 2
  • Add WebSocketRequest

    Add WebSocketRequest

    Goals :soccer:

    This PR tracks the addition of WebSocketRequest.

    Implementation Details :construction:

    TBD

    Testing Details :mag:

    Tests added.

    opened by jshier 1
Releases(5.4.4)
  • 5.4.4(Sep 20, 2021)

    Released on 2021-09-20. All issues associated with this milestone can be found using this filter.

    Added

    • Support for Xcode 13, including a workaround for Combine compilation on older architectures.
    • Testing on watchOS.
    • Support for building on Windows and Linux. Alamofire is unsupported on these platforms but should build correctly.

    Updated

    • Usage of .count >= 0 to !.isEmpty.

    Fixed

    Source code(tar.gz)
    Source code(zip)
  • 5.4.3(Apr 21, 2021)

  • 5.4.2(Apr 3, 2021)

    Released on 2021-04-03. All issues associated with this milestone can be found using this filter.

    Updated

    • Resume data handling for DownloadRequests to access resume data from errors as well as cancellation.
    • Project files and templates for Xcode 12.4 and GitHub templates.

    Fixed

    • MultipartUpload thread-safety.
    • Multipart body stream length handling to better handle partial streams.
    Source code(tar.gz)
    Source code(zip)
  • 5.4.1(Dec 20, 2020)

  • 5.4.0(Nov 4, 2020)

    Released on 2020-11-04. All issues associated with this milestone can be found using this filter.

    Added

    • URLResponseSerializer and attendant convenience methods so downloads can produce a non-optional URL.

    Updated

    • Handing of file:// URLs, removing error added in 5.3.0 and adding support for DownloadRequest.
    Source code(tar.gz)
    Source code(zip)
  • 5.3.0(Oct 17, 2020)

    Released on 2020-10-17. All issues associated with this milestone can be found using this filter.

    Added

    • Closure callback APIs for the production of URLRequests and URLSessionTasks.
    • URLSessionTaskMetrics gathering on watchOS 7+.

    Updated

    Fixed

    • Double lock crash in AuthenticationInterceptor caused by synchronous refresh implementations.
    • Crash when requesting file:// URLs by producing validation error.
    • Missing rethrow of error produced when writing temporary multipart files fails.
    • Objective-C module conflicts in Xcode 12 by removing Obj-C module support.
    Source code(tar.gz)
    Source code(zip)
  • 5.2.2(Jul 17, 2020)

    Released on 2020-07-17. All issues associated with this milestone can be found using this filter.

    Added

    • macOS(Catalyst) User-Agent string.

    Updated

    • debugDescription of DataRequest and DownloadRequest to better handle non-text and long content, with better formatting.
    • Code to use switch instead of if else statement.

    Fixed

    • Linking on some Apple OS versions when using Swift Package Manager.
    • Reliability issues with DataStreamRequest.
    Source code(tar.gz)
    Source code(zip)
  • 5.2.1(May 25, 2020)

  • 5.2.0(May 16, 2020)

    Released on 2020-05-16. All issues associated with this milestone can be found using this filter.

    Added

    • Combine support! DataResponsePublisher, DownloadResponsePublisher, and DataStreamPublisher to stream Alamofire responses.
    • AuthenticationInterceptor, for easier adaptation and retry of requests with credentials.

    Updated

    • Response handlers to take all serializer parameters.
    • DisabledEvaluator to DisabledTrustEvaluator, deprecating the previous name.
    • Interceptor to be initialized with multiple RequestInterceptors, in addition to RequestAdapters and RequestRetriers.

    Fixed

    • Minor documentation issues.
    • Encoding of Decimal values in URLEncodedFormEncoder.
    • Thread-safety issue in Session.
    • Memory leak in NetworkReachabilityManager.
    Source code(tar.gz)
    Source code(zip)
  • 5.1.0(Apr 4, 2020)

    Released on 2020-04-04. All issues associated with this milestone can be found using this filter.

    Added

    • RequestModifier closure to request APIs, allowing mutation of created URLRequests.
    • DataStreamRequest, for streaming HTTP responses.

    Updated

    • Various framework internals to make porting to Linux easier.
    • Project to require Swift 5.1.

    Fixed

    • Typo in ServerTrustEvaluating documentation.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.5(Mar 23, 2020)

    Released on 2020-03-23. All issues associated with this milestone can be found using this filter.

    Fixed

    • Request casting issue on retry that could lead to incomplete retry of UploadRequests.
    • Rare scenario where finish() could be called multiple times, leading to duplicate response handler calls.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.4(Mar 15, 2020)

  • 5.0.3(Mar 14, 2020)

    Released on 2020-03-14. All issues associated with this milestone can be found using this filter.

    Added

    • SwiftPM testing support.
    • Documentation around the prohibition of background URLSessionConfigurations in Alamofire 5.

    Fixed

    Source code(tar.gz)
    Source code(zip)
  • 5.0.2(Feb 23, 2020)

  • 5.0.1(Feb 23, 2020)

    Released on 2020-02-23. All issues associated with this milestone can be found using this filter.

    Updated

    • AlamofireExtension to have public properties and initializer, and conform to @dynamicMemberLookup.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0(Feb 14, 2020)

    Released on 2020-02-14. All issues associated with this milestone can be found using this filter.

    Added

    • Support for NSURLAuthenticationMethodClientCertificate when handling auth challenges using URLCredentials.
    • Migration Guide for Alamofire 5.

    Updated

    • Advanced Usage documentation for Alamofire 5.
    • AF namespace to be a reference to Session.default.

    Fixed

    • Runtime crashes due to overzealous state checking in SessionDelegate by reducing the severity of the assertions.
    • Unwanted public attribute on _URLEncodedFormEncoder.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-rc.3(Oct 26, 2019)

    Released on 2019-10-26. All issues associated with this milestone can be found using this filter. Note: Alamofire 5 is now API stable.

    Updated

    • Automatic resume() behavior to be called after the first response handler is added instead of immediately after task creation.

    Fixed

    • Incorrect header convenience method in Usage documentation.
    • Unstable parameter ordering in URLEncodedFormEncoder.
    • Xcode build issues and precompiled binary build issues by removing the dynamic bundle identifier.
    • Build warnings for deprecated SecTrust API when building for Catalyst.
    • Regression from Alamofire 4 causing Alamofire to reject NTLM and Negotiate authentication methods.
    Source code(tar.gz)
    Source code(zip)
  • 4.9.1(Oct 26, 2019)

    Released on 2019-10-26. All issues associated with this milestone can be found using this filter.

    Added

    • Support for GitHub Actions for CI.

    Updated

    • DataResponse and DownloadResponse debugDescription to include more useful information.

    Fixed

    • Dynamic bundle identifier causing issues with Xcode and precompiled binaries by removing the dynamic behavior.
    • Compiler warnings when building for Catalyst by updating the usage of deprecated API.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-rc.2(Sep 8, 2019)

    Released on 2019-09-08. All issues associated with this milestone can be found using this filter. Note: Alamofire 5 is now API stable.

    Fixed

    • Single remaining use of Error instead of generic Failure constraint in DataResponse API.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-rc.1(Sep 4, 2019)

    Released on 2019-09-04. All issues associated with this milestone can be found using this filter. Note: Alamofire 5 is now API stable.

    Added

    • cancelAllRequests method on Session to cancel all in flight requests.
    • Ability to inject FileManager instance into UploadRequest.
    • DataPreprocessor protocol and implementations, allowing the preprocessing of data before serialization.
    • Internal URLRequest validation and error. GET requests with body data will now produce an error.
    • Generic Failure constraint to DataResponse and DownloadResponse, making them DataResponse<Success, Failure: Error> and DownloadResponse<Success, Failure: Error>.
    • Precondition to ensure Session can't be used with background URLSessionConfigurations. Alamofire will explicitly support such functionality at some point in the future.
    • SwiftFormat configuration and updated styling.
    • AFDataResponse<Success> and AFDownloadResponse<Success> typealiases to help deal with the doubly generic responses.

    Updated

    • All internal Result usage to use the fully qualified type instead of AFResult.
    • DataRequest and DownloadRequest functional API, renaming flatMap to tryMap.
    • HTTPMethod to be a struct rather than an enum.
    • All errors produced by Alamofire to be AFError by default. All responses will now start with an AFError Failure type.
    • NetworkReachabilityManager to simplify and modernize its API.
    • Usage.md documentation to be fully up-to-date with Alamofire 5.
    • Bundle identifiers to include the platform name, fixing ITMS-90806.

    Fixed

    • Thread-safety issue with serialization queue usage.
    Source code(tar.gz)
    Source code(zip)
  • 4.9.0(Sep 3, 2019)

    Released on 2019-09-03. All issues associated with this milestone can be found using this filter.

    Added

    • API to cancel DownloadRequests without producing resume data.

    Updated

    • Bundle identifiers to include the platform name, fixing ITMS-90806.

    Fixed

    • NetworkReachabilityManager behavior regression from 4.8.1.
    • Memory leak when using validate().
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-beta.7(Jul 29, 2019)

    Released on 2019-07-29. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Added

    • URLEncodedFormEncoder.DataEncoding and URLEncodedFormEncoder.KeyEncoding to customize the encoding of Data and CodingKeys in URLEncodedFormEncoder.
    • Asynchronous cURLDescription method to produce cURL commands for Requests which are in the process of creating their initial URLRequest.

    Updated

    • All inline API documentation.
    • Handling of response serializers appended after a Request has completed. This no longer produces an error but will instead trigger the normal Request lifetime methods.

    Fixed

    • Empty parameters being encoded as an empty String instead of nil by URLEncodedFormEncoder.
    • Handling of os_unfair_lock to prevent rare crash.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-beta.6(Apr 23, 2019)

    Released on 2019-04-23. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Updated

    • ServerTrustEvaluation logic by simplifying public key equality checks for SecKey types.
    • Request.State access to lock access and task updates using internal locking API.

    Fixed

    • Issues in DownloadRequest where some events were being duplicated and some were missing.
    • Issue with AppStore submissions where the pre-release version in the bundle short versions string was being rejected when built with Carthage or as a submodule.
    • Issue where response serializer completions were not called when appended to a completed Request.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-beta.5(Apr 12, 2019)

    Released on 2019-04-12. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Added

    • Request.didResumeTaskNotification, Request.didSuspendTaskNotification, Request.didCancelTaskNotification, and Request.didCompleteTaskNotification notifications.
    • Separate URLSessionTask lifetime events to EventMonitor.

    Updated

    • SessionStateProvider to no longer be public and renamed the file it lives in.
    • MultipartUpload to no longer be public.
    • Request, DataRequest, UploadRequest, and DownloadRequest to longer be open, as Alamofire does not support subclassing these types.
    • Names of the notifications posted by Request to include Notification.
    • httpHeaders extensions on URLRequest, HTTPURLResponse, and URLSessionConfiguration to be headers instead.

    Fixed

    • Issue in Request where calling cancel() inside a response serializer would result in the serializer running again.
    • Issue in Session where the delegate precondition would be triggered when running with a swizzled URLSessionDelegate.
    • Compiler error in the example app.
    • Issues Request where certain lifetime events could be triggered more than once by repeatedly calling resume(), suspend(), or cancel().
    • Framework version string to be compatible with TestFlight and AppStore releases.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-beta.4(Mar 29, 2019)

    Released on 2019-03-29. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Added

    • The AlamofireExtended protocol and used it to namespace all public extensions.
    • The ability to retry requests after encountering response serialization errors.

    Updated

    • The switch and DispatchQueue logic throughout codebase to simplify usage patterns.
    • The MultipartFormData data APIs by condensing them using optional parameters.
    • The upload APIs for MultipartFormData to support custom boundaries.
    • The Xcode project, source code, SPM package, and podspec to support Swift 5 only.
    • The Alamofire Result type to be a new AFResult typealias on the new Swift.Result type in Swift 5 and removed all public extensions.

    Fixed

    • Issue in RequestInterceptor closures where callback arguments were not marked as @escaping.
    • Issue in response serializers where emptyResponseAllowed logic was not working as expected.
    Source code(tar.gz)
    Source code(zip)
  • 4.8.2(Mar 27, 2019)

  • 5.0.0-beta.3(Mar 7, 2019)

    Released on 2019-01-07. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Added

    • The EmptyResponse protocol, to allow any type to provides values to stand in for an empty response.
    • Request and response bodies to Request's debugDescription.

    Updated

    • Package.swift for Swift 5 support, moving Swift 4.2 support to [email protected].
    • Use of Array to Range in Request's default acceptableResponseCodes.
    • RetryPolicy to allow subclasses to override retry(_:, for: Session, dueTo:, completion:).
    • Alamofire's didResume notification to didFinish, which is now called when a Request finished, not when tasks resume.

    Fixed

    • Requests not finishing when their controlling Session is deinitd or invalidated.
    • Memory leak when using validate() due to reference cycle from implicit self capture when using an @autoclosure.
    • Crash when using requestDidParseAnyResponse when using ClosureEventMonitor.
    • RetryPolicy to properly conform to RequestInterceptor.
    • Typos in documentation.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-beta.2(Feb 7, 2019)

    Released on 2019-01-07. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Added

    • Support for controlling redirect behavior per Session and per Request using the RedirectHandler protocol.
    • Support for controlling cached response behavior per Session and per Request using the CachedResponseHandler protocol.
    • Support for controlling retry behavior per Session and per Request using the RequestInterceptor protocol.
    • The Adapter, Retrier, and Interceptor types to provide fine grained control of retry behavior.
    • Support for exponential backoff retry policies through the new RetryPolicy and ConnectionLostRetryPolicy types.

    Updated

    • The RequestRetrier protocol to take a RetryResult in the completion closure allowing custom retry errors to be thrown.
    • The Hashable implementation on Request to use new hash(into:) API.
    Source code(tar.gz)
    Source code(zip)
  • 4.8.1(Jan 15, 2019)

  • 5.0.0.beta.1(Dec 6, 2018)

    Released on 2018-12-06. All issues associated with this milestone can be found using this filter. Note: Alamofire will not be following semantic versioning during the beta process. There may be breaking changes until 5.0.0 is released.

    Added

    • Support for Decodable response serialization with responseDecodable.
    • Support for Brotli Content-Encoding in Alamofire's default headers.
    • HTTPHeaders type and convenience APIs.
    • Support for Encodable parameter types with JSONParameterEncoder and URLEncodedFormParameterEncoder.
    • Customizable empty reponse handling in response serializers.
    • EventMonitor protocol, to tap in to internal Alamofire lifetime events.
    • ServerTrustFailureReason to AFError.
    • Asynchronous request creation.

    Updated

    • ResponseSerializer and associated protocols' requirements and implementations.
    • RequestAdapter to allow for asynchronous adaptation.
    • SessionManager to Session, with rewritten implementation and API.
    • Request, DataRequest, UploadRequest, and DownloadRequest with rewritten implementation and API.
    • Top level request API to be inside a real AF namespace enum rather than unnecessary Alamofire. usage.

    Removed

    • Support for iOS < 10, macOS < 10.12, tvOS < 10, watchOS < 3.
    • Support for PropertyListSerialization and responsePropertyList.
    • Support for URLSessionStreamTask.
    • Closure override and customization API.
    • Timeline type, as Alamofire now gathers URLSessionTaskMetrics for every request.
    Source code(tar.gz)
    Source code(zip)
Owner
Alamofire
Elegant Networking in Swift
Alamofire
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support

Networking was born out of the necessity of having a simple networking library that doesn't have crazy programming abstractions or uses the latest rea

Nes 1.3k Nov 23, 2021
Versatile HTTP Networking in Swift

Net is a versatile HTTP networking library written in Swift. ?? Features URL / JSON / Property List Parameter Encoding Upload File / Data / Stream / M

Intelygenz 122 Oct 29, 2021
Extensible HTTP Networking for iOS

Bridge Simple Typed JSON HTTP Networking in Swift 4.0 GET GET<Dict>("http://httpbin.org/ip").execute(success: { (response) in let ip: Dict = respo

null 91 Aug 28, 2020
An elegant yet powerful iOS networking layer inspired by ActiveRecord.

Written in Swift 5 AlamoRecord is a powerful yet simple framework that eliminates the often complex networking layer that exists between your networki

Tunespeak 18 Aug 6, 2020
A networking library for Swift

Nikka Nikka is a super simple Swift HTTP networking library that comes with many extensions to make it modular and really powerful. Installation Usage

Emilien Stremsdoerfer 27 Sep 14, 2021
Declarative and Reactive Networking for Swift.

Squid Squid is a declarative and reactive networking library for Swift. Developed for Swift 5, it aims to make use of the latest language features. Th

Oliver Borchert 67 Sep 14, 2021
Robust Swift networking for web APIs

Conduit Conduit is a session-based Swift HTTP networking and auth library. Within each session, requests are sent through a serial pipeline before bei

Mindbody 50 Sep 9, 2021
A type-safe, high-level networking solution for Swift apps

What Type-safe network calls made easy Netswift offers an easy way to perform network calls in a structured and type-safe way. Why Networking in Swift

Dorian Grolaux 21 Nov 14, 2021
A delightful networking framework for iOS, macOS, watchOS, and tvOS.

AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the Foundation URL Loading System, extending t

AFNetworking 33.3k Nov 23, 2021
foursquare iOS networking library

FSNetworking foursquare's iOS networking library FSN is a small library for HTTP networking on iOS. It comprises a single class, FSNConnection, and se

Foursquare 388 Oct 26, 2021
Asynchronous socket networking library for Mac and iOS

CocoaAsyncSocket CocoaAsyncSocket provides easy-to-use and powerful asynchronous socket libraries for macOS, iOS, and tvOS. The classes are described

Robbie Hanson 12.1k Nov 19, 2021
Sherlock Holmes of the networking layer. :male_detective:

ResponseDetective is a non-intrusive framework for intercepting any outgoing requests and incoming responses between your app and your server for debu

Netguru 1.9k Nov 22, 2021
Lightweight Networking and Parsing framework made for iOS, Mac, WatchOS and tvOS.

NetworkKit A lightweight iOS, Mac and Watch OS framework that makes networking and parsing super simple. Uses the open-sourced JSONHelper with functio

Alex Telek 30 Nov 2, 2020
Type-safe networking abstraction layer that associates request type with response type.

APIKit APIKit is a type-safe networking abstraction layer that associates request type with response type. // SearchRepositoriesRequest conforms to Re

Yosuke Ishikawa 1.9k Nov 27, 2021
⚠️ Deprecated - (in favour of Networking) :cloud: Elegantly connect to a JSON api. (Alamofire + Promises + JSON Parsing)

⚠ Important Notice: Farewell ws... hello Networking ! Networking is the next generation of the ws project. Think of it as ws 2.0 built for iOS13. It u

Fresh 356 Oct 21, 2021
SWNetworking - Powerful high-level iOS, macOS and tvOS networking library.

SWNetworking SkyWite is an open-source and highly versatile multi-purpose frameworks. Clean code and sleek features make SkyWite an ideal choice. Powe

SkyWite 23 Jun 22, 2021
Restofire is a protocol oriented networking client for Alamofire

Restofire is a protocol oriented networking client for Alamofire. Features Requirements Installation Usage License Features Global Configuration for h

Restofire 381 Nov 11, 2021
Bonjour networking for discovery and connection between iOS, macOS and tvOS devices.

Merhaba Bonjour networking for discovery and connection between iOS, macOS and tvOS devices. Features Creating Service Start & Stop Service Stop Brows

Abdullah Selek 60 Sep 28, 2021
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.

A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications. ?? TermiNetwork was tested in a produc

Bill Panagiotopoulos 75 Oct 29, 2021