Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Project Dependency Management

Has anyone had any success in finding a reliable, generalised solution for managing dependencies for iPhone projects? I'm looking to split my iPhone applications up into reusable components and then pull them into projects that require them. I guess I'm looking for a Maven-esque workflow but for Xcode/iPhone projects. I've tried a number of things so far such as:

  1. I've created a Maven plugin for iPhone applications which automates the building and signing of the applications but I constantly feel like I'm fighting against Maven to get this to work and it is altogether pretty messy. I'd rather not use this unless there are no other options.

  2. I have also tried using static libraries to package the code up to re use but the problem with this is that I'd also like to include reusable XIBs and images in my projects and these cannot be included in the static library for redistribution. They are great for code but I'd like to have one system that does everything rather than different dependency management systems for different types of dependency.

  3. At the moment I've settled on using the version control system to do my dependencies for me. In this case I'm using SVN externals to load the dependencies into the workspace when I checkout the project.

Does anyone have any ideas as to what I could do?

Update

I'm now using CocoaPods to perform this task.

like image 319
xoebus Avatar asked Jul 13 '11 22:07

xoebus


People also ask

How do you manage dependencies in iOS?

Manual Dependency ManagementOpen the new Alamofire folder, and drag the Alamofire. xcodeproj into the Project Navigator of your application's Xcode project. Select the Alamofire. xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.

What is SPM in iOS?

Also known as SwiftPM or SPM, it's been included in Swift since version 3.0. From the official repository: The Swift Package Manager is a tool for managing distribution of source code, aimed at making it easy to share your code and reuse others' code.

Which of the following is used to manage native dependencies in an iOS project?

React Native uses CocoaPods to manage iOS project dependencies and most React Native libraries follow this same convention.


1 Answers

The way I've done it in the past is as follows:

  • Static Library for shared code
  • Bundle for Images / Data Files / Etc (Non Code)

By doing this, you only ever have to worry about updating the project that manages your static library / bundle and not the applications that use them.

The key thing to creating a bundle, is that Bundles are not listed under iOS when adding a new target to a project. Instead they are listed under Mac OS X. Don't worry, it works great.

Once you've created your Bundle and Static Library targets, you'll need to get those into your application:

  • Add the Static Library under Link Binary With Libraries (Xcode 4)
  • Add the Bundle under Copy Bundle Resources (Xcode 4)

The final thing to keep in mind is that when you want to load resources from the newly created bundle you need to do something like the following if you were going to load an image:

UIImage *myImage = [UIImage imageNamed:@"YourBundle.bundle/MyImage.png"];

like image 194
MayorJustin Avatar answered Oct 05 '22 01:10

MayorJustin