Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Alamofire VS AFNetworking

I am developing an app using Swift. I want to call a REST API. I found there are two popular libraries, AFNetworking and Alamofire. But I don't know which is better (is more popular or has more features).

Can anybody suggest what are the main differences between Alamofire and AFNetworking?

like image 480
Puvanarajan Avatar asked Oct 07 '15 09:10

Puvanarajan


People also ask

Should you use Alamofire?

Advantages of Using AlamofireUsing Alamofire will give a cleaner project. API call interactions (POST/GET/PUT/etc.) will be easier and more understable. Alamofire simplifies a number of common networking tasks that makes development faster and easier.

What is AFNetworking?

AFNetworking is an open source networking library for iOS and macOS that simplifies a developer's tasks with a RESTful networking API and creates modular request/response patterns with success, progress, and failure completion blocks. It has a very active developer community and is used in some of the best apps.

What is Alamofire in Swift?

Alamofire is a networking library written in Swift. You use it to make HTTP(S) requests on iOS, macOS and other Apple platforms. For example, to post data to a web-based REST API or to download an image from a webserver. Alamofire has a convenient API built on top of URLSession (“URL Loading System”).

Does Alamofire use URLSession?

Alamofire and URLSession both help you to make network requests in Swift. The URLSession API is part of the foundation framework, whereas Alamofire needs to be added as an external dependency. Many developers doubt whether it's needed to include an extra dependency on something basic like networking in Swift.


2 Answers

Use AFNetworking if you use Objective-C

Use Alamofire if you use Swift

like image 177
Arsen Avatar answered Sep 29 '22 16:09

Arsen


AFNetworking and Alamofire are by the same people (the Alamofire Software Foundation), Alamofire is their Swift version whereas AFNetworking is the Objective-C version.

Feature wise they are the same.

like image 43
Luke Berry Avatar answered Sep 29 '22 15:09

Luke Berry