I want to add Crashlytics to my project.
One of the steps is "Add a Run Script Build Phase". I should add line:
"${PODS_ROOT}/Fabric/run" <FABRIC_API_KEY> <BUILD_SECRET>
So, FABRIC_API_KEY and BUILD_SECRET I'd like to configure via .env-file (to set up different Crashlytics-accounts for different environments).
In project.pbxproj it looks like:
BCC7406A1F35F118000AEAAA /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Fabric/run\" <FABRIC_API_KEY> <BUILD_SECRET>";
};
@GantMan , I'm not very familiar with XCode, because it's my first RN-project.
Also I should add
@pedro do you have any solutions for my case?
@NachtRitter I achieved similar thing using this over-complicated method, but didn't find anything easier, because BuildDotenvConfig.ruby just deletes /tmp/envfile after it's processed.
export in .env.* files so you can use the values as environment variables in your build script:export ABC=1
$ENVFILE in the build script didn't work for me for some reason)if [ -n /tmp/envfile ]
then
cp -f /tmp/envfile /tmp/my_envfile
else
echo ".env" > /tmp/my_envfile
fi
envfile=$(< /tmp/my_envfile)
source $PROJECT_DIR/../$envfile
echo $ABC
hi @NachtRitter , my pr #349 allows reading values from env file in Build settings. please give it a try, thanks
@maxkomarychev Thanks, however I'm not working currently with React Native projects. So maybe someone else will check it
Most helpful comment
@NachtRitter I achieved similar thing using this over-complicated method, but didn't find anything easier, because
BuildDotenvConfig.rubyjust deletes/tmp/envfileafter it's processed.exportin .env.* files so you can use the values as environment variables in your build script:$ENVFILEin the build script didn't work for me for some reason)