Swiftpack.co - Package - AFNetworking/AFNetworking

AFNetworking

Build Status CocoaPods Compatible Carthage Compatible Platform Twitter

AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the Foundation URL Loading System, extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.

Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.

How To Get Started

Communication

  • If you need help, use Stack Overflow. (Tag 'afnetworking')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, and can provide steps to reliably reproduce it, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

AFNetworking supports multiple methods for installing the library in a project.

Installation with CocoaPods

To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'AFNetworking', '~> 4.0'

Installation with Swift Package Manager

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

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

Note: AFNetworking's Swift package does not include it's UIKit extensions.

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AFNetworking, add the following to your Cartfile.

github "AFNetworking/AFNetworking" ~> 4.0

Requirements

| AFNetworking Version | Minimum iOS Target | Minimum macOS Target | Minimum watchOS Target | Minimum tvOS Target | Notes | |:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| | 4.x | iOS 9 | macOS 10.10 | watchOS 2.0 | tvOS 9.0 | Xcode 11+ is required. | | 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. NSURLConnectionOperation support has been removed. | | 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. | | 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. NSURLSession subspec requires iOS 7 or OS X 10.9. | | 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a | | 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a |

(macOS projects must support 64-bit with modern Cocoa runtime).

Programming in Swift? Try Alamofire for a more conventional set of APIs.

Architecture

NSURLSession

  • AFURLSessionManager
  • AFHTTPSessionManager

Serialization

  • <AFURLRequestSerialization>
    • AFHTTPRequestSerializer
    • AFJSONRequestSerializer
    • AFPropertyListRequestSerializer
  • <AFURLResponseSerialization>
    • AFHTTPResponseSerializer
    • AFJSONResponseSerializer
    • AFXMLParserResponseSerializer
    • AFXMLDocumentResponseSerializer (macOS)
    • AFPropertyListResponseSerializer
    • AFImageResponseSerializer
    • AFCompoundResponseSerializer

Additional Functionality

  • AFSecurityPolicy
  • AFNetworkReachabilityManager

Usage

AFURLSessionManager

AFURLSessionManager creates and manages an NSURLSession object based on a specified NSURLSessionConfiguration object, which conforms to <NSURLSessionTaskDelegate>, <NSURLSessionDataDelegate>, <NSURLSessionDownloadDelegate>, and <NSURLSessionDelegate>.

Creating a Download Task

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];

NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
    NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
    return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
    NSLog(@"File downloaded to: %@", filePath);
}];
[downloadTask resume];

Creating an Upload Task

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];

NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"Success: %@ %@", response, responseObject);
    }
}];
[uploadTask resume];

Creating an Upload Task for a Multi-Part Request, with Progress

NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
    } error:nil];

AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];

NSURLSessionUploadTask *uploadTask;
uploadTask = [manager
              uploadTaskWithStreamedRequest:request
              progress:^(NSProgress * _Nonnull uploadProgress) {
                  // This is not called back on the main queue.
                  // You are responsible for dispatching to the main queue for UI updates
                  dispatch_async(dispatch_get_main_queue(), ^{
                      //Update the progress view
                      [progressView setProgress:uploadProgress.fractionCompleted];
                  });
              }
              completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
                  if (error) {
                      NSLog(@"Error: %@", error);
                  } else {
                      NSLog(@"%@ %@", response, responseObject);
                  }
              }];

[uploadTask resume];

Creating a Data Task

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];

NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error);
    } else {
        NSLog(@"%@ %@", response, responseObject);
    }
}];
[dataTask resume];

Request Serialization

Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body.

NSString *URLString = @"http://example.com";
NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]};

Query String Parameter Encoding

[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil];
GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3

URL Form Parameter Encoding

