Skip to content

Commit

Permalink
Support multiple env file in Xcode
Browse files Browse the repository at this point in the history
Idea is one env file per scheme
Addresses #1156
  • Loading branch information
jeanregisser committed Mar 17, 2020
1 parent e776aff commit b85c2b9
Show file tree
Hide file tree
Showing 23 changed files with 531 additions and 21 deletions.
3 changes: 3 additions & 0 deletions packages/mobile/.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ SHOW_GET_INVITE_LINK=false
DEV_SETTINGS_ACTIVE_INITIALLY=true
# Enable for true hot reloading while dev-ing UI
DEV_RESTORE_NAV_STATE_ON_RELOAD=false
IOS_BUNDLE_ID_SUFFIX=.dev
IOS_BUNDLE_DISPLAY_NAME=Celo (dev)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.dev.plist
3 changes: 3 additions & 0 deletions packages/mobile/.env.alfajores
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ FIREBASE_ENABLED=true
SECRETS_KEY=production
SHOW_TESTNET_BANNER=true
SHOW_GET_INVITE_LINK=true
IOS_BUNDLE_ID_SUFFIX=.alfajores
IOS_BUNDLE_DISPLAY_NAME=Celo
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajores.plist
5 changes: 4 additions & 1 deletion packages/mobile/.env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ DEV_SETTINGS_ACTIVE_INITIALLY=true
FIREBASE_ENABLED=true
SECRETS_KEY=integration
SHOW_TESTNET_BANNER=true
SHOW_GET_INVITE_LINK=false
SHOW_GET_INVITE_LINK=false
IOS_BUNDLE_ID_SUFFIX=.integration
IOS_BUNDLE_DISPLAY_NAME=Celo (int)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.integration.plist
3 changes: 3 additions & 0 deletions packages/mobile/.env.pilot
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ FIREBASE_ENABLED=true
SECRETS_KEY=production
SHOW_TESTNET_BANNER=false
SHOW_GET_INVITE_LINK=false
IOS_BUNDLE_ID_SUFFIX=.pilot
IOS_BUNDLE_DISPLAY_NAME=Celo (pilot)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.pilot.plist
3 changes: 3 additions & 0 deletions packages/mobile/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ FIREBASE_ENABLED=false
SECRETS_KEY=debug
SHOW_TESTNET_BANNER=false
SHOW_GET_INVITE_LINK=true
IOS_BUNDLE_ID_SUFFIX=.test
IOS_BUNDLE_DISPLAY_NAME=Celo (test)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.dev.plist
5 changes: 4 additions & 1 deletion packages/mobile/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**/GoogleService-Info*.plist
sentry.properties
Pods
Pods

# react-native-config codegen
tmp.xcconfig
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed packages/mobile/ios/GoogleService-Info.plist.enc
Binary file not shown.
14 changes: 14 additions & 0 deletions packages/mobile/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,18 @@ post_install do |installer|
rnfirebase.build_configurations.each do |config|
config.build_settings["HEADER_SEARCH_PATHS"] = "$(inherited) ${PODS_ROOT}/Headers/Public/**"
end

# Include env xccconfig generated by React Native Config
installer.aggregate_targets.each do |target|
target.user_build_configurations.each_key do |key|
cocoapods_xcconfig = target.xcconfig_path(key)
rnconfig_xcconfig = target.client_root + "tmp.xcconfig"
File.open(cocoapods_xcconfig, 'a') do |f|
f.write <<~EOF
// Env config generated by React Native Config
#include? "#{rnconfig_xcconfig.relative_path_from(cocoapods_xcconfig.dirname)}"
EOF
end
end
end
end
2 changes: 1 addition & 1 deletion packages/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,6 @@ SPEC CHECKSUMS:
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Yoga: 14927e37bd25376d216b150ab2a561773d57911f

PODFILE CHECKSUM: c66da841c6399b1bc159ddb85a372fb50501e909
PODFILE CHECKSUM: 5bb8bdd9fd2daf5091a61879babd6bcd7110300d

