I am using App Center for CI of my application with default "Push hook", which rebuilds every time I push to the branch. I have a task to pass an API endpoint as an App Center variable, which is configured in Build Configurations.
Alongside, I have my appcenter-pre-build.sh
script, which is placed in the same directory, as .xcworkspace
file (as it is noted in official documentation). The script itself looks like this:
#!/usr/bin/env bash
echo "EXECUTING APPCENTER_PRE_BUILD SCRIPT"
if [ -z "$VERSION_CODE_SHIFT" ]
then
echo "You need define the VERSION_CODE_SHIFT variable in App Center"
exit
fi
if [ -z "$ENDPOINT" ]
then
echo "You need define the ENDPOINT variable in App Center"
exit
fi
PLIST_PATH="VideoApp/VideoApp/Info.plist"
VERSION_CODE=$((VERSION_CODE_SHIFT + APPCENTER_BUILD_ID))
APP_CENTER_CURRENT_PLATFORM="ios"
if [ "$APP_CENTER_CURRENT_PLATFORM" == "ios" ]
then
plutil -replace CFBundleVersion -string "$VERSION_CODE" $PLIST_PATH
echo "Updated version code in $PLIST_PATH to new value: $VERSION_CODE"
plutil -replace CFBundleShortVersionString -string "\${MARKETING_VERSION}.$VERSION_CODE" $PLIST_PATH
echo "Updated marketing version in $PLIST_PATH to new value: \${MARKETING_VERSION}.$VERSION_CODE"
plutil -replace HubEndpoint -string "$ENDPOINT" $PLIST_PATH
echo "Updated HubEndpoint in $PLIST_PATH to new value: $ENDPOINT"
fi
So, basically, I pull environment variables from App Center and modify my Info.plist and then use its properties in code to set the API endpoint. Also, as you can see, app's version is being modified in similar fashion.
The App Center build eventually fails with the following error:
error: Multiple commands produce '/Users/runner/Library/Developer/Xcode/DerivedData/VideoApp-gpxrsqjtrulyrqamenreayeeatqj/Build/Intermediates.noindex/ArchiveIntermediates/Video-Community/InstallationBuildProductsLocation/Applications/PC365.app/appcenter-pre-build.sh':
1) Target 'Video-Community' (project 'VideoApp') has copy command from '/Users/runner/runners/2.168.2/work/1/s/VideoApp/VideoApp/appcenter-pre-build.sh' to '/Users/runner/Library/Developer/Xcode/DerivedData/VideoApp-gpxrsqjtrulyrqamenreayeeatqj/Build/Intermediates.noindex/ArchiveIntermediates/Video-Community/InstallationBuildProductsLocation/Applications/PC365.app
/appcenter-pre-build.sh'
2) Target 'Video-Community' (project 'VideoApp') has copy command from '/Users/runner/runners/2.168.2/work/1/s/VideoApp/appcenter-pre-build.sh' to '/Users/runner/Library/Developer/Xcode/DerivedData/VideoApp-gpxrsqjtrulyrqamenreayeeatqj/Build/Intermediates.noindex/ArchiveIntermediates/Video-Community/InstallationBuildProductsLocation/Applications/PC365.app
/appcenter-pre-build.sh'
warning: duplicate output file '/Users/runner/Library/Developer/Xcode/DerivedData/VideoApp-gpxrsqjtrulyrqamenreayeeatqj/Build/Intermediates.noindex/ArchiveIntermediates/Video-Community/InstallationBuildProductsLocation/Applications/PC365.app/appcenter-pre-build.sh' on task: CpResource /Users/runner/runners/2.168.2/work/1/s/VideoApp/appcenter-pre-build.sh /Users/runner/Library/Developer/Xcode/DerivedData/VideoApp-gpxrsqjtrulyrqamenreayeeatqj/Build/Intermediates.noindex/ArchiveIntermediates/Video-Community/InstallationBuildProductsLocation/Applications/PC365.app
/appcenter-pre-build.sh (in target 'Video-Community' from project 'VideoApp')
** ARCHIVE FAILED **
##[error]Error: /usr/bin/xcodebuild failed with return code: 65
So it is somehow produces duplicates of this script.
It seems very odd to me, because the script is not assigned to any target and created outside of Xcode.
I guess, the issue was about some kind of script caching. I have removed appcenter-pre-build.sh
from the repository, pushed, builded in App Center (this time without errors), then added the script again, pushed and it just worked.