What is a proper way to execute ruby script from xcode build phase script?

2.9k views Asked by At

I wrote some ruby script, that uses CocoaPods/Xcodeproj to edit xcode project file.

This script executes from xcode build phase script:

ruby script.rb someProj.xcodeproj

Inside ruby script, there is a 'require' for xcodeproj:

require 'xcodeproj'

When I invoke this script manually from terminal, everything is ok.

But when it invokes from xcode build phase, ruby throws exception:

cannot load such a file xcodeproj (something like that)

What am I missing?

1

There are 1 answers

0
Nikita On BEST ANSWER

Build phase -> Shell: change /bin/sh to /bin/bash -l Bash login is required, in order to load ruby variables/paths/etc.