COCOAPODS: 1.7.5
36 changes: 22 additions & 14 deletions packages/mobile/ios/celo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
00E356F31AD99517003FC87E /* celoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* celoTests.m */; };
0350D7F2EBD64D0585FEF0AF /* Hind-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 95E01263B685485BA7D5CEB0 /* Hind-Light.ttf */; };
0445977E03C74B20A93158B5 /* Hind-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B59F6FDB7D084157A12E7A52 /* Hind-Bold.ttf */; };
0581BC2D3AEB42D086D403E3 /* Hind-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AAE92820119F4CC5B23C6636 /* Hind-Medium.ttf */; };
0F1E1EB52346439C00274556 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0F1E1EB32346439C00274556 /* [email protected] */; };
0F1E1EB62346439C00274556 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0F1E1EB42346439C00274556 /* [email protected] */; };
0FF4C5D62355F18C009E07DD /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0FF4C5D52355F18B009E07DD /* GoogleService-Info.plist */; };
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
Expand Down Expand Up @@ -53,7 +53,6 @@
0F1E1EB32346439C00274556 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
0F1E1EB42346439C00274556 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
0FE3DE8E2347740700EA87A0 /* celo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = celo.entitlements; path = celo/celo.entitlements; sourceTree = "<group>"; };
0FF4C5D52355F18B009E07DD /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
114969FB1F3AA04FFDC6831F /* Pods-celoTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-celoTests.debug.xcconfig"; path = "Target Support Files/Pods-celoTests/Pods-celoTests.debug.xcconfig"; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* celo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = celo.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = celo/AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -143,7 +142,6 @@
13B07FAE1A68108700A75B9A /* celo */ = {
isa = PBXGroup;
children = (
0FF4C5D52355F18B009E07DD /* GoogleService-Info.plist */,
0FE3DE8E2347740700EA87A0 /* celo.entitlements */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
Expand Down Expand Up @@ -216,14 +214,6 @@
name = Resources;
sourceTree = "<group>";
};
4FA6CD97B5DB4D8A8D85F318 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
path = Application;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -255,6 +245,7 @@
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
0FA148AE242137AC009239C6 /* Copy GoogleService-Info.plist */,
ED787910B2A9AE78802F0CBC /* [CP] Embed Pods Frameworks */,
FAA606D3D7E04ED7985FC9FF /* Upload Debug Symbols to Sentry */,
);
Expand Down Expand Up @@ -381,7 +372,6 @@
0F1E1EB62346439C00274556 /* [email protected] in Resources */,
0F1E1EB52346439C00274556 /* [email protected] in Resources */,
0581BC2D3AEB42D086D403E3 /* Hind-Medium.ttf in Resources */,
0FF4C5D62355F18C009E07DD /* GoogleService-Info.plist in Resources */,
2CE54C7D16D44C5380C53609 /* Hind-Regular.ttf in Resources */,
5575263ED1EA4F568D328DE9 /* Hind-SemiBold.ttf in Resources */,
);
Expand Down Expand Up @@ -419,6 +409,24 @@
shellPath = /bin/sh;
shellScript = "# First set the path to sentry.properties\nexport SENTRY_PROPERTIES=sentry.properties\n\n# Setup nvm and set node\n[ -z \"$NVM_DIR\" ] && export NVM_DIR=\"$HOME/.nvm\"\n\nif [[ -s \"$HOME/.nvm/nvm.sh\" ]]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [[ -x \"$(command -v brew)\" && -s \"$(brew --prefix nvm)/nvm.sh\" ]]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\n\n# Set up the nodenv node version manager if present\nif [[ -x \"$HOME/.nodenv/bin/nodenv\" ]]; then\neval \"$(\"$HOME/.nodenv/bin/nodenv\" init -)\"\nfi\n\n[ -z \"$NODE_BINARY\" ] && export NODE_BINARY=\"node\"\n\n# Fixes bundling failing with our monorepo setup\nexport PROJECT_ROOT=\"$PROJECT_DIR/..\"\n\n$NODE_BINARY ../../../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \\\n../../../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
0FA148AE242137AC009239C6 /* Copy GoogleService-Info.plist */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Copy GoogleService-Info.plist";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/../scripts/copy_google_service_plist.sh\"\n";
};
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -825,7 +833,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = org.celo.mobile.dev;
PRODUCT_BUNDLE_IDENTIFIER = "org.celo.mobile$(IOS_BUNDLE_ID_SUFFIX)";
PRODUCT_NAME = celo;
SWIFT_OBJC_BRIDGING_HEADER = "celo-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -857,7 +865,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = org.celo.mobile.dev;
PRODUCT_BUNDLE_IDENTIFIER = "org.celo.mobile$(IOS_BUNDLE_ID_SUFFIX)";
PRODUCT_NAME = celo;
SWIFT_OBJC_BRIDGING_HEADER = "celo-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.7">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "&quot;$SRCROOT/../scripts/xcode_scheme_build_pre_action.sh&quot; &quot;${ENVFILE:-.env.alfajores}&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "celo.app"
BlueprintName = "celo"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "83CBBA2D1A601D0E00E9B192"
BuildableName = "libReact.a"
BlueprintName = "React"
ReferencedContainer = "container:../node_modules/react-native/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "celo.app"
BlueprintName = "celo"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "celoTests.xctest"
BlueprintName = "celoTests"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "celo.app"
BlueprintName = "celo"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "00E356ED1AD99517003FC87E"
BuildableName = "celoTests.xctest"
BlueprintName = "celoTests"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "celo.app"
BlueprintName = "celo"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "celo.app"
BlueprintName = "celo"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
version = "1.7">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "&quot;$SRCROOT/../scripts/xcode_scheme_build_pre_action.sh&quot; &quot;${ENVFILE:-.env}&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "celo.app"
BlueprintName = "celo"
ReferencedContainer = "container:celo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
Loading

0 comments on commit b85c2b9

Please sign in to comment.