Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] iOS Resolver: Failed to install CocoaPods for the current user #654

Open
derwaldgeist opened this issue Nov 14, 2023 · 16 comments
Open
Labels
needs-attention Need Googler's attention type: question

Comments

@derwaldgeist
Copy link

  • Unity editor version: 2022.3.13f1 Silicon
  • External Dependency Manager version: 1.2.176
  • Source you installed EDM4U: From a Unity package
  • Features in External Dependency Manager in use: Android and iOS Resolver
  • Plugins SDK in use: Facebook, Google Sign In
  • Platform you are using the Unity editor on: MacOS Sonoma, Apple Silicon

I just got my M3 MacBook Pro and am trying to get my existing Unity project up and running. After installing the Silicon version of Unity Editor, I opened my project for the first time. This resulted in an error message that Cocoapods cannot be installed

image image

I have upgraded my cocapods (1.14.2) and Ruby (3.2.2) installations, but still the problem persists. It seems as if EDM4U picks up an installation that was already pre-installed on the machine.

What's the issue repro rate? 100%

What happened? How can we make the problem occur?

Just install Unity on a fresh Apple Silicon MacBook and try to open an existing project using EDM4U.

@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@derwaldgeist
Copy link
Author

derwaldgeist commented Nov 14, 2023

I also found this Issue:

#589

which has been closed but without a real solution. I tried to set the UTF8 setting mentioned in the comments, but this did not work.

Plus, I tried to install cocoapods 1.10.2 as recommended in the comments as well, but this does not seem to be available for Silicon Macs, neither via sudo gem install nor via homebrew.

@paulinon paulinon removed the new to be triaged label Nov 14, 2023
@paulinon
Copy link
Collaborator

Hi @derwaldgeist,

Have you installed Xcode and Xcode Command Line Tools? You'll need Xcode in order to build your app on an iOS device since Unity only generates the Xcode project. You can install Xcode Command Line Tools using this command:

xcode-select --install

I look forward to hearing from you soon.

@paulinon paulinon added the needs-info Need information for the developer label Nov 14, 2023
@remzisenel
Copy link

I am in the same boat as the original poster.

$ xcode-select --install

xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates

osx Sonoma ships with ruby 2.6.10.210 and iOS Resolver uses the system shipped ruby version even when a newer ruby version is installed and configured in shell profile.

$ ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.4.10
  - RUBY VERSION: 3.2.2 (2023-03-30 patchlevel 53) [arm64-darwin23]
...

@remzisenel
Copy link

remzisenel commented Nov 14, 2023

I confirmed my shell profile is loading correctly into Unity process by executing ruby --version and gem env through a process created within Unity runtime. I'm also using bash to make sure the shell is the same as the one being used by the iOS Resolver.

var process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = "bash";
...
process.Start();

Outputs:

'ruby --version' completed with code 0

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]
'gem env' completed with code 0

RubyGems Environment:
  - RUBYGEMS VERSION: 3.4.10
  - RUBY VERSION: 3.2.2 (2023-03-30 patchlevel 53) [arm64-darwin23]
...
'echo $PATH' completed with code 0

[HOME_DIR]/.rbenv/shims:...

.rbenv/shims have symlinks to the ruby-3.2.2 environment

@derwaldgeist
Copy link
Author

xcode-select --install

Yes, Xcode command line tools are already installed. But still, I cannot make it work. This did not happen on my Intel Mac, with the very same setup. Could it be that it is a Silicon Mac specific problem?

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Nov 14, 2023
@derwaldgeist
Copy link
Author

derwaldgeist commented Nov 14, 2023

@remzisenel I guess you didn't find a solution yet, did you? This is driving me nuts... I get the same output from ruby -v and gem env as you, if I call them on the terminal. I'm using zsh, though, with the oh-my-zsh addon. This worked fine on my Intel Mac.

@derwaldgeist
Copy link
Author

derwaldgeist commented Nov 14, 2023

I've also checked my path now. It contains /opt/homebrew/opt/ruby/bin which correctly points to a ruby 3.2.2 executable, as well as a gem 3.4.22 executable.

The error dialog I am getting claims that it only finds ruby 2.6.10.210 instead. Wherever this version comes from. This is installed in /usr/bin. If I get these instructions right, this version shall not be removed because it is required by MacOS itself:

https://mac.install.guide/ruby/9.html

@derwaldgeist
Copy link
Author

derwaldgeist commented Nov 14, 2023

I tried to tell asdf to use ruby 3.2.2 inside the Unity project, but this did not help. Also tried to set Use Shell to Execute Cocoapod Tool in EDM4U to false, but this didn't have an effect either. Is there another way to tell EDM4U where to locate the right ruby version?

I've also checked bash and sh. All point to the 3.2.2 version.

@derwaldgeist
Copy link
Author

derwaldgeist commented Nov 14, 2023

I was abe to fix this using these instructions:
https://forum.unity.com/threads/cocoapods-installation-failure-when-building-for-ios.1167700/#post-8793733

I guess the important part is this:

sudo arch -arm64 gem install -n /usr/local/bin cocoapods -v 1.10.2

I also tried it without the -v 1.10.2, and the more recent 1.14.2 seems to work as well.

However, this seems like a pretty odd workaround to me. Would appreciate a better solution.

@remzisenel
Copy link

remzisenel commented Nov 15, 2023

I believe the root of the problem is that the resolvers are not using the right binaries in PATH. I couldn't figure out why yet.

I did get around the cocoapods problem by manually installing cocoapods through my own terminal, somewhat akin to what @derwaldgeist did - he installed (an older version of) cocoapods for the system ruby environment, I installed cocoapods manually for the newer rbenv installed ruby environment.

@Olof-IL
Copy link

Olof-IL commented Nov 16, 2023

I agree with @remzisenel

Spent a few hours trying to resolve this issue today, and yes, it seems no matter what I do, the iOS Resolver seems dead set on using the old outdated /usr/bin/ruby, even though I've installed 3.2.2 (tried both with homebrew and with rbenv)

It would be nice if the tool could be fixed to properly respect the path and use the correct version of ruby.

@Olof-IL
Copy link

Olof-IL commented Nov 16, 2023

I'll also share my workaround.

  1. Add /Users/YourUser/.gem/ruby/2.6.0/bin to your path, add this to your .zshrc:
    export PATH="$PATH:/Users/YourUser/.gem/ruby/2.6.0/bin"
  2. Manually install a version cocoapods compatible with 2.6.0 using the ruby version at /usr/bin:
    sudo /usr/bin/gem install cocoapods -v 1.12.1

Note! You must use at least 1.12.1 or it will not work to archive using XCode 14.3 or later.

But of course, the real fix is for Unity-Jar-Resolver to use the proper version of Ruby instead of only using /usr/bin/ruby, since the latest version of cocoapods is not compatible with 2.6.0

@hantengx
Copy link

hantengx commented Dec 8, 2023

I alse have this error. And add path to zsh is invaild. Then I foud add path to bash is ok! It seems that Unity uses the bash environment by default。

@6ag
Copy link

6ag commented Feb 17, 2024

我将 .zshrc 中的相关配置拷贝到 .profile 中了一份,这样就可以使用我自己安装的 ruby 和 cocoapods 版本了。

@juni1423
Copy link

I was abe to fix this using these instructions: https://forum.unity.com/threads/cocoapods-installation-failure-when-building-for-ios.1167700/#post-8793733

I guess the important part is this:

sudo arch -arm64 gem install -n /usr/local/bin cocoapods -v 1.10.2

I also tried it without the -v 1.10.2, and the more recent 1.14.2 seems to work as well.

However, this seems like a pretty odd workaround to me. Would appreciate a better solution.

yeah!!!! it save me. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-attention Need Googler's attention type: question
Projects
None yet
Development

No branches or pull requests

8 participants