How to configure GoogleService TRACKING_ID programmatically? - ios

I am using Google Map Service in one of my iOS apps. I have two configurations Development and Production. Google Service TRACKING_IDs are different for both of the configurations so, every time when I prepare final AppStore version I need to change the TRACKING_ID from GoogleService-info.plist which is a repetitive manual work for me. I would like to know if that TRACKING_ID can be configured from source programmatically to avoid this manual checklist. I can detect configurations using macros but I do not know how I can override the .plist stuffs for Google service.

Related

Firebase - Multiple Projects (dev and prod) same app target

I'm looking at Firebase documentation on how to achieve this (see here). Here is the instruction:
If the builds are part of a single target, the best option is to give both configuration files unique names (e.g. GoogleService-Info-Free.plist and GoogleService-Info-Paid.plist). Then choose at runtime which plist to load.
However, at the end of the page, there is "caveat" to this implementation:
On iOS, do not add GoogleService-Info.plist to your project if you are supplying different configuration at run time, as this can result in an apparent change of GOOGLE_APP_ID and result in lost Analytics.
Since I'm trying to add multiple environments to an existing app (live in the App Store) that has a GoogleService-Info.plist added to its project, does that mean I cannot do that since it will result in lost Analytics? Or, can I simply remove the GoogleService-Info.plist and add the environment specific ones, without any problems?
The GoogleService-Info.plist is recommended since it allows Analytics to report early events. If you configure it at run-time, says switching from Google App ID A to B, then you will lose events of A logged before configuring with B. It's more like a warning to let you know the risk of using the runtime API.

Is there is any way to create a IOS app as build for another app?

I have an IOS app which holds lot of Configuration settings to use the app and also this app is used in 5 warehouses, settings will be differ from one warehouse to another warehouse. So it becomes more painful for the users using this app.. Even ever they install the app then need to set the configuration settings.
So my problem is If i hardcode the settings value, it is very difficult to maintain the code for all the different warehouse. if i do small change in my app have to change in all of the 5 source code.. Even if i decide to maintain 1 code .. i have to change the setting value every time before setting the build.. It is more painful for me.
so my question is..
Is there any way to run a app and set values in configuration settings. And generate this setting app as a build ?? i don't know it will workout or not please share me some ideas..
If I understand correctly, you want to have 1 source code and there is possibility to create different Targets. Each target can have it's own configuration plist file and you can set also different preprocessor macros for each target.
How to use preprocesor macros you can see here: How can I differentiate between multiple targets in xcode at runtime
How to create targets you can see here: Add preprocessor macro to a target in xcode 6
One more possibility (besides targets) is to create a shared library and if you want to apply some configs after installation you can prompt user to download one from a server (for instance)
Yes, you can create different schemas.
For example, you can create an application for Development, Staging, Production.
You can have configurations in plist file and make it variable according to the schemas.
When your application opens it will take the values according to the schema with which it was built.
Follow this guide to create different schemas.
Also, you can integrate Fastlane to generate builds easily with different schemas with simple commands.
Yes you can have one app with different targets and schema. Then just google it there's many articles about.

Different parameters in xcode builds

I'm developing an iOS app with Swift 2 and, like most developers, I have a staging and a production environment, with different servers, URL and settings.
I'm looking for a way to quickly switch between the two configurations as I'm developing the app.
On Android I could use build types and flavors to solve this problem.
I've read a lot of guides around the web but all of them were in Obj-C and relied on the macro preprocessor and the #ifdef that was available in Obj-C but isn't in Swift.
There are no clear guides on how to do this in swift and, being a total beginner, I'm not even sure where to start looking.
To recap: what I'm looking for it's a way to switch between two configurations (ex 2 property list files) and to reference the settings contained in those configurations from my code, based on the build I've selected.
You can add a user defined setting in Target's settings with different values for each scheme (Debug, Release, Ad-Hoc, AppStore etc) and use the user defined variable in info.plist file (or as you call it configurations).
Check answer to this question. Although the question is specific to Facebook App Id setup, the answer applies to any generic setting.
Once you have correct data in info.plist you can directly use it in code.

Different apps from the same code base

I have developed a generic app, which can ne customized for clients. Each app should be available in the app store.
Any idea what is the best way to deploy the different apps? This is of course also necessary on app updates.
Only the package name, some graphics and some settings change for different Apps. The Code will be the same for all.
Consider deploying your app as a framework, static library or CocoaPod. The clients should be able to use your framework/pod to customize the appearance (and anything else) and publish their apps.
CocoaPods: If your project is in progress and your client is using it, I wouldn't recommend it. Pods are great way for managing dependencies mostly if dependencies are not going to change on nightly basis. Also you'll have to make a few decisions about how to integrate it with your source control. If you and your clients will be working on their client app and pods simultanously. They'll most likely have to get your pods in a workspace, which defeats the purpose of pods. (If somebody knows a better way around editing pods and project simultanously, please let me know as well.)
Static Library/Frameworks: Rey Wenderlich has a good tutorial for creating frameworks. http://www.raywenderlich.com/65964/create-a-framework-for-ios

How can be an open source project released without publishing a few (private) parameters?

I'd like to release one of my projects (an iPhone app).
The problem I have is that I use Parse, google admob and google analytics, so all of them have private keys or app keys that I have to remove when publish them as open source. But I stil want to continue the development of my app from that repo.
How can I automate the process of removing that data and at the same time add them when I work with the project? I want to avoid uploading that private data by mistake.
I'd like to know your suggestions or ideas about this topic.
BTW, I prefer to use BiitBucket or GitHub, maybe they have some feature or plugin for that, no idea.
A good practice consists in gathering all your private keys in a config file (in the case of your app it would be a header containing several define), and add this config file to the .gitignore of your project. Then in your README simply mention that contributors should create in their workspace this config file with their own private keys.
By doing this you will first have a unique config file, so you know where to look at when you want to update a key, and secondly it will prevent you from publishing it by mistake.

Resources