Managing different environments using AppCenter analytics? - ios

I use two different build schemes for managing live and staging environments in my enterprise app. Both schemes use different app ids. Now, I want to integrate AppCenter analytics. I want to know, how can i manage two separate environments for same app, since I don’t want staging analytics to corrupt the live one.
Do I need to create a separate app in AppCenter for live and staging and use the corresponding app-secret to start analytics services depending on the selected build scheme? Or is there a better way?

I think you already answer your question since you said "I don’t want staging analytics to corrupt the live one" :). So I recommend to separate as Prod and Debug app.
In my app, I separate them by setting pragma PROD & DEBUG in Build Settings:
active compilation conditions:
DEBUG - Add pragma DEBUG
Release - Add pragma PROD
Then you can set your AppCenter secret key by using the code:
#if DEBUG
secretKey = "YOUR_DEBUG_KEY"
#else
secretKey = "YOUR_PROD_KEY"
#endif
Hope this helps.

Related

Flutter. Applying a different configuration for Testflight and the App Store

The task is to use different API URLs inside the Flutter application for the app installed through the Testflight and for the app installed through the App Store.
Libraries like: store_checker and detect_testflight
do not give 100% results, and I cannot be sure that they will not stop correctly detecting the installation source after the next update.
I also cannot rely on the kReleaseMode constant, since there is no way to create a build that compiled in debug mode and uploads it on a Testflight. This can only be done in release mode.
Using custom configuration files and setting up the .gitattributes file also seems like a perversion, and is not suitable because, besides the local repositories of many developers, bitbucket is used, in which I cannot add my merge driver. Also, there is no guarantee that other developers will use this driver.
Tell me a simple and concise way to implement this? Didn't Apple come up with the idea that developers would need to use different settings for builds in Testflight and in App Store?

Create multiple environment with same bundle id using firebase iOS swift?

We are working on fabric for a crash report. We have four environments debug, dev, prod, and staging. So based on the environment we have created the organization in fabric setting and get API key. So that we can able to use API key for different environments with the same bundle id.
For Fabric i have followed this link : Fabric Crashlytics multiple environments for iOS app
But now we have to move the fabric to firebase. We have created the project for my one environment. But I want to create multiple environments with same bundle id in firebase. Can anyone give me an idea?
Ref link : In this link they have created the dev and production for different bundle id. https://medium.com/bam-tech/setup-firebase-on-ios-android-with-multiple-environments-ad4e7ef35607
In Firebase, you can use multiple projects to support different environments.
The Firebase Console will not prevent you from creating multiple projects having apps with the same bundle id (there is some subtlety when doing this on Android around SHA1 keys but it doesn't apply to iOS).
It is up to you if you want to use the same bundle id or not:
Use the same bundle id if you are okay with overwriting the prod app when testing on devices
Use a different bundle id (e.g. append ".staging" or ".test") if you want to test side-by-side
Be mindful that you will have to manage different GoogleService-Info.plist files since you are using two different Firebase projects, and be extra careful when deploying to App Store - you do not want to publish an app that points to your staging or test environments!
Additional reading: https://firebase.google.com/docs/projects/multiprojects

Firebase Analytics events on iOS - test and production

The iOS app I am working on uses Firebase Analytics to report events. It works as expected, but the app is not in production yet. Once it is it would be preferable to have the events logged by real users separate from these logged when debugging.
What is the best way to have Firebase Analytics events logged separately for test and production?
First you will probably want to create a separate Firebase project for staging/debug.
Then you will have to configure your app to be able to use different resources based on build type. For Android we solved this using build flavors, not sure what the iOS equivalent is.
From docs (https://firebase.google.com/docs/projects/multiprojects):
By default, FirebaseApp.configure() will load the GoogleService-Info.plist file bundled with the application. If your development and production environments are configured as separate targets in XCode, you can:
Download both GoogleService-Info.plist files
Store the two files in different directories
Add both to your XCode project
Associate the
different files with the different targets using the Target
Membership panel.
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.

Which configuration mode does TestFlight use?

I am setting up the production, staging and development stacks/configurations modes for my iOS and API (backend).
I figure the "RELEASE" mode definitely be when the application is public on the app store. I would like to know which configuration mode is used when the iOS application is distributed on TestFlight ?
I understood that the scheme is what determines which configuration mode is used. While I upload the .ipa to TestFlight the Archive scheme is used.
Therefore, now I would like to know if there is a way to have a different configuration for what is on TestFlight and what is released.
What I am trying to solve
We use TestFight to distribute the application to our external testers and stake holders. Therefore would like that application to have a different configuration (e.g. SERVER_ENDPOINT_URL)
Thanks!
Well, I found out that I what I want to accomplish is not possible. Nor was the system built in a way to address my issue.
So what I am doing now is.
Archiving a build with "debug" configuration
Uploading to TestFlight and distributing the executable
After testing is complete
Recompile / re archive the build with "release" configuration
Upload to iTunesConnect and publish the application
Thanks!
Apps are distributed to TestFlight in release mode. If I understand your question right, which I'm not sure I do, at the basic level you want to use a different endpoint URL in your release version. You can differentiate between debug and release using the following
#if DEBUG
static let baseURLString = "https://mydebugurl.com"
#else
static let baseURLString = "https://myreleaseurl.com/"
#endif
However for that to work you need to add custom flags to your build settings, see this question for more info
I hope that answers your question
As far as I know, you won't be able to provide "a different set of variables" for builds pushed to testFlight and app release. That is what it is there for, to test the same byte code that will be published to the public.
With that said, what you could do: Create a "version" endpoint. So if you know that when you first push build 1.2, you will want stakeholders/external testers to see it first. Send a request to your prod server, passing along the build version that is being used, if version == 1.2, point all endpoint traffic to your special "development" endpoints(creating a hostName variable in your SessionManager device side, and setting that accordingly will make that really simple), else push the user on to use prod data.

Setup Facebook for both Xcode configurations

I have a successfully released app with some Facebook integration like login, share etc. After release I need to have two separate apps: the first one works with production server and another one works with testing server. I made four Xcode configurations: debug for testing, release for testing, debug for prod and release for prod. In Build Settings I change their bundle ids and everything works great. Except Facebook login.
I have created another FB app with new FBAppID, new Bundle ID. In Run Script I set the correct FBAppID in Info.plist depending on testing or production environment. But logInWithReadPermissions:fromViewController:handler: returns an error:
remote_app_id does not match stored id.
What do I do wrong? Is it possible to make facebook work in both configurations?

Resources