How to Deploy Two Mobile Applications Off of One Codebase/mobile-config.js?

Hey guys, I would really love anyones help with sorting this issue out! I am working on a Meteor application that is currently deployed to both the Apple and Google Connect stores. As such, it has a mobile-config.js file with all of our applications fields and information.

A client of ours would like us to create a separate application for them and deploy it to the Apple and Google Connect stores. The application will use the same codebase as the already existing application. Essentially, the apps will be the exact same - the client is just asking us to wrap our application in their esthetics and deploy that application as a separate application that, on the Apple and Google Connect stores, will have nothing at all to do with our already deployed application.

My question is: Since this separate application will use the same codebase, is their a way for me to use two different mobile-config.js files?

How I imagine this working is to use the sampart/cordova-plugin-app-version package to determine what application is being launched by using getAppName or getPackageName (PLUGIN DOCS: GitHub - sampart/cordova-plugin-app-version: Cordova plugin to return the version number of the current app [not maintained]). Once I know what application is being launched I would like to use the corresponding mobile-config.js file for that specific application. Is that possible? And if it isn’t, is there a way to work around this issue? Am I connecting the chain of events in the right order?

Another solution to this issue that I have thought of is to set the fields inside of “App.info”, “App.icons” and “App.launchScreens” to variables that are dynamically interchanged depending on what application is being loaded on startup. Is that something anyone has any experience doing? All of the other fields in my mobile-config.js file (all of the App.setPreference, App.accessRule and App.appendToConfig) are going to be the same for both application. All I need to do is change “App.info”, “App.icons” and “App.launchScreens” depending on what application is being loaded.

Thanks so much everyone, you all have saved my life several times over, I always really appreciate it.

1 Like

Could you create a local package and put all of your app’s code into it? Use the package in your app, and in the new app for your client and you’re good to go.

Is this a possibility?

1 Like

Hi @allerion I don’t think package is the way to go as the mobile-config.js file is parsed during build and not in runtime.

@ryan1623 I already did this many times and my company https://quave.dev strategy is to use one env variable and then dynamically populate the fields in the mobile-config.js.

We have this example here showing exactly this strategy in place.

There are two intuitions in this strategy:
1 - mobile-config.js file is just a Javascript file that is going to be invoked during build time
2 - you can use env vars to change this behavior

So you can provide a MOBILE_APP_ID=YOUR_APP_ID into your build command, like in you can see here in this bash.

2 Likes

Ohh wow @filipenevola, I think this is exactly what I needed. Thank you for putting me in this direction, I didn’t even think that the mobile-config.js file is just another Javascript file!

1 Like

Thanks @allerion, I spent some time looking into the Meteor docs on packages, there is a lot of cool stuff you can make that I didn’t even think of. I think @filipenevola might be right in his solution being the cleanest way to fix my problem, but I plan on using packages to resolve some other issues I’ve been running into. Thanks again!

@ryan1623 yes, @filipenevola idea is the right way to do it and will save you a lot of time! Glad to hear you found a moment to explore the packages system, it’s very powerful. Good luck with your project. :slight_smile:

1 Like

Hey @filipenevola, your comment has helped me a ton, I’ve spent a bunch of time making scripts and I think it is going to make testing/deploying so much easier.

Could you help me with something? I am trying to set my iOS Team ID so that after I add the ios platform and run the ios Xcode opens I don’t have to manually set my Team ID. Do you have advice on how I might want to do that? I am trying to find a way to do this without creating a build.json file. Can you think of a way to set the Team ID without using a build.json? I have a Meteor.settings file that I am adding to my meteor run call. Is there a way for me to add the build.json fields to the already existing settings file?

I’ve tried adding signing flags like the Cordova docs say you are able to here: iOS Platform Guide - Apache Cordova
But I haven’t been able to get that to work. I would like to define my signing variables in my script and add them to my meteor run call using --buildConfig - is that implemented in Meteor?

Thanks @filipenevola, you’ve already been a huge help!