How to Make Xcode Use the Correct Version of Ruby When Running a Script

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

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

Xcode run phase script in Ruby wrong encoding

In the end the solution seems to be to force UTF8 onto ruby

LC_ALL= LANG=en_US.UTF-8 ruby -e 'p Encoding.default_external'
export LANG=en_US.UTF-8

Use non-system ruby to execute ruby scripts within macOS App

Due to Martin R's help I was able to solve the issue.
For now I deactivated macOS sandboxing in the projects capabilities.

Now I can use any ruby I want.

Thank you

Get xcodeproj and ruby 2.7.0 into the PATH

managed to fix it with reinstalling xcodeproj and added

export PATH=/opt/homebrew/lib/ruby/gems/2.7.0/bin:$PATH

to my ~/.bash_profile

then I opened a new terminal

Run Ruby bundler gems as Xcode build scripts

There are few ways to modify OS X environment variables.
However, there's an easy workaround in this case.

In the 'run script' build stage:

source ~/.bash_profile && bundle exec ....



Related Topics



Leave a reply



Submit