Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Alamofire and AlamofireImage in the same project

Is there a best way to use Alamofire and AlamofireImage together in the same project?

I use Alamofire in most projects I make and I really like the "new" AlamofireImage framework, which uses Alamofire itself as a submodule.

If I use both of the frameworks in my project however as siblings, then I end up with multiple versions of Alamofire, duplicate schemes, etc. I'd like to use them as siblings for a couple of reasons.

  1. AlamofireImage isn't always running the latest version of Alamofire.
  2. After asking some questions to the guys making Carthage, they suggested this over using nested frameworks. https://github.com/Carthage/Carthage/issues/816

Is there any best practices anyone can suggest here? I keep running though issues with this and ending up with a million schemes for Alamofire is starting to drive me a bit crazy. Let alone the issues I kept running into when trying to use Carthage.

Small Note: At I'm using submodules in Git over Carthage atm, as I was not able to use Carthage due to the errors I was getting with nested frameworks (and I'd prefer not to use CocoaPods as I feel it can get way too complex, way too quickly).

Thanks for any help or suggestions anyone can give.

like image 794
Baza207 Avatar asked Dec 05 '25 03:12

Baza207


1 Answers

I recently had the same difficulty in my iOS project. The solution is to reference the Alamofire framework which is INSIDE the AlamofireImage repo.

Here is the step-by-step guideline to make this work

git Set-up

  • XCode should be closed.
  • Cd into thee project directory
  • Add AlamofireImage as a git submodule to your repo (git add submodule AlamofireImageLink)
  • Now, there are two options for ensuring that the submodules are correctly initialized
    • Re-clone the project repo using the "--recursive" flag on when cloning to ensure submodules are correctly downloaded
    • cd into AlamofireImage and run git init and git update. cd into AlamofireImage/Alamofire and run git init and git update.

XCode Set-Up

  • Re-open the project in XCode
  • Add AlamofireImage and AlamofireiOS as embedded / linked binaries in the project build settings.
    • AlamofireiOS will be referenced as INSIDE Alamofire
  • Ensure the AlamofireImage and AlamofireiOS build settings are set to the target deployment of the project (iOS 9.1 probably)
  • Ensure that both have references set to "Relative to Group" in the right sidebar
  • May need to remove the red Alamofire framework reference in the navigator.

Feel free to look at my set-up for guidance: https://github.com/Matt--King/HearthStoneFlashbacks

like image 170
Aakash Avatar answered Dec 07 '25 18:12

Aakash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!