https://kotlinlang.org logo
#ios
Title
# ios
j

Jacob Rhoda

11/02/2023, 12:52 AM
I cleared my caches today and was rebuilding…but I seem to have broken something in my environment. When I build from Xcode with Cocoapods doing the Kotlin build, it only find the system Ruby/Gems and not the one I have installed from Homebrew. Thus it doesn’t find my Cocoapods install. Any insights of where to update the GEM_HOME env variable?
t

Timofey Solonin

11/02/2023, 4:00 PM
Hi! The issue is likely not the `GEM_HOME`; rather, the
PATH
environment variable is different when you are running from Xcode and therefore a different
pod
executable is picked up. One workaround that you could try is to: • Uninstall the CocoaPods installed by system Ruby
Copy code
sudo /usr/bin/gem uninstall cocoapods
• Create a symbolic link from Homebrew installation to
/usr/local/bin
Copy code
ln -s "$(brew --prefix)/bin/pod" /usr/local/bin
• Make sure
which -a pod
shows
/usr/local/bin/pod
Since
/usr/local/bin
is in the default
PATH
used by Xcode, the
pod
executable should be picked up from the Homebrew installation via the symbolic link.
j

Jacob Rhoda

11/02/2023, 4:04 PM
Thanks for responding! From what I understand, the issue is that Gems puts a script in
/usr/local/bin
called
pod
, which gets picked up by pretty much any shell. It’s a Ruby script that invokes the rubygems module and looks for the Gem. Since it’s not installed in the system version (I don’t want to use the System version of Ruby), it doesn’t find it. Unfortunately, the symbolic link idea won’t work and I’d probably just have to install cocoapods as a gem for the system version of Ruby as a workaround.
It’d be really great if I could specify the GEM_HOME environment variable, or perhaps it could use Bundler to specify the cocoapods version.
t

Timofey Solonin

11/03/2023, 7:02 PM
I am not sure this helps in your specific case, but just for the reference I want to mention that Homebrew CocoaPods installation sets up it's own Ruby and GEM_HOME. This can be seen in:
Copy code
cat "$(brew --prefix)/bin/pod"
j

Jacob Rhoda

11/03/2023, 7:51 PM
Yeah, I don’t think that helps fix the issue, but points that environments can be set up in different ways.
I managed to workaround by disabling generating a Podspec file, and adding my GEM_HOME environment variable directly to the script in the Podspec.