-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathxcode_scheme_build_pre_action.sh
executable file
·29 lines (23 loc) · 1.25 KB
/
xcode_scheme_build_pre_action.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env sh
#
# Xcode scheme pre action script
set -exu
# First copy the envfile
cp "${SRCROOT}/../$1" /tmp/.env-xcode
# Add newline in case it's missing, otherwise it causes an issue
echo "" >> /tmp/.env-xcode
# Then we load the env variables
# From https://stackoverflow.com/a/56229034/158525
# Supports vars with spaces and single or double quotes
eval "$(grep -v -e '^#' /tmp/.env-xcode | xargs -I {} echo export \'{}\')"
# Now augment it with network specific "secrets" (not real secrets, just API keys)
# See https://newbedev.com/how-to-convert-a-json-object-to-key-value-format-in-jq
# Check if jq exists in the path or use the absolute path
JQ_CMD=$(command -v jq || echo "/opt/homebrew/bin/jq")
$JQ_CMD -r ".${DEFAULT_TESTNET}|to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" "${SRCROOT}/../secrets.json" >> /tmp/.env-xcode
# This makes the scheme use the specified envfile
# See https://github.com/luggit/react-native-config#ios-1
echo "/tmp/.env-xcode" > /tmp/envfile
# This makes envfile config available in xcode build settings
# See https://github.com/luggit/react-native-config#availability-in-build-settings-and-infoplist
"${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/env.xcconfig"