-
-
Save tskulbru/8ea6d823daeac0253d329fd59bb79c96 to your computer and use it in GitHub Desktop.
Firebase stage + Prod config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STEP 1. | |
Add a flag in the "Other Swift Flags" like -DENVConfigStaging to a debug target. | |
Now when you build this target you have a debug flag set, otherwise assume production. | |
STEP 2. | |
Add the staging and production GoogleService-Info.plist(s) | |
STEP 3. | |
Add a build phase script to look for the build flag and copy the appropriate GoogleService-Info.plist to the built .app before codesigning it | |
Doing this allows you to create a class like EnvConfig.swift to define env specific stuff | |
You can do the same thing with GCC preprocessor flags, etc.. if you don't swift | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE_DIR="${SRCROOT}/${PROJECT_NAME}" | |
if [ "${CONFIGURATION}" = "Release" ] | |
then | |
cp "$SOURCE_DIR/GoogleService-Info.release.plist" "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleService-Info.plist" | |
else | |
cp "$SOURCE_DIR/GoogleService-Info.debug.plist" "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleService-Info.plist" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@objc(EnvConfig) | |
class EnvConfig: NSObject { | |
#if ENVConfigStaging | |
class var isProduction:Bool { | |
return false | |
} | |
#else | |
class var isProduction:Bool { | |
return true | |
} | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment