0

I am trying to read a plist value using a /usr/bin/ruby script. How can I do this?

Bugsnag API script

fork do
  Process.setsid
  STDIN.reopen("/dev/null")
  STDOUT.reopen("/dev/null", "a")
  STDERR.reopen("/dev/null", "a")

  require 'shellwords'

  BUGSNAG_API_KEY=$(defaults read "$FRAMEWORK/APIKeys.plist" bugsnag) // Convert this to ruby

  Dir["#{ENV["DWARF_DSYM_FOLDER_PATH"]}/*/Contents/Resources/DWARF/*"].each do |dsym|
    system("curl --http1.1 -F apiKey={BUGSNAG_API_KEY} -F dsym=@#{Shellwords.escape(dsym)} -F projectRoot=#{Shellwords.escape(ENV["PROJECT_DIR"])} https://upload.bugsnag.com/")
  end
end
Mocha
  • 2,035
  • 12
  • 29
  • Consider editing your question. This is just a shell script. It's not using xcode at all – Max Jul 23 '20 at 00:51

1 Answers1

1
BUGSNAG_API_KEY=$(defaults read "$FRAMEWORK/APIKeys.plist" bugsnag)

Assuming this is sh, it's running a command and capturing its output in a string. In Ruby you use backticks to do that

BUGSNAG_API_KEY = `defaults read #{ENV['FRAMEWORK']}/APIKeys.plist bugsnag`

The only thing I had to change was using ENV to access environment variables instead of sh's $ syntax.

Max
  • 21,123
  • 5
  • 49
  • 71