Reputation: 914
I have the following scenario:
I'm developing an iOS application that is being used for different companies. For each company, there are a few differences:
The best approach is to make a single code and then, override some values and assets for each one of the applications. In Android I can easily achieve this by creating a library module (with the core of the app) and an application module for each company (with no Java code) just by overriding the resources.
I'm trying to develop the same structure at XCode, but the way of doing it is not clear for me. After a brief research, I considered some options: Framework, Static Library and Subprojects.
Which one would be the correct way of doing it? Should I consider using a Dependency/Package Manager (like Swift Package Manager, CocoaPods or Carthage)?
These package manager are git-dependent? Because I'm working with SVN, and switching to Git is not viable at this point.
Project settings:
XCode 9
Swift 4
Upvotes: 0
Views: 113
Reputation: 702
You can go with Static Framework for developing this kind of projects. Now, Static framework has its own ups and downs.
https://www.raywenderlich.com/65964/create-a-framework-for-ios
Note: During release of the app don't forget to ensure the proper payload structure of the ipa file.
Upvotes: 0
Reputation: 4187
I recommend you to use targets.
Let me show you how I handle this hierarchy with my assets
/ settings
.
My Assets
directory
images
images
/ colors
/ certificates
You have to change the Target Membership
for the Company1 > Images
by selecting only the target that it does need to refer to.
For example, common > Assets
needs to refer to all targets
.
You can do the same with your code if you need to do something different in each targets.
Personally, I use the power of extension
to split the code in different source files to be able to refer to different targets.
Refer this file to the Company1
target
extension FirstViewController {
func doSomething() {
// implement this method for the company 1
}
}
Refer this file to the Company2
target
extension FirstViewController {
func doSomething() {
// implement this method for the company 2
}
}
Refer this file to all targets
class LandingEmptyViewController {
func foobar() {
self.doSomething()
}
}
You can also pass some flags
per target in the Build Settings
Using those solutions, you will be able to do the same of in Android.
Upvotes: 3