Using Alamofire and AlamofireImage in the same project - ios

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.
AlamofireImage isn't always running the latest version of Alamofire.
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.

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

Related

How to move from CocoaPods to Carthage?

My project has linked with like 30 different libraries. Very few of them support Carthage.
Do I need to make a branch and make them support Carthage one by one?
Is there any better way to do so?
The carthage idea is based on frameworks. So if your dependencies do not support them, carthage is unable to build them for you. Simple as that.
But: You can use carthage also to manage dependencies only by using the param "--no-build". Then carthage will only fetch the dependencies into your Carthage/Checkouts folder.
There are some drawbacks:
depending on the project you have to add the projects of each dependency to your own project, if the projects only contain a sample app you have to add the code itself
if the projects have dependencies itself carthage is only able to find them if there is a cartfile in the projects, as an alternative you may add the dependent projects to your own cartfile to avoid forking them but then you have to update the versions for yourself
developers see the code itself while work but they should handle them as read-only
...
It's possible to use carthage like that, but I wouldn't recommend it. If you need more informations about this solution read here.
Note: If you fork the projects and make them support carthage the community might be grateful. ;-)
There is no problem in having both Carthage and Cocoapods running on the same project. You can try a hybrid approach and replace the libraries step by step.
You can check this post on it. There, I make my build time 9 times faster by replacing Cocoapods with Carthage, but I discuss how some libraries were hard or impossible to replace.

Integrating CocoaLumberjack into iOS Project via Drag-and-Drop

I'm trying to integrate CocoaLumberjack into my iOS project by dragging-and-dropping the Lumberjack.Xcode file into my project. That works fine, but now my project has 9 new targets. I don't need all of that overhead. So my question is, how do I cut down on the number of targets to just the needed stuff for iOS?
It seems every time I drag over only the mobile project that it is missing needed files. Upon my research, it seems that there are no up-to-date tutorials related to integrating Lumberjack specifically to iOS, which seems like a tool that would be commonly used so that is odd. Being new to all of this, it is troublesome and I would love some help.
Other information: I'm doing a manual installation since Cocoapods is not an option for me. I am following their Installation Guide:
Installation Guide
The very first line in the manual installation guide is
git submodule add git#github.com:CocoaLumberjack/CocoaLumberjack.git
I do not want to add yet another submodule to my project, so I'm dragging and dropping Lumberjack.Xcode into my project.
Before I learned how to use CocoaPods, I used to just clone the repo and copy all of the .h and .m files into my project, ensuring they're added to the correct target.
The only issue you have to make sure to avoid is missing one or more files. Not 100% sure with CocoaLumberjack, but I'd look at just adding everything from here:
https://github.com/CocoaLumberjack/CocoaLumberjack/tree/master/Classes
Instead of adding it as a submodule, you can simply clone the repo and add it to your project. The rest of the instructions remain the same. So replace the line you quoted above with:
git clone git#github.com:CocoaLumberjack/CocoaLumberjack.git
rm -r CocoaLumberjack/.git/
Then follow the rest of the instructions in the install guide.
Instructions from CocoaLumberJack
https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/GettingStarted.md

Cocoa Touch Framework Swift with embed libraries

I am working on a suite of applications that contain common modules.
 
I want to store the common modules in a Cocoa Touch Framework.
This framework may also contain the libraries and Alamofire and SwiftyJSON because they are widely used in the modules.
 
Currently, despite the many tutorials, articles, etc. read on the internet, I cannot get a stable solution.
Is it possible to integrate the frameworks Alamofire and SwiftyJSON within the framework custom or is it better to integrate them in the different projects consuming the framework (they will also need individually) ?
 
