M.C. needs to attract extra consideration to this query.
I’m at the moment making an attempt so as to add a Google Maps API key to each iOS and Android in my Flutter app with out hardcoding it, utilizing surroundings variables.
To do that, I adopted a information that makes use of a shell script, extract-defines.sh, to decode DART_DEFINES and output the variables to an .xcconfig file. I’ve arrange this script as a pre-build motion in Xcode, however that did not work.
i am undecided how you can debug this to examine if the script is working or not.
shell script that ought to extract the dart-defines and add it to the xconfig.
#!/bin/sh
OUTPUT_FILE=”${SRCROOT}/Flutter/Dart-Defines.xcconfig”
: > $OUTPUT_FILE
perform decode_url() { echo “${*}” | base64 –decode; }
IFS=’,’ learn -r -a define_items <<<“$DART_DEFINES”
for index in “${!define_items[@]}”
do
merchandise=$(decode_url “${define_items[$index]}”)
# Dart definitions additionally embody gadgets which are mechanically outlined on the Flutter aspect.
# Nonetheless, if we export these definitions, we will be unable to construct because of errors, # so we don’t output gadgets that begin with flutter or FLUTTER.
lowercase_item=$(echo “$merchandise” | tr ‘[:upper:]’ ‘[:lower:]’)
if [[ $lowercase_item != flutter* ]]; then
echo “$merchandise” >> “$OUTPUT_FILE”
fi
performed
i added this Key to Data.plist
<key>GOOGLE_MAPS_API</key> <string>$(GOOGLE_MAPS_API)</string>
now i am making an attempt to configure Google Maps in AppDelegate.swift utilizing this similar key
import Flutter
import UIKit
import GoogleMaps
@predominant
@objc class AppDelegate: FlutterAppDelegate {
override func utility(
_ utility: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if let googleMapsApiKey = Bundle.predominant.object(forInfoDictionaryKey: “GOOGLE_MAPS_API”) as? String {
GMSServices.provideAPIKey(googleMapsApiKey)
}
return tremendous.utility(utility, didFinishLaunchingWithOptions: launchOptions)
}
}
i used to be principally following the one information i discovered about this on-line. however i believe i is likely to be lacking one thing.
Be aware: i wish to do that for android as properly however i began with IOS and hit a wall