简体   繁体   中英

GitHub: What is the best way to manage different versions of an app?

I have an iOS app with two different versions, basically one is made to be published on the App Store (Online version) and the other one is for in-house distribution (Offline version).

What I'm looking for is the best way to publish my code on GitHub, so that I can easily update both Xcode projects in the future, because only a portion of the code is different for the two versions.

As I understand it, branches are made to be merged to 'master', but in my case, both versions need to be separated and only a few changes are required to be merged.

I have tried to create a second branch for my GitHub repository, but I can't figure out if this is the easiest way to keep both projects updated together, or would it be better to create two separate repositories on GitHub?

Thank you for your feedback!

There are several ways to accomplish what you want. Using multiple repos or branches for different versions of the app is not a good option. Codebases will probably diverge in time and become very hard to maintain.

To solve this issue, we prefer to use separate target configurations in XCode.

Easiest way to create a new version of your app:

  • Duplicate the current target
  • rename it like 'XXX in-house' instead of 'XXX copy' (optional)
  • Change the bundle identifier to be different from the original target
  • Rename 'XXX copy-Info.plist' file to a better name and change the Info.plist reference from the target's Build Settings (optional)

Now you can change any configuration from the target's configuration pane.

In order to distinguish which version of the app running you can define macros in target's build settings (like FREE=1) or you can check current identifier, app name, etc. in your code to set current version.

typedef enum {
    QWEAppStore,
    QWEAppStoreFree,
} QWEAppVersion;

#ifdef FREE
    #define QWECurrentVersion QWEAppStoreFree
#else
    #define QWECurrentVersion QWEAppStore
#endif

Then use it in your classes like:

- (IBAction)buttonTapped:(id)sender
{
    if (QWECurrentVersion == QWEAppStore) {
        // Do something
    } else {
        // Do something else
    }
}

Having two git repo's would be difficult to manage.

A typical workflow would be to have 3 branches

master appStore internal

When you make a code change, you will need to push it to both the appStore and internal branches.

Here is an example project that has many different release versions all inside one git repo

https://github.com/adaptivecomputing/torque

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM