How can Xcode 8 be aware of my shell environment variables?

Viewed 766

In Xcode 8.x, at compilation time, I want to run a Ruby script using the environment variables of my shell environment. Unfortunately, when I add a Run Script Phase to my target's build phases, my Ruby script can't find the environment variables from my shell environment.

For instance, I'd like this script:

#!/usr/bin/env ruby

require('plist')

open('myProperties.plist', 'w') do |f|
  f << {
    :'myProperty' => ENV['MY_PROPERTY'].to_s
  }.to_plist
end

to generate a .plist file with data from my environment.

Ultimately, my purpose is to provide a convenient way to use secret API keys in an open-source iOS project needing such keys to work properly. Any idea how I can achieve this?

0 Answers
Related