1

I'm trying to create a shell script that runs only on the prod versions of the cloud build targets. Its goal is to replace the bundle id and firebase config files for the production values. I'm using the $WORKSPACE environment variable to achieve some basic file manipulation using bash. It seems to be working fine for the android build, but it's erroring for the ios build.

Here's the simple script:

 
#!/bin/sh
 
echo $WORKSPACE
 
mv $WORKSPACE/client/Assets/google-services.json_prod $WORKSPACE/client/Assets/google-service.json
mv $WORKSPACE/client/Assets/GoogleService-Info.plist_prod $WORKSPACE/client/Assets/GoogleService-Info.plist
 
sed -i 's/Android: redacted/Android: redacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/iPhone: redacted/iPhone: hredacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/overrideDefaultApplicationIdentifier: 0/overrideDefaultApplicationIdentifier: 1/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/productName: redacted: redacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset

On ios build, here's the output:

Executing Pre-Build Script at Assets/Shell/pre_build.sh
73: /BUILD_PATH/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb
74: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
75: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
76: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
77: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
78: ! build of 'ios-prod' failed. Pre-Build script exited with status 1. Aborting.
Teo.sk
  • 2,619
  • 5
  • 25
  • 30

1 Answers1

0

I ended up removing the $WORKSPACE variable from the script and using only a relative path like this: ./client/Assets... and it worked.

Teo.sk
  • 2,619
  • 5
  • 25
  • 30
  • 1
    How did you configure your clould settings to find the bash script? I can't seem to do it. – Xelnath Mar 01 '23 at 21:56
  • @Xelnath - I did it by simply putting the bash script into the Assets folder and then pointing the "Pre-build script" field to it in the "Script hooks" section of the cloud build settings: https://i.imgur.com/MukhiNH.png – Teo.sk Mar 02 '23 at 08:13
  • Thank you, I had my bash script in the parent of the assets folder, thus causing the issue :D – Xelnath Mar 03 '23 at 07:07