Is it possible to generate a framework running on the simulator and on the phone (whatever methods: subproject or not, dynamic or static library, fat library) ?
You can absolutely do this. You currently have three options for setting this up for development and two options for deployment.
Development
Git Submodules
Git submodules are a great way to bring additional libraries into your project's repository to embed in your project. All you need to do is add the submodule, then drag the Xcode project of that library into your Xcode project so it's nested inside your project. Then you need to add the framework as a link target to your library.
Carthage
Carthage also supports git submodules through the --use-submodules flag. All you need to do is install carthage through homebrew, then create a Cartfile that adds Alamofire and SwiftyJSON using the following command.
carthage update --use-submodules
CocoaPods
CocoaPods is a dependency management system that allows you to easily pull in and deploy different versions of a given library. Since both Alamofire and SwiftyJSON support CocoaPods, you could create a Podfile, and run pod install to pull the pods into your library. I would not recommend this though as this is a pretty heavy weight approach. Instead, I would recommend using either Git Submodules or Carthage for development.
Deployment
Deployment is a MUCH different situation. Currently, there are two fairly robust deployment mechanisms for iOS and OSX that are in wide use in the OSS community (including Alamofire and Carthage).
Carthage
If you imported your git submodules using Carthage, then you may already be completely supporting Carthage deployments. It depends on whether you used a Cartfile.private file to pull in your dependencies. Given what you're trying to do, I doubt that you would use a private Cartfile and would instead use the public one. This means that you should be good to go right out of the box. Awesome!
CocoaPods
CocoaPods is much different than Carthage and has some big advantages over Carthage, at a cost. You need to create a podspec file and push that into a public or private spec repo. Then anyone can pull your pod into their project using a Podfile.
Summary
As you can see, there are MANY options here. I would highly recommend using Carthage to pull in your git submodules, then supporting both Carthage and CocoaPods for deployment. I know that's a lot of effort though, so you may want to focus on one or the other. Sorry for the massive amount of links and information, but you question leads me to believe that you would greatly benefit from all these various sources.
Hopefully that helps get you on your way to becoming a dependency development and deployment ninja.

How to install projects without cocoa pods?

I have seen various libraries on GitHub that look useful, but only list CocoaPods as an install method. I'm not sure I want to be dependent on CocoaPods, because I'm wary of Apple breaking it in some future OS X/Xcode update. Is there a way to get these libraries into my Xcode project without using CocoaPods?
Role of CocoaPods is to automate and simplify the process, but you don't need to use CocoaPods if you don't want to.
In case of "manual installation", usually it would be:
download the project from GitHub
add the files to Xcode
import headers
But there is no universal recipe for every project, it may slightly differ from case to case, but usually it boils down to previously mentioned.
The best way if you don't want to use CocoaPods is to read the project documentation, and study examples if there are any.
Of course there is. Basically you need to download the library project, drag the project into your own project, do some library dependency setup and you're done.
For details, check out https://github.com/Alamofire/Alamofire for manually adding a Swift library. And https://github.com/jverkoey/ObjQREncoder for manually adding a Objective-C library to your project.
The only way to install things without Cocoapods is to just drag the source code of other projects into your class. For example, most Github projects can be installed via Cocoapods, or you can just drag the relevant source code into your projects. You don't need to drag in all of the project resources, all you need is usually class files

How to use cocoapods in an exist ios project

I have an ios project first made in Xcode4.6. I have update it to Xcode5.0.2. Now I want to change the project to using cocoapods to manage the third party pods.
Due to a newer to cocoapods.I search the Internet to how to install cocoapods and so on.Now it's OK.So I run the pod install to get "AFFnetworking 2.1.0". .xcworkspace generate successfully.Then I open the workspace.I saw this in the navigation
There are many question mark.I think this means that Xcode5.0.2 didn't know the AFNetworking 2.1.0 added by cocoapods. And If I write the "#import "AFNetworking.h" in a .m file. Xcode will say that can't find the "AFNetworking.h".
I am a newer to cocoapods. So home someone could help me. Tanks a lot.
Because AFNetworking is linked as a library you need to use the < > import style. So #import <AFNetworking/AFNetworking.h>.
The question marks are coming from your version-control system, not from Xcode itself; they indicate that the files added by CocoaPods are new to version control. I’d recommend committing all of the CocoaPods-related files right away so that you have just one commit that represents “moving to CocoaPods”.
I guess you are using git repository.Add files pod to repository, currently they are untracked thats the reason for '?' there.if the error persists then see the following discussion
AFNetworking Cause Error while using XCTest in Xcode5

Resources