简体   繁体   中英

Automate NewRelic dSYM upload outside Xcode?

My iOS project uses New Relic for tracking. NewRelic requires uploading a dSYM file.

https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/configuration/upload-dsyms-bitcode-apps

I'd like to automate the process through Fastlane, but the provided script complains with:

./NewRelicAgent.framework/Versions/A/Resources/newrelic_postbuild.sh must be run from an XCode build

How can I execute this from within my standard deploy script? I don't want to add this as an XCode post-compile run script or upload manually through the web site.

After some research, I learned that the provided newrelic_postbuild.sh script simply zips up the dSYM folder and uploads it with a curl script.

Fastlane should already do the first part with the gym action. Just specify the output directory in your normal Fastfile build lane.

gym({output_directory: "./build")

When execute, the action above dumps out the symbol file to: ./build/HelloWorld.app.dSYM.zip

To upload that, add it to a variable and execute the following:

NEWRELIC_URL="https://mobile-symbol-upload.newrelic.com/symbol"
NEWRELIC_KEY = "ABCd3fgH1JkLmN0PqRsTuVW8Yz"
DYSM_ZIP_FILE = "./build/HelloWorld.app.dSYM.zip"

Dir.chdir("..") do
    sh "curl -F dsym=@\"#{DYSM_ZIP_FILE}\" -H \"x-app-license-key: #{NEWRELIC_KEY}\" \"#{NEWRELIC_URL}\""
end

That'll do it. If you want to just do it from within a bash script, that command would be:

curl -F dsym=@"${DYSM_ZIP_FILE}" -H "x-app-license-key: ${NEWRELIC_KEY}" "${NEWRELIC_URL}"

The benefit of this approach is that we don't have to clutter our Xcode build settings with extra scripts, and we can avoid executing unnecessary and redundant scripting code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM