Closed mantuness closed 5 months ago
~Replacing "${SRCROOT}"
with ${BUILD_ROOT}/../..
also works~ No it doesn't work! See Miguel's post below.
SCRIPT=`/usr/bin/find "${BUILD_ROOT}/../.." -name newrelic_postbuild.sh | head -n 1`
/bin/sh "${SCRIPT}" "<var>AAbc5de7f96ddb93ae97435e60450b137ed5ea6786-NRMA</var>"
Replacing
"${SRCROOT}"
with${BUILD_ROOT}/../..
also works:SCRIPT=`/usr/bin/find "${BUILD_ROOT}/../.." -name newrelic_postbuild.sh | head -n 1` /bin/sh "${SCRIPT}" "<var>AAbc5de7f96ddb93ae97435e60450b137ed5ea6786-NRMA</var>"
It will, but IMO is not the best way to handle it. If for some reason the path for SourcePackages changes it will not work again...
Of course this is not something that can stay long term. But also... there isn't really a stable way of getting the SPM build path right now. The correct way to handle this is to turn the new relic upload tool in a SPM build tool, but I guess that will take some time.
Of course this is not something that can stay long term. But also... there isn't really a stable way of getting the SPM build path right now. The correct way to handle this is to turn the new relic upload tool in a SPM build tool, but I guess that will take some time.
Yes I agree. But for now, a more suitable option would be to include the script inside the NewRelic .framework
(s) that are inside .xcframework
. That way and until the SPM build tool is not available we would have 100% sure that we would always find the script 😉
Replacing
"${SRCROOT}"
with${BUILD_ROOT}/../..
also works:SCRIPT=`/usr/bin/find "${BUILD_ROOT}/../.." -name newrelic_postbuild.sh | head -n 1` /bin/sh "${SCRIPT}" "<var>AAbc5de7f96ddb93ae97435e60450b137ed5ea6786-NRMA</var>"
That was our first approach, but it failed when archiving release builds as it seems that environment variable's value changes and so going back 2 directories is not enough and it ends failing. The solution we currently have is a script that searches for the project's root directory inside the DerivedData folder in order to then search the SourcePackages folder for the NewRelic post build script.
I went for the "copy script in source" solution. No surprises there 😄 thanks everyone!
I went for the "copy script in source" solution. No surprises there 😄 thanks everyone!
So each time there's a new NewRelic release you will need to check if the original script was updated and then update the one in the build phase? 🤔
So each time there's a new NewRelic release you will need to check if the original script was updated and then update the one in the build phase? 🤔
Almost: so that next time there is a NewRelic release I hope to actually have time to fix it the proper way...
We are in the process of updating our documentation. In the meantime, you can replace your post-build step
e.g. SCRIPT=/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1
/bin/sh "${SCRIPT}" "AA1a6027867c2cdf81fb6f86817596de4df490ea25-NRMA"
with this new post-build step
SCRIPT=/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1
if [ -z "${SCRIPT}"]; then
ARTIFACT_DIR="${BUILD_DIR%Build/*}SourcePackages/artifacts"
SCRIPT=/usr/bin/find "${ARTIFACT_DIR}" -name newrelic_postbuild.sh | head -n 1
fi
/bin/sh "${SCRIPT}" "AA1a6027867c2cdf81fb6f86817596de4df490ea25-NRMA"
@mantuness I commented above
I went for the "copy script in source" solution. No surprises there 😄 thanks everyone!
Hi! could you explain how can I do this?
@virgilius-santos Go into the build phases section and you should be able to do it there. Where all the build phases scripts are you may need to expand some columns to show them.
I use bash. This script works for me from XCode:
SCRIPT=`/usr/bin/find "$SRCROOT" -name newrelic_postbuild.sh | head -n 1`
SCRIPT "YOUR NR TOKEN"
I take that back. I don't get a failure anymore, but it's not working.
Could you help us out by giving us the failure or what may be causing the issue so we can help investigate
Took me a second to realize the markdown formatting made the script hard to copy+paste. Unformatted:
SCRIPT=`/usr/bin/find "${SRCROOT}" -name newrelic_postbuild.sh | head -n 1`
if [ -z "${SCRIPT}"]; then
ARTIFACT_DIR="${BUILD_DIR%Build/*}SourcePackages/artifacts"
SCRIPT=`/usr/bin/find "${ARTIFACT_DIR}" -name newrelic_postbuild.sh | head -n 1`
fi
/bin/sh "${SCRIPT}" "<YOUR NEW RELIC TOKEN>"
Thanks for a useful service. Please update the docs!
Linking New Relic Documentation to bring visibility to this solution 📜
I was also facing the same issue.
For iOS Agent 7.4.0+: Build script should be - "${BUILD_DIR%/Build/*}/SourcePackages/artifacts/newrelic-ios-agent-spm/NewRelic.xcframework/Resources/run-symbol-tool" "APP_TOKEN"
But when I was looking at the folders ${BUILD_DIR%/Build/*}/SourcePackages/artifacts/
the folder named newrelic-ios-agent-spm
was missing then I found another folder named newrelic-ios Saw -sdk
and I found NewRelice.xcframework
According to me the following documents should be revised
"${BUILD_DIR%/Build/*}/SourcePackages/artifacts/newrelic-ios-sdk/NewRelic.xcframework/Resources/run-symbol-tool" "APP_TOKEN"
NewRelic Run Script - `# Type a script or drag a script file from your workspace to insert its path. if [ ${CONFIGURATION} = "Debug" ]; then echo "Skipping DSYM upload CONFIGURATION: ${CONFIGURATION}" exit 0 fi
if [ "${CONFIGURATION}" == "Release" ] ; then "${BUILD_DIR%/Build/}/SourcePackages/artifacts/newrelic-ios-sdk/NewRelic.xcframework/Resources/run-symbol-tool" "APP_TOKEN" else "${BUILD_DIR%/Build/}/SourcePackages/artifacts/newrelic-ios-sdk/NewRelic.xcframework/Resources/run-symbol-tool" "APP_TOKEN" fi`
Closed legacy dSYM upload script issue.
Description
Currently, the described build phase script does not have into account that with SPM the dependency will be inside
DerivedData/.../SourcePackages/.../NewRelic.xcframework/Resources/newrelic_postbuild.sh
and with the current suggestion the script always fail. We managed to work around the problem but I think this should be addressed from your side. Maybe one possible way of solving the issue would be to include the script inside everyNewRelic.framework
that are insideNewRelic.xcframework
. That way we would have access to the script without much trouble because it would be inside the app bundle ;)Steps to Reproduce
Just integrate with SPM, add the script build phase as described, and check what happens. The script will fail 😕
Expected Behavior
The script should work
Relevant Logs / Console output
Your Environment
N/A
Additional context