How to use Alamofire and AlamofireObjectMapper in IOS Swift

Posted by


Today I am going to tutorial How to use Alamofire and AlamofireObjectMapper in IOS Swift. If you have not known yet. You can check here Alamofire. AlamofireObjectMapper Which is popular core network.

Before We jump into project. You need to know Cocoa pod. That’s package to manage lib. You can also check here Cocoapods . Let’s get started.

Download Now

  1. Creating new project
    • From Xcode New->Project
    • In this tutorial I choose Swift language.
  2. Setting up Cocoa pod.
    • Opening terminal
    • cd to your root project
    • typing :  nano podfile
    • Adding snippet code

    • Ctrol + x -> y
    • typing : pod install
    • That’s all for downloading which libraries is necessary for this project.
  3. Setting up MVP architecture pattern
    • You will get infrastructure like this.
    • Download Icon and Font
    • Editing AppDelegate



    • Editing info.plist


    • That’s code in order to allow transport network.
  4. Model folder
    • Creating User class


  5. Common folder
    • Creating UserResponse into response folder


    • Creating UserRequest into request folder


    • Creating Navigator class


    • Creating API Class


    • Creating ShareReferences class


  6. Creating UI folder
    • Creating user folder
    • You can check previous tutorial to know. how to use MVP in IOS Swift MVP
    • Creating UserView class


    • Creating UserAPI class


    • Creating UserPresenter class


    • Creating SignInViewController class


    • Creating SignUpViewController class


  7. Creating home folder
    • Creating HomeViewController


    • That’s all mvp can work with Alamofire and auto parsed json response from Server via ObjectMapper.
    • Now You need to create view android design UI in main.storyboard
    • That’s final step. Let’s get started.
  8. Design ViewController
    • Editing SignInViewController class to UI
    • Click at specific UI you can to assistance “Show the assistant editor” at top of left Xcode
    • Drag and drop from SignInViewController to view.
    • Continue doing the same way the rest of SignUpViewController and HomeController
    • Design SignUpViewController
    • Design HomeViewController
  9. Running app and then getting great result.
    • SignIn page
    • SignUp page
    • Home page


In my personal view MVP architecture pattern combine with Alamofire and AlamofireObjectMapper will create a great model. Almofire not only core network you can also use another func such as upload and download file.

Wish happy coding.


One comment

Leave a Reply

Your email address will not be published. Required fields are marked *