Closed adrianvintu closed 7 months ago
Its a dupe of https://github.com/PostHog/posthog-flutter/issues/22 You can have a manifest per flavor and build type https://developer.android.com/build/manage-manifests (with each API key) Then Android merges all the manifests Same for iOS I think, see example https://stackoverflow.com/questions/37615405/use-different-googleservice-info-plist-for-different-build-schemes
@marandaneto Thank you!
@marandaneto the ios version does not work
The link you sent me has Swift code that loads the google setting file.
How to do the same for Posthog?
@marandaneto the ios version does not work
The link you sent me has Swift code that loads the google setting file.
How to do the same for Posthog?
@adrianvintu the idea is the same, you can have a plist file per flavor or something similar, I don't have an example but I know it's possible, you can just inspire from that. As I mentioned, this is a dupe of https://github.com/PostHog/posthog-flutter/issues/22 to make this easier without this workaround but it's not a high priority yet.
Thank you @marandaneto
In the end I have done like this: https://www.marcosantadev.com/manage-plist-files-plistbuddy/
INFO_PLIST="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
FLAVOR_PLIST="$PROJECT_DIR/Plist/Info-$PRODUCT_BUNDLE_IDENTIFIER.plist"
/usr/libexec/PlistBuddy -c "Merge $FLAVOR_PLIST" "$INFO_PLIST"
This is also required for release, inside proguard-rules.pro
# posthog
-keep class com.posthog.** { *; }
-keep interface com.posthog.** { *; }
Version
4.4.1
Steps to Reproduce
It seems the configuration is not hardcoded into the AppManifest and Info.plist.
How can we build flavors? https://docs.flutter.dev/deployment/flavors
Expected Result
ApiKey is not hardcoded into AppManifest and Info.plist. ApiKey is hardcoded into a dart file belonging to a flavor.
JS verson has an init() method - can we have the same in Flutter?
Actual Result
ApiKey is hardcoded into AppManifest and Info.plist.