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

Jiri Bruchanov

03/05/2024, 7:34 PM
Hi, anyone who would know ? If I add pod dependency into build.gradle, it's working fine from Android studio, however it fails if I build the app from xcode due to
env: pod: No such file or directory
?
Copy code
Showing All Messages
* What went wrong:

Execution failed for task ':shared:podInstallSyntheticIos'.
> 'env pod install' command failed with an exception:
   env: pod: No such file or directory
          Full command: env pod install          
          Possible reason: CocoaPods is not installed
          Please check that CocoaPods v1.10 or above is installed.          
          To check CocoaPods version type 'pod --version' in the terminal      
          To install CocoaPods execute 'sudo gem install cocoapods'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to <https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
I do have cocoapods installed. (tried reinstall etc). It used to work, but I probably did something in xcode/gradle which broke it
j

Jeff Lockhart

03/05/2024, 8:08 PM
Xcode uses its own PATH to find executables like
pod
. I've found if you didn't install CocoaPods with
sudo
and the system Ruby, then Xcode can't find it. That might be your issue.
j

Jiri Bruchanov

03/05/2024, 8:19 PM
I don't think it's my case, if I download a web sample it just works
j

Jeff Lockhart

03/05/2024, 8:42 PM
Well, the error indicates Xcode can't find the
pod
executable. Are you sure the other project uses CocoaPods and doesn't integrate the Kotlin shared module without it? How did you install CocoaPods?
j

Jiri Bruchanov

03/05/2024, 8:43 PM
basically this shared/gradle.build
Copy code
apply plugin: libs.plugins.jetbrains.cocoapods.get().pluginId
cocoapods {
           ...
            pod('CocoaAsyncSocket') {
                version = libs.versions.cocoa.async.socket.get()
            }
        }
j

Jeff Lockhart

03/05/2024, 8:44 PM
Is that the app that works or the one that doesn't?
j

Jiri Bruchanov

03/05/2024, 8:44 PM
this is example from the failing one
the working one is slightly different, as it's own module
j

Jeff Lockhart

03/05/2024, 8:45 PM
If it doesn't use CocoaPods, it wouldn't have the same error.
j

Jiri Bruchanov

03/05/2024, 8:46 PM
but I think you are right, something might be broken with the PATH, because if I start messing with the build script it really can't see the
pod
it's using cocoapods, it's just not in
shared
, it own project module
j

Jeff Lockhart

03/05/2024, 8:47 PM
Did you install CocoaPods as a local user or with
sudo
?
j

Jiri Bruchanov

03/05/2024, 8:47 PM
sudo gem install cocoapods
j

Jeff Lockhart

03/05/2024, 8:47 PM
Try running that again.
j

Jiri Bruchanov

03/05/2024, 8:53 PM
same thing...
j

Jeff Lockhart

03/05/2024, 8:56 PM
What's the path you get for
where pod
?
j

Jiri Bruchanov

03/05/2024, 8:57 PM
/Users/scurab/.rvm/rubies/ruby-3.1.2/bin/pod
interestingly, if I run
where pod
from the xcode build script it fails, that
where
is unknown
I must've broken the PATH somehow or something similar for that project
is there some xcode PATH config visible ? so I can compare it between my projects ?
j

Jeff Lockhart

03/05/2024, 9:00 PM
Not that I've been able to find, which is why I ended up just installing globally instead of as a local Ruby gem.
But if that's the only path you get with
where pod
, that is a local installed gem, which Xcode won't see on its modified PATH.
I don't think you've messed up Xcode's PATH, as it's really locked down and doesn't include everything on your global system PATH.
For me, I have
pod
in:
Copy code
/usr/local/opt/ruby/bin/pod
/usr/local/bin/pod
So Xcode can see one or both of those paths. You need to be sure Ruby is installing to those locations.
j

Jiri Bruchanov

03/05/2024, 9:04 PM
ah, progress...
sudo gem install -n /usr/local/bin cocoapods
helps, at least to next step which is failing 🙂
🎉 1
Copy code
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
  	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
  	from /usr/local/bin/pod:25:in `<main>'
  	from /usr/local/bin/ruby_executable_hooks:22:in `eval'
  	from /usr/local/bin/ruby_executable_hooks:22:in `<main>'
strangely I must have somehow messed ruby versions... because terminal is running 3.1.2... but xcode ^ 2.6
j

Jeff Lockhart

03/05/2024, 9:06 PM
Yeah, it can be a mess with Xcode and its custom PATH, installing different Ruby versions, etc.
You'll need to be sure CocoaPods is installed by the same Ruby version that Xcode sees, so it gets all its dependencies also installed for that Ruby install.
j

Jiri Bruchanov

03/05/2024, 9:07 PM
I'll look into that... thanks a lot for help
👍🏼 1
@Jeff Lockhart can you tell me what ruby version do you have ?
j

Jeff Lockhart

03/05/2024, 9:43 PM
I have Ruby 3.2.2 installed. But system Ruby that Xcode sees is 2.6.10p210.
j

Jiri Bruchanov

03/05/2024, 9:44 PM
🤔 cocoapods fails to install asking ruby >=2.7.0
which makes me thinking how does it work from xcode
j

Jeff Lockhart

03/05/2024, 9:45 PM
I just installed it with
sudo gem install cocoapods
, which still used the 3.2.2 version, but installed it to the general path that Xcode can see. I'm not sure why it doesn't do that in your case.
j

Jiri Bruchanov

03/05/2024, 9:46 PM
assuming
ruby -v
is 3.2.2 ?
hm, finally it works, however not totally satisfied that I know what I did to fix it 🙂
👍 1
but deffo it has something to do with multiple versions of ruby installed
19 Views