Xcode: 9.3.1
OS: macOS High Sierra 10.13.4
I am and iOS developer and I am not familiar with ruby at all.
I am using a run-script in my Xcode project which uses a ruby gem called 'xcodeproj'. Before everything was working, But I updated my macOS and now this runscript is not able to find gem 'xcodeproj'
When I try to build my project it shows following error
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
I went to the path which is shown in the above error, and there was no xcodeproj gem files, even after that I installed gem install xcodeproj it is being installed somewhere else. This is the output on my terminal
xxx-MacBook-Pro:~ user$ gem list
*** LOCAL GEMS ***
atomos (0.1.2)
bigdecimal (default: 1.3.4)
bundler (default: 1.16.1)
CFPropertyList (3.0.0)
claide (1.0.2)
cmath (default: 1.0.0)
colored2 (3.1.2)
csv (default: 1.0.0)
date (default: 1.0.0)
dbm (default: 1.0.0)
etc (default: 1.0.0)
fcntl (default: 1.0.0)
fiddle (default: 1.0.0)
fileutils (default: 1.0.2)
io-console (default: 0.4.6)
ipaddr (default: 1.2.0)
json (default: 2.1.0)
nanaimo (0.2.5)
openssl (default: 2.1.0)
psych (default: 3.0.2)
rdoc (default: 6.0.1)
scanf (default: 1.0.0)
sdbm (default: 1.0.0)
stringio (default: 0.0.1)
strscan (default: 1.0.0)
webrick (default: 1.4.2)
xcodeproj (1.5.9)
zlib (default: 1.0.0)
Moreover, when I try to execute my ruby runscript via terminal it shows no error (And via xcode it fails).
Apparently, gem xcodeproj has been installed in my macOS but it is not under Ruby.framwork and I think that's why my xcode's runscript is failing at build time. Hese is my runscript 
The screenshot of error in Xcode 
Any help is highly appreciated, guys :)
Okay I found the bug in my code.
There were two ruby versions one for the system i.e
/System/Library/Frameworks/Ruby.framework/Versions/2.3(this is for the root system, which comes with macOS) and other was/usr/local/Cellar/ruby/2.5.1/lib/ruby(Not sure what is this for, My guess is that it is separate ruby environment for new version 2.5.1, I might have installed it in past)In my runscript's shell, I had
/usr/bin/rubywhich has ruby executable file for system's ruby/System/Library/Frameworks/Ruby.frameworkI checked the ruby environment by command
gem environment, And it gave the outputHere
EXECUTABLE DIRECTORY: /usr/local/binand I had a different path for my ruby executable which I specified in my runscript's shell(/usr/bin/ruby)so I changed/usr/bin/rubyto/usr/local/bin/rubyand it is working.As my gem was being installed in updated version of ruby(2.5)
/usr/local/Cellar/ruby/2.5.1/lib/rubyinstead of old system's ruby (2.3)/System/Library/Frameworks/Ruby.frameworkso now as I provided the executable ruby path of the latest ruby version, in which gem was installed, it is working fine.