[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
POST http://example.com/
Content-Type: application/x-www-form-urlencoded

foo=bar&baz[]=1&baz[]=2&baz[]=3

JSON Parameter Encoding

[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
POST http://example.com/
Content-Type: application/json

{"foo": "bar", "baz": [1,2,3]}

Network Reachability Manager

AFNetworkReachabilityManager monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.

  • Do not use Reachability to determine if the original request should be sent.
    • You should try to send it.
  • You can use Reachability to determine when a request should be automatically retried.
    • Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something.
  • Network reachability is a useful tool for determining why a request might have failed.
    • After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out."

See also WWDC 2012 session 706, "Networking Best Practices.".

Shared Network Reachability

[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
    NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
}];

[[AFNetworkReachabilityManager sharedManager] startMonitoring];

Security Policy

AFSecurityPolicy evaluates server trust against pinned X.509 certificates and public keys over secure connections.

Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.

Allowing Invalid SSL Certificates

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production

Unit Tests

AFNetworking includes a suite of unit tests within the Tests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test.

Credits

AFNetworking is owned and maintained by the Alamofire Software Foundation.

AFNetworking was originally created by Scott Raymond and Mattt Thompson in the development of Gowalla for iPhone.

AFNetworking's logo was designed by Alan Defibaugh.

And most of all, thanks to AFNetworking's growing list of contributors.

Security Disclosure

If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker.

License

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

Github

link
Stars: 32897

Dependencies

Used By

Total: 1

Releases

Fixes and Updates - 2020-04-20 02:22:29

Released on Sunday, April 19, 2020. All issues associated with this milestone can be found using this filter.

Updated

  • Project templates and integrations.
    • Implemented by Kaspik in #4531.
  • Various CocoaPods podspec settings.

Fixed

  • Crash during authentication delegate method.
  • SPM integration.
    • Implemented by jshier in #4554.
  • Improper update instead of replacement of header values.
    • Implemented by ElfSundae in #4550.
  • Nullability of some methods.
    • Implemented by ElfSundae in #4551.
  • Typos in CHANGELOG.
    • Implemented by ElfSundae in #4537.
  • Missing tvOS compatibility for some methods.
    • Implemented by ElfSundae in #4536.
  • Missing FOUNDATION_EXPORT for AFJSONObjectByRemovingKeysWithNullValues.
    • Implemented by ElfSundae in #4529.

Removed

  • Unused UIImage+AFNetworking.h file.
    • Implemented by ElfSundae in #4535.

A Long Time Coming - 2020-03-29 20:49:55

Released on Sunday, March 29, 2020. All issues associated with this milestone can be found using this filter.

Added

  • Notificate when a downloaded file has been moved successfully.
    • Implemented by xingheng in #4393.
  • Specific error for certificate pinning failure.
    • Implemented by 0xced in #3425.
  • WKWebView extensions.
    • Implemented by tjanela in #4439.
  • Automatic location of certificates in the main bundle for certificate pinning.
    • Implemented by 0xced in #3752.
  • User-Agent support for tvOS.
    • Implemented by ghking in #4014.
  • Ability for AFHTTPSessionManager to recreate its underlying NSURLSession.
    • Implemented by Kaspik in #4256.
  • Ability to set HTTP headers per request.
    • Implemented by stnslw in #4113.
  • Ability to capture NSURLSessionTaskMetrics.
    • Implemented by Caelink in #4237.

Updated

  • dataTaskWithHTTPMethod to be public.
    • Implemented by smartinspereira in #4007.
  • Reachability notification to include the instance which issued the notification.
    • Implemented by LMsgSendNilSelf in #4051.
  • AFJSONObjectByRemovingKeysWithNullValues to be public.
    • Implemented by ashfurrow in #4051.
  • AFJSONObjectByRemovingKeysWithNullValues to remove NSNull values from NSArrays.
    • Implemented by ashfurrow in #4052.

Changed

  • Automated CI to GitHub Actions.
    • Implemented by jshier in #4523.

Fixed

  • Explicit NSSecureCoding support.
    • Implemented by jshier in #4523.
  • Deprecated API usage on Catalyst.
    • Implemented by jshier in #4523.
  • Nullability annotations.
    • Implemented by jshier in #4523.
  • AFImageDownloader to more accurately cancel downloads.
    • Implemented by kinarobin in #4407.
  • Double KVO notifications in AFNetworkActivityManager.
    • Implemented by kinarobin in #4406.
  • Availability annotations around NSURLSessionTaskMetrics.
    • Implemented by ElfSundae in #4516.
  • Issues with associated_object and subclasses.
    • Implemented by welcommand in #3872.
  • Memory leak in example application.
    • Implemented by svoit in #4196.
  • Crashes in mulithreaded scenarios and dispatch_barrier.
    • Implemetned by streeter in #4474.
  • Issues with NSSecureCoding.
    • Implemented by ElfSudae in #4409.
  • Code style issues.
    • Implemented by svoit in #4200.
  • Race condition in AFImageDownloader.
    • Implemented by bbeversdorf in #4246.
  • Coding style issues.
    • Implemented by LeeHongHwa in #4002.

Removed

  • Support for iOS < 9, macOS < 10.10.
    • Implemented by jshier in #4523.
  • All previously deprecated APIs.
    • Implemented by jshier in #4523.
  • Unnecessary __block capture.
    • Implemented by kinarobin in #4526.
  • Workaround for NSURLSessionUploadTask creation on iOS 7.
    • Implemented by kinarobin in #4525.
  • Workaround for safe NSURLSessionTask creation on iOS < 8.
    • Implemented by kinarobin in #4401.
  • UIWebView extensions.
    • Implemented by tjanela in #4439.

2.7.0 - 2019-02-13 04:48:47

Released on Tuesday, February 12, 2019. All issues associated with this milestone can be found using this filter.

Fixed

  • Update Podfile to work on modern CocoaPods
  • Add nullability specifiers to all id responseObject parameters
  • Fix empty content crash on AFHTTPSessionManager.post

3.2.1 - 2018-05-04 17:00:42

Released on Friday, May 04, 2018. All issues associated with this milestone can be found using this filter.

Updated

  • Xcode 9.3 Support
    • Implemented by Jeff Kelley in #4199.
  • Update HTTPBin certificates for April 2018.
    • Implemented by Jeff Kelley in #4198.

Additional Changes

  • Remove conflicting nullable specifier on init
    • Implemented by Nick Brook and Jeff Kelley in #4182.
  • Use @available if available to silence a warning.
    • Implemented by Jeff Kelley in #4138.
  • UIImageView+AFNetworking: Prevent stuck state for malformed urlRequest
    • Implemented by Adam Duflo and aduflo in #4131.
  • add the link for LICENSE
    • Implemented by Liao Malin in #4125.
  • Fix analyzer warning for upload task creation
    • Implemented by Jeff Kelley in #4122.

3.2.0 - 2017-12-15 21:11:57

Released on Friday, December 15, 2017. All issues associated with this milestone can be found using this filter.

Added

  • Config AFImageDownloader NSURLCache and ask AFImageRequestCache implementer if an image should be cached
    • Implemented by wjehenddher in #4010.
  • Add XMLParser/XMLDocument serializer tests
    • Implemented by skyline75489 in #3753.
  • Enable custom httpbin URL with HTTPBIN_BASE_URL environment variable
    • Implemented by 0xced in #3748.
  • AFHTTPSessionManager now throws exception if SSL pinning mode is set for non https sessions
    • Implemented by 0xced in #3687.

Updated

  • Update security policy test certificates
    • Implemented by SlaunchaMan in #4103.
  • Allow return value of HTTP redirection block to be NULL
    • Implemented by TheDom in #3975.
  • Clarify documentation for supported encodings in AFJSONResponseSerializer
    • Implemented by skyline75489 in #3750.
  • Handle Error Pointers according to Cocoa Convention
    • Implemented by tclementdev in #3653.
  • Updates AFHTTPSessionManager documentation to reflect v3.x change
    • Implemented by ecaselles in #3476.
  • Improved code base to generate fewer warnings when using stricter compiler settings
    • Implemented by 0xced in 3431.

Changed

  • Change “Mac OS X” and “OS X” references to “macOS”
    • Implemented by SlaunchaMan in #4104.

Fixed

  • Fixed crash around customizing NSURLCache size for < iOS 8.2
    • Implemented by kcharwood in #3735.
  • Fixed issue where UIWebView extension did not preserve all of the request information
    • Implemented by skyline75489 in #3733.
  • Fixed bug with webview delegate callback
    • Implemented by kcharwood in #3727.
  • Fixed crash when passing invalid JSON to request serialization
    • Implemented by 0xced in #3719.
  • Fixed potential KVO crasher for URL Session Task delegates
    • Implemented by 0xced in #3718.
  • Removed ambiguous array creation in AFSecurityPolicy
    • Implemented by sgl0v in #3679.
  • Fixed issue where NS_UNAVAILABLE is not reported for AFNetworkReachabilityManager
    • Implemented by Microbee23 in #3649.
  • Require app extension api only on watchOS
    • Implemented by ethansinjin in #3612.
  • Remove KVO of progress in favor of using the NSURLSession delegate APIs
    • Implemented by coreyfloyd in #3607.
  • Fixed an issue where registering a UIProgessView to a task that was causing a crash
    • Implemented by Starscream27 in #3604.
  • Moved [self didChangeValueForKey:@"currentState"] into correct scope
    • Implemented by chenxin0123 in #3565.
  • Fixed issue where response serializers did not inherit super class copying
    • Implemented by kcharwood in #3559.
  • Fixed crashes due to race conditions with NSMutableDictionary access in AFHTTPRequestSerializer
    • Implemented by alexbird in #3526.
  • Updated dash character to improve markdown parsing for license
    • Implemented by gemmakbarlow in #3488.

Removed

  • Deprecate the unused stringEncoding property of AFHTTPResponseSerializer
    • Implemented by 0xced in #3751.
  • Removed unused AFTaskStateChangedContext
    • Implemented by yulingtianxia in #3432.

3.1.0 - 2016-03-31 17:28:58

Released on Thursday, March 31, 2016. All issues associated with this milestone can be found using this filter.

Added

  • Improved AFImageResponseSerializer test coverage
    • Implemented by quellish in #3367.
  • Exposed AFQueryStringFromParameters and AFPercentEscapedStringFromString for public use.
    • Implemented by Kevin Harwood in #3160.

Updated

  • Updated Test Suite to run on Xcode 7.3
    • Implemented by Kevin Harwood in #3418.
  • Added white space to URLs in code comment to allow Xcode to properly parse them
    • Implemented by Draveness in #3384.
  • Updated documentation to match method names and correct compiler warnings
    • Implemented by Hakon Hanesand in #3369.
  • Use NSKeyValueChangeNewKey constant in change dictionary rather than hardcoded string.
    • Implemented by Wenbin Zhang in #3360.
  • Resolved compiler warnings for documentation errors
    • Implemented by Ricardo Santos in #3336.

Changed

  • Reverted NSURLSessionAuthChallengeDisposition to NSURLSessionAuthChallengeCancelAuthenticationChallenge for SSL Pinning
    • Implemented by Kevin Harwood in #3417.

Fixed

  • Removed trailing question mark in query string if parameters are empty
    • Implemented by Kevin Harwood in #3386.
  • Fixed crash if bad URL was passed into the image downloader
    • Implemented by Christian Wen and Kevin Harwood in #3385.
  • Fixed image memory calculation
    • Implemented by 周明宇 in #3344.
  • Fixed issue where UIButton image downloading called wrong cancel method
    • Implemented by duanhong in #3332.
  • Fixed image downloading cancellation race condition
    • Implemented by Kevin Harwood in #3325.
  • Fixed static analyzer warnings on AFNetworkReachabilityManager
    • Implemented by Jeff Kelley in #3315.
  • Fixed issue where download progress would not be reported in iOS 7
    • Implemented by zwm in #3294.
  • Fixed status code 204/205 handling
    • Implemented by Kevin Harwood in #3292.
  • Fixed crash when passing nil/null for progress in UIWebView extension
    • Implemented by Kevin Harwood in #3289.

Removed

  • Removed workaround for NSJSONSerialization bug that was fixed in iOS 7
    • Implemented by Cédric Luthi in #3253.

3.0.4 - 2015-12-18 19:20:52

Released on Friday, December 18, 2015. All issues associated with this milestone can be found using this filter.

Fixed

  • Fixed issue where AFNSURLSessionTaskDidResumeNotification was removed twice
    • Implemented by Kevin Harwood in #3236.

3.0.3 - 2015-12-16 20:20:26

Released on Wednesday, December 16, 2015. All issues associated with this milestone can be found using this filter.

Added

  • Added tests for response serializers to increase test coverage
    • Implemented by Kevin Harwood in #3233.

Fixed

  • Fixed AFImageResponseSerializer serialization macros on watchOS and tvOS
    • Implemented by Charles Joseph in #3229.

3.0.2 - 2015-12-14 21:08:36

Released on Monday, December 14, 2015. All issues associated with this milestone can be found using this filter.

Fixed

  • Fixed a crash in AFURLSessionManager when resuming download tasks
    • Implemented by Chongyu Zhu in #3222.
  • Fixed issue where background button image would not be updated
    • Implemented by eofs in #3220.

3.0.1 - 2015-12-11 21:29:07

Released on Friday, December 11, 2015. All issues associated with this milestone can be found using this filter.

Added

  • Added Xcode 7.2 support to Travis
    • Implemented by Kevin Harwood in #3216.

Fixed

  • Fixed race condition with ImageView/Button image downloading when starting/cancelling/starting the same request
    • Implemented by Kevin Harwood in #3215.

3.0.0 - 2015-12-10 20:24:32

Released on Thursday, December 10, 2015. All issues associated with this milestone can be found using this filter.

Migration

For detailed information about migrating to AFNetworking 3.0.0, please reference the migration guide.

Changes

Added

  • Added support for older versions of Xcode to Travis
    • Implemented by Kevin Harwood in #3209.
  • Added support for Codecov.io
    • Implemented by Cédric Luthi and Kevin Harwood in #3196.
  • Added support for IPv6 to Reachability
    • Implemented by SAMUKEI and Kevin Harwood in #3174.
  • Added support for Objective-C light weight generics
    • Implemented by Kevin Harwood in #3166.
  • Added nullability attributes to response object in success block
    • Implemented by Nathan Racklyeft in #3154.
  • Migrated to Fastlane for CI and Deployment
    • Implemented by Kevin Harwood in #3148.
  • Added support for tvOS
    • Implemented by Kevin Harwood in #3128.
  • New image downloading architecture
    • Implemented by Kevin Harwood in #3122.
  • Added Carthage Support
    • Implemented by Kevin Harwood in #3121.
  • Added a method to create a unique reachability manager
    • Implemented by Mo Bitar in #3111.
  • Added a initial delay to the network indicator per the Apple HIG
    • Implemented by Kevin Harwood in #3094.

Updated

  • Improved testing reliability for continuous integration
    • Implemented by Kevin Harwood in #3124.
  • Example project now consumes AFNetworking as a library.
    • Implemented by Kevin Harwood in #3068.
  • Migrated to using instancetype where applicable
    • Implemented by Kyle Fuller in #3064.
  • Tweaks to project to support Framework Project
    • Implemented by Christian Noon in #3062.

Changed

  • Split the iOS and OS X AppDelegate classes in the Example Project
    • Implemented by Cédric Luthi in #3193.
  • Changed SSL Pinning Error to be NSURLErrorServerCertificateUntrusted
    • Implemented by Cédric Luthi and Kevin Harwood in #3191.
  • New Progress Reporting API using NSProgress
    • Implemented by Kevin Harwood in #3187.
  • Changed pinnedCertificates type in AFSecurityPolicy from NSArray to NSSet
    • Implemented by Cédric Luthi in #3164.

Fixed

  • Improved task creation performance for iOS 8+
    • Implemented by nikitahils, Nikita G and Kevin Harwood in #3208.
  • Fixed certificate validation for servers providing incomplete chains
    • Implemented by André Pacheco Neves in #3159.
  • Fixed bug in AFMultipartBodyStream that may cause the input stream to read more bytes than required.
    • Implemented by bang in #3153.
  • Fixed race condition crash from Resume/Suspend task notifications
    • Implemented by Kevin Harwood in #3152.
  • Fixed AFImageDownloader stalling after numerous failures
    • Implemented by Rick Silva in #3150.
  • Fixed warnings generated in UIWebView category
    • Implemented by Kevin Harwood in #3126.

Removed

  • Removed AFBase64EncodedStringFromString static function
    • Implemented by Cédric Luthi in #3188.
  • Removed code supporting conditional compilation for unsupported development configurations.
    • Implemented by Cédric Luthi in #3177.
  • Removed deprecated methods, properties, and notifications from AFN 2.x
    • Implemented by Kevin Harwood in #3168.
  • Removed support for NSURLConnection
    • Implemented by Kevin Harwood in #3120.
  • Removed UIAlertView category support since it is now deprecated
    • Implemented by Kevin Harwood in #3034.

3.0.0-beta.3 - 2015-12-04 20:53:32

Build Statuscodecov.io

For detailed information about migrating to AFNetworking 3.0.0, please reference the migration guide. All 3.0.0 beta changes will be tracked with this filter.

Release Notes

Beta 3 introduces API changes for tracking NSProgress. Feedback from the community is welcome as the 3.0.0 release will soon be finalized. Please provide feedback in #3187.

The following changes have been made since 3.0.0-beta.2:

Added

  • Added support for Codecov.io
    • Implemented by Cédric Luthi and Kevin Harwood in #3196.
    • Please help us increase overall coverage by submitting a pull request!
  • Added support for IPv6 to Reachability
    • Implemented by SAMUKEI and Kevin Harwood in #3174.
  • Added support for Objective-C light weight generics
    • Implemented by Kevin Harwood in #3166.
  • Added nullability attributes to response object in success block
    • Implemented by Nathan Racklyeft in #3154.

Changed

  • Split the iOS and OS X AppDelegate classes in the Example Project
    • Implemented by Cédric Luthi in #3193.
  • Changed SSL Pinning Error to be NSURLErrorServerCertificateUntrusted
    • Implemented by Cédric Luthi and Kevin Harwood in #3191.
  • New Progress Reporting API using NSProgress
    • Implemented by Kevin Harwood in #3187.
  • Changed pinnedCertificates type in AFSecurityPolicy from NSArray to NSSet
    • Implemented by Cédric Luthi in #3164.

Fixed

  • Fixed certificate validation for servers providing incomplete chains
    • Implemented by André Pacheco Neves in #3159.
  • Fixed bug in AFMultipartBodyStream that may cause the input stream to read more bytes than required.
    • Implemented by bang in #3153.

Removed

  • Removed AFBase64EncodedStringFromString static function
    • Implemented by Cédric Luthi in #3188.
  • Removed code supporting conditional compilation for unsupported development configurations.
    • Implemented by Cédric Luthi in #3177.
  • Removed deprecated methods, properties, and notifications from AFN 2.x
    • Implemented by Kevin Harwood in #3168.

3.0.0-beta.2 - 2015-11-13 19:53:13

Build Status

For detailed information about migrating to AFNetworking 3.0.0, please reference the migration guide. All 3.0.0 beta changes will be tracked with this filter.

In addition to all the relevant changes from 2.6.2 and 2.6.3, the following changes have been made since 3.0.0-beta.1:

Added

  • Added nullability attributes to response object in success block
  • Migrated to Fastlane for CI and Deployment
  • Added a method to create a unique reachability manager
  • Added a initial delay to the network indicator per the Apple HIG

Updated

  • Improved testing reliability for continuous integration

Fixed

  • Fixed certificate validation for servers providing incomplete chains
  • Fixed bug in AFMultipartBodyStream that may cause the input stream to read more bytes than required.
  • Fixed race condition crash from Resume/Suspend task notifications
  • Fixed AFImageDownloader stalling after numerous failures
  • Fixed warnings generated in UIWebView category

2.6.3 - 2015-11-11 15:01:02

Released on Wednesday, November 11, 2015. All issues associated with this milestone can be found using this filter.

Fixed

  • Fixed clang analyzer warning suppression that prevented building under some project configurations
  • Restored Xcode 6 compatibility

2.6.2 - 2015-11-06 20:13:57

Released on Friday, November 06, 2015. All issues associated with this milestone can be found using this filter.

Important Upgrade Note for Swift

  • #3130 fixes a swift interop error that does have a breaking API change if you are using Swift. This was identified after 2.6.2 was released. It changes the method from throws to an error pointer, since that method does return an object and also handles an error pointer, which does not play nicely with the Swift/Objective-C error conversion. See #2810 for additional notes. This affects AFURLRequestionSerializer and AFURLResponseSerializer.

Added

Updated

  • Updated travis to run on 7.1
  • Simplifications of if and return statements in AFSecurityPolicy

Fixed

  • Fixed swift interop issue that prevented returning a nil NSURL for a download task
  • Suppressed false positive memory leak warning in Reachability Manager
  • Fixed swift interop issue with throws and Request/Response serialization
  • Fixed race condition in reachability callback delivery
  • Fixed URLs that were redirecting in the README
  • Fixed Project Warnings
  • Fixed README link to WWDC session
  • Switched from OS_OBJECT_HAVE_OBJC_SUPPORT to OS_OBJECT_USE_OBJC for watchOS 2 support.
  • Added missing __nullable attributes to failure blocks in AFHTTPRequestOperationManager and AFHTTPSessionManager
  • Fixed memory leak in NSURLSession handling

3.0.0-beta.1 - 2015-10-16 19:55:48

Build Status For detailed information about migrating to AFNetworking 3.0.0, please reference the migration guide. All future 3.0.0 beta changes will be tracked with this filter.

New

  • AFNetworking relies exclusively on NSURLSession. All NSURLConnection support has been removed from AFNetworking.
  • AFNetworking now supports installation through Carthage.
  • All UIKit categories are now build on NSURLSession.
  • Image downloading has been rebuilt using the image downloading architecture from AlamofireImage.
  • AFNetworking now supports tvOS and Xcode 7.1
  • Example project has been refactored to include support for all supported platforms.
  • Test targets have been completely refactored
  • Many other minor improvements.

The full changelog will be available for the final 3.0.0 release.

2.6.1 - 2015-10-13 19:28:26

Future Compatibility Note Note that AFNetworking 3.0 will soon be released, and will drop support for all NSURLConnection based API's (AFHTTPRequestOperationManager, AFHTTPRequestOperation, and AFURLConnectionOperation. If you have not already migrated to NSURLSession based API's, please do so soon. For more information, please see the 3.0 migration guide.

Fixed

  • Fixed a bug that prevented empty x-www-form-urlencoded bodies.
  • Fixed bug that prevented AFNetworking from being installed for watchOS via CocoaPods.
  • Added missing nullable attributes to AFURLRequestSerialization and AFURLSessionManager.
  • Migrated to OS_OBJECT_USE_OBJC.
  • Added missing nullable tags to UIKit extensions.
  • Fixed potential infinite recursion loop if multiple versions of AFNetworking are loaded in a target.
  • Updated Travis CI test script
  • Migrated to FOUNDATION_EXPORT from extern.
  • Fixed issue where AFURLConnectionOperation could get stuck in an infinite loop.
  • Fixed regression where URL request serialization would crash on iOS 8 for long URLs.

2.6.0 - 2015-08-19 15:32:01

2.6.0 (08-18-2015) Released on Tuesday, August 18th, 2015. All issues associated with this milestone can be found using this filter.

Important Upgrade Notes Please note the following API/project changes have been made:

  • iOS 6 support has now been removed from the podspec. Note that iOS 6 support has not been removed explicitly from the project, but it will be removed in a future update.
  • Full Certificate Chain Validation has been removed from AFSecurityPolicy. As discussed in #2744, there was no documented security advantage to pinning against an entire certificate chain. If you were using full certificate chain, please determine and select the most ideal certificate in your chain to pin against.
  • The request url will now be returned by the UIImageView category if the image is returned from cache. In previous releases, both the request and the response were nil. Going forward, only the response will be nil.
  • Support for App Extension Targets is now baked in using NS_EXTENSION_UNAVAILABLE_IOS. You no longer need to define AF_APP_EXTENSIONS in order to include code in a extension target.
  • This release now supports watchOS 2.0, which relys on target conditionals that are only present in Xcode 7 and iOS 9/watchOS 2.0/OS X 10.10. If you install the library using CocoaPods, AFNetworking will define these target conditionals for on older platforms, allowing your code to complile. If you do not use Cocoapods, you will need to add the following code your to PCH file.
#ifndef TARGET_OS_IOS
  #define TARGET_OS_IOS TARGET_OS_IPHONE
#endif
#ifndef TARGET_OS_WATCH
  #define TARGET_OS_WATCH 0
#endif
  • This release migrates query parameter serialization to model AlamoFire and adhere to RFC standards. Note that / and ? are no longer encoded by default.

Note that support for NSURLConnection based API's will be removed in a future update. If you have not already done so, it is recommended that you transition to the NSURLSession APIs in the very near future.

Added

Fixed

  • Fixed a crash related for objects that observe notifications but don't properly unregister.
  • Fixed a race condition crash that occured with AFImageResponseSerialization.
  • Fixed an issue where tests failed to run on CI due to unavailable simulators.
  • Fixed "method override not found" warnings in Xcode 7 Betas
  • Removed Duplicate Import and UIKit Header file.
  • Removed the ability to include duplicate certificates in the pinned certificate chain.
  • Fixed potential memory leak in AFNetworkReachabilityManager.

Documentation Improvements

  • Clarified best practices for Reachability per Apple recommendations.
  • Added startMonitoring call to the Reachability section of the README
  • Fixed documentation error around how baseURL is used for reachability monitoring.
  • Numerous spelling corrections in the documentation.

2.5.4 - 2015-05-14 19:18:44

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

Updated

  • Updated the CI test script to run iOS tests on all versions of iOS that are installed on the build machine.

Fixed

  • Fixed an issue where AFNSURLSessionTaskDidResumeNotification and AFNSURLSessionTaskDidSuspendNotification were not being properly called due to implementation differences in NSURLSessionTask in iOS 7 and iOS 8, which also affects the AFNetworkActivityIndicatorManager.
  • Fixed an issue where the OS X test linker would throw a warning during tests.
  • Fixed an issue where tests would randomly fail due to mocked objects not being cleaned up.

AFNetworking 2.5.3 - 2015-04-20 13:42:40

  • Add security policy tests for default policy
  • Add network reachability tests
  • Change validatesDomainName property to default to YES under all security policies
  • Fix NSURLSession subspec compatibility with iOS 6 / OS X 10.8
  • Fix leak of data task used in NSURLSession swizzling
  • Fix leak for observers from addObserver:...:withBlock:
  • Fix issue with network reachability observation on domain name

AFNetworking 2.5.2 - 2015-03-26 22:17:48

  • Add guards for unsupported features in iOS 8 App Extensions
  • Add missing delegate callbacks to UIWebView category
  • Add test and implementation of strict default certificate validation
  • Add #define for NS_DESIGNATED_INITIALIZER for unsupported versions of Xcode
  • Fix AFNetworkActivityIndicatorManager for iOS 7
  • Fix AFURLRequestSerialization property observation
  • Fix testUploadTasksProgressBecomesPartOfCurrentProgress
  • Fix warnings from Xcode 6.3 Beta
  • Fix AFImageWithDataAtScale handling of animated images
  • Remove AFNetworkReachabilityAssociation enumeration
  • Update to conditional use assign semantics for GCD properties based on OS_OBJECT_HAVE_OBJC_SUPPORT for better Swift support

AFNetworking 2.5.1 - 2015-03-26 22:17:31

  • Add NS_DESIGNATED_INITIALIZER macros. (Samir Guerdah)
  • Fix and clarify documentation for stringEncoding property. (Mattt Thompson)
  • Fix for NSProgress bug where two child NSProgress instances are added to a parent NSProgress. (Edward Povazan)
  • Fix incorrect file names in headers. (Steven Fisher)
  • Fix KVO issue when running testing target caused by lack of automaticallyNotifiesObserversForKey: implementation. (Mattt Thompson)
  • Fix use of variable arguments for UIAlertView category. (Kenta Tokumoto)
  • Fix genstrings warning for NSLocalizedString usage in UIAlertView+AFNetworking. (Adar Porat)
  • Fix NSURLSessionManager task observation for network activity indicator manager. (Phil Tang)
  • Fix UIButton category method caching of background image (Fernanda G. Geraissate)
  • Fix UIButton category method failure handling. (Maxim Zabelin)
  • Update multipart upload method requirements to ensure request.HTTPBody is non-nil. (Mattt Thompson)
  • Update to use builtin __Require macros from AssertMacros.h. (Cédric Luthi)
  • Update parameters parameter to accept id for custom serialization block. (@mooosu)

AFNetworking 2.5.0 - 2014-11-18 11:39:59

  • Add documentation for expected background session manager usage (Aaron Brager)
  • Add missing documentation for AFJSONRequestSerializer and AFPropertyListSerializer (Mattt Thompson)
  • Add tests for requesting HTTPS endpoints (Mattt Thompson)
  • Add init method declarations of AFURLResponseSerialization classes for Swift compatibility (Allen Rohner)
  • Change default User-Agent to use the version number instead of the build number (Tim Watson)
  • Change validatesDomainName to readonly property (Mattt Thompson, Brian King)
  • Fix checks when observing AFHTTPRequestSerializerObservedKeyPaths (Jacek Suliga)
  • Fix crash caused by attempting to set nil NSURLResponse -URL as key for userInfo dictionary (Elvis Nuñez)
  • Fix crash for multipart streaming requests in XPC services (Mattt Thompson)
  • Fix minor aspects of response serializer documentation (Mattt Thompson)
  • Fix potential race condition for AFURLConnectionOperation -description
  • Fix widespread crash related to key-value observing of NSURLSessionTask -state (Phil Tang)
  • Fix UIButton category associated object keys (Kristian Bauer, Mattt Thompson)
  • Remove charset parameter from Content-Type HTTP header field values for AFJSONRequestSerializer and AFPropertyListSerializer (Mattt Thompson)
  • Update CocoaDocs color scheme (@Orta)
  • Update Podfile to explicitly define sources (Kyle Fuller)
  • Update to relay downloadFileURL to the delegate if the manager picks a fileURL (Brian King)
  • Update AFSSLPinningModeNone to not validate domain name (Brian King)
  • Update UIButton category to cache images in sharedImageCache (John Bushnell)
  • Update UIRefreshControl category to set control state to current state of request (Elvis Nuñez)

AFNetworking 2.4.1 - 2014-09-04 17:47:39

  • Fix compiler warning generated on 32-bit architectures (John C. Daub)
  • Fix potential crash caused by failed validation with nil responseData (Mattt Thompson)
  • Fix to suppress compiler warnings for out-of-range enumerated type value assignment (Mattt Thompson)

AFNetworking 2.4.0 - 2014-09-03 20:24:32

  • Add CocoaDocs color scheme (Orta)
  • Add image cache to UIButton category (Kristian Bauer, Mattt Thompson)
  • Add test for success block on 204 response (Mattt Thompson)
  • Add tests for encodable and re-encodable query string parameters (Mattt Thompson)
  • Add AFHTTPRequestSerializer -valueForHTTPHeaderField: (Kyle Fuller)
  • Add AFNetworkingOperationFailingURLResponseDataErrorKey key to user info of serialization error (Yannick Heinrich)
  • Add imageResponseSerializer property to UIButton category (Kristian Bauer, Mattt Thompson)
  • Add removesKeysWithNullValues setting to serialization and copying (Jon Shier)
  • Change request and response serialization tests to be factored out into separate files (Mattt Thompson)
  • Change signature of success parameters in UIButton category methods to match those in UIImageView (Mattt Thompson)
  • Change to remove charset parameter from application/x-www-form-urlencoded content type (Mattt Thompson)
  • Change AFImageCache to conform to NSObject protocol ( Marcelo Fabri)
  • Change AFMaximumNumberOfToRecreateBackgroundSessionUploadTask to AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask (Mattt Thompson)
  • Fix documentation error for NSSecureCoding (Robert Ryan)
  • Fix documentation for URLSessionDidFinishEventsForBackgroundURLSession delegate method (Mattt Thompson)
  • Fix expired ADN certificate in example project (Carson McDonald)
  • Fix for interoperability within Swift project (Stephan Krusche)
  • Fix for potential deadlock due to KVO subscriptions within a lock (Alexander Skvortsov)
  • Fix iOS 7 bug where session tasks can have duplicate identifiers if created from different threads (Mattt Thompson)
  • Fix iOS 8 bug by adding explicit synthesis for delegate of AFMultipartBodyStream (Mattt Thompson)
  • Fix issue caused by passing nil as body of multipart form part (Mattt Thompson)
  • Fix issue caused by passing nil as destination in download task method (Mattt Thompson)
  • Fix issue with AFHTTPRequestSerializer returning a request and silently handling an error from a queryStringSerialization block (Kyle Fuller, Mattt Thompson)
  • Fix potential issues by ensuring invalidateSessionCancelingTasks only executes on main thread (Mattt Thompson)
  • Fix potential memory leak caused by deferred opening of output stream (James Tomson)
  • Fix properties on session managers such that default values will not trump values set in the session configuration (Mattt Thompson)
  • Fix README to include explicit call to start reachability manager (Mattt Thompson)
  • Fix request serialization error handling in AFHTTPSessionManager convenience methods (Kyle Fuller, Lars Anderson, Mattt Thompson)
  • Fix stray localization macro (Devin McKaskle)
  • Fix to ensure connection operation -copyWithZone: calls super implementation (Chris Streeter)
  • Fix UIButton category to only cancel request for specified state (@xuzhe, Mattt Thompson)

AFNetworking 2.3.1 - 2014-06-13 19:38:05

  • Fix issue with unsynthesized streamStatus & streamError properties on AFMultipartBodyStream (Mattt Thompson)

AFNetworking 2.3.0 - 2014-06-11 21:03:42

  • Add check for AF_APP_EXTENSIONS macro to conditionally compile background method that makes API call unavailable to App Extensions in iOS 8 / OS X 10.10
  • Add further explanation for network reachability in documentation (Steven Fisher)
  • Add notification for initial change from AFNetworkReachabilityStatusUnknown to any other state (Jason Pepas, Sebastian S.A., Mattt Thompson)
  • Add tests for AFNetworkActivityIndicatorManager (Dave Weston, Mattt Thompson)
  • Add tests for AFURLSessionManager task progress (Ullrich Schäfer)
  • Add attemptsToRecreateUploadTasksForBackgroundSessions property, which attempts Apple's recommendation of retrying a failed upload task if initial creation did not succeed (Mattt Thompson)
  • Add completionQueue and completionGroup properties to AFHTTPRequestOperationManager (Robert Ryan)
  • Change serialization tests to be split over two different files (Mattt Thompson)
  • Change to make NSURLSession subspec not depend on NSURLConnection subspec (Mattt Thompson)
  • Change to make Serialization subspec not depend on NSURLConnection subspec (Nolan Waite, Mattt Thompson)
  • Change completionHandler of application:handleEventsForBackgroundURLSession:completion: to be run on main thread (Padraig Kennedy)
  • Change UIImageView category to accept any object conforming to AFURLResponseSerialization, rather than just AFImageResponseSerializer (Romans Karpelcevs)
  • Fix calculation and behavior of NSProgress (Padraig Kennedy, Ullrich Schäfer)
  • Fix deprecation warning for backgroundSessionConfiguration: in iOS 8 / OS X 10.10 (Mattt Thompson)
  • Fix implementation of copyWithZone: in serializer subclasses (Chris Streeter)
  • Fix issue in Xcode 6 caused by implicit synthesis of overridden NSStream properties (Clay Bridges, Johan Attali)
  • Fix KVO handling for NSURLSessionTask on iOS 8 / OS X 10.10 (Mattt Thompson)
  • Fix KVO leak for NSURLSessionTask (@Zyphrax)
  • Fix potential crash caused by attempting to use non-existent error of failing requests due to URLs exceeding a certain length (Boris Bügling)
  • Fix to check existence of uploadProgress block inside a referencing dispatch_async to avoid potential race condition (Kyungkoo Kang)
  • Fix UIImageView category race conditions (Sunny)
  • Remove unnecessary default operation response serializer setters (Mattt Thompson)

AFNetworking 2.2.4 - 2014-05-13 15:55:16

  • Add NSSecureCoding support to all AFNetworking classes (Kyle Fuller, Mattt Thompson)
  • Change behavior of request operation NSOutputStream property to only nil out if responseData is non-nil, meaning that no custom object was set (Mattt Thompson)
  • Fix data tasks to not attempt to track progress, and rare related crash (Padraig Kennedy)
  • Fix issue with -downloadTaskDidFinishDownloading: not being called (Andrej Mihajlov)
  • Fix KVO leak on invalidated session tasks (Mattt Thompson)
  • Fix missing import of `UIRefreshControl+AFNetworking" (@BB9z)
  • Fix potential compilation errors on Mac OS X, caused by import order of <AssertionMacros.h>, which signaled an incorrect deprecation warning (Mattt Thompson)
  • Fix race condition in UIImageView+AFNetworking when making several image requests in quick succession (Alexander Crettenand)
  • Update documentation for -downloadTaskWithRequest: to warn about blocks being disassociated on app termination and backgrounding (Robert Ryan)

AFNetworking 2.2.3 - 2014-04-18 22:47:10

  • Change removesKeysWithNullValues property to recursively remove null values from dictionaries nested in arrays (@jldagon)
  • Change to not override Content-Type header field values set by HTTPRequestHeaders property (Aaron Brager, Mattt Thompson)
  • Fix AFErrorOrUnderlyingErrorHasCodeInDomain function declaration for AFXMLDocumentResponseSerializer (Mattt Thompson)
  • Fix error domain check in AFErrorOrUnderlyingErrorHasCodeInDomain (Mattt Thompson)
  • Fix UIImageView category to only nil out request operation properties belonging to completed request (Mattt Thompson)
  • Fix removesKeysWithNullValues to respect NSJSONReadingMutableContainers option (Mattt Thompson)

AFNetworking 1.3.4 - 2014-04-15 21:29:37

  • Fix potential non-terminating loop in connection:didReceiveData: (Mattt Thompson)
  • Fix SSL certificate validation to assert that no impossible pinning configuration exists (Maximillian Dornseif)
  • Fix SSL certificate validation to provide a human readable Warning when SSL Pinning fails (Maximillian Dornseif)
  • Fix to add explicit cast to NSUInteger in format string (Alexander Kempgen)
  • Fix to call call SecTrustEvaluate before calling SecTrustGetCertificateCount in SSL certificate validation (Josh Chung)
  • Fix to check CFStringTransform() call for success before using result (Kevin Cassidy Jr)
  • Fix to prevent unused assertion results with macros (Indragie Karunaratne)
  • Fix AFHTTPMultipartBodyStream to randomly generate form boundary, to prevent attack based on a known value (Mathias Bynens, Tom Van Goethem, Mattt Thompson)
  • Remove unused variable kAFStreamToStreamBufferSize (Alexander Kempgen)