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

Problem with XCode 14 and m1 mac. #232

Open
clintmod opened this issue Sep 21, 2022 · 18 comments
Open

Problem with XCode 14 and m1 mac. #232

clintmod opened this issue Sep 21, 2022 · 18 comments

Comments

@clintmod
Copy link

clintmod commented Sep 21, 2022

I just had to set up a couple of new m1 build machines and I couldn't get this gem to run the ruby-inline c++ code when running pod install with XCode 14.

I was able to work around this by downgrading to Xcode 13.

Here was the error:

bash-3.2$ make pods

Getting pods

bundle exec pod install --repo-update --verbose --deployment
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/osx_keychain-1.0.2/lib/osx_keychain.rb:83:18: warning: 'SecKeychainOpen' is deprecated: first deprecated in macOS 12.0 - Custom keychain management is no longer supported [-Wdeprecated-declarations]
        status = SecKeychainOpen("login.keychain",&keychain);
                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Headers/SecKeychain.h:287:10: note: 'SecKeychainOpen' has been explicitly marked deprecated here
OSStatus SecKeychainOpen(const char *pathName, SecKeychainRef * __nonnull CF_RETURNS_RETAINED keychain)
         ^
1 warning generated.
Undefined symbols for architecture arm64:
  "_rb_cObject", referenced from:
      _Init_Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1 in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_const_get", referenced from:
      _Init_Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1 in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_define_method", referenced from:
      _Init_Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1 in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_eRuntimeError", referenced from:
      _get in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
      _set in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_intern2", referenced from:
      _Init_Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1 in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_raise", referenced from:
      _get in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
      _set in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_str_new", referenced from:
      _get in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_string_value_cstr", referenced from:
      _get in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
  "_rb_string_value_ptr", referenced from:
      _get in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
      _set in Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1-99b4fc.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

---------------------------------------------
Error loading plugin file `/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-keys-2.2.1/lib/cocoapods_plugin.rb`.

CompilationError - error executing "clang -fdeclspec -dynamic -bundle  -L/Users/edwardg/.rbenv/versions/3.0.2/lib  -Wl,-multiply_defined,suppress -fno-common -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe -L. -L/Users/edwardg/.rbenv/versions/3.0.2/lib  -fstack-protector-strong -I /Users/edwardg/.rbenv/versions/3.0.2/include/ruby-3.0.0 -I /Users/edwardg/.rbenv/versions/3.0.2/include/ruby-3.0.0/arm64-darwin21 -I /Users/edwardg/.rbenv/versions/3.0.2/include -L/Users/edwardg/.rbenv/versions/3.0.2/lib -o \"/Users/edwardg/.ruby_inline/ruby-3.0.0/Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1.bundle\" \"/Users/edwardg/.ruby_inline/ruby-3.0.0/Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1.c\" -lc -framework Security -framework CoreFoundation -framework CoreServices ": pid 23937 exit 1
Renamed /Users/edwardg/.ruby_inline/ruby-3.0.0/Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1.c to /Users/edwardg/.ruby_inline/ruby-3.0.0/Inline_OSXKeychain_5b2f8d1cd1bde9c4ff3fea49f09cd5c1.c.bad
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/RubyInline-3.12.5/lib/inline.rb:621:in `build'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/RubyInline-3.12.5/lib/inline.rb:859:in `inline'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/osx_keychain-1.0.2/lib/osx_keychain.rb:17:in `<class:OSXKeychain>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/osx_keychain-1.0.2/lib/osx_keychain.rb:6:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-keys-2.2.1/lib/keyring.rb:1:in `require'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-keys-2.2.1/lib/keyring.rb:1:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-keys-2.2.1/lib/cocoapods_plugin.rb:1:in `require'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-keys-2.2.1/lib/cocoapods_plugin.rb:1:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:92:in `require'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:92:in `block in safe_require'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:90:in `each'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:90:in `safe_require'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:31:in `block in load_plugins'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:30:in `map'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command/plugin_manager.rb:30:in `load_plugins'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command.rb:326:in `block in run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command.rb:325:in `each'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command.rb:325:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/pod:23:in `load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/pod:23:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:23:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli.rb:486:in `exec'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli.rb:31:in `dispatch'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli.rb:25:in `start'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/bundle:23:in `load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/bundle:23:in `<main>'
---------------------------------------------

  Preparing
[!] Your Podfile requires that the plugin `cocoapods-keys` be installed. Please install it and try installation again.

/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:722:in `block in ensure_plugins_are_installed!'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:720:in `each'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:720:in `ensure_plugins_are_installed!'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:225:in `block in prepare'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:149:in `message'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:222:in `prepare'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:160:in `install!'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/pod:23:in `load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/pod:23:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli/exec.rb:23:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli.rb:486:in `exec'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli.rb:31:in `dispatch'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/cli.rb:25:in `start'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/bundle:23:in `load'
/Users/edwardg/.rbenv/versions/3.0.2/gemsets/till/bin/bundle:23:in `<main>'

[!] cocoapods-generate requires CocoaPods >= 1.5.0
make: *** [pods] Error 1
bash-3.2$ 

I actually tried to force an x86_64 build to see if that would fix it with arch -x86_64 pod install but it still complained about not being able to find the exact same symbols. I wonder if the ruby framework in Xcode 14 changed.

Wanted to also mention that I'm installing ruby with rbenv and that I did downgrade ruby from 3 to 2 although I'm not sure that the ruby downgrade was required.

@BlueRaccoonTech
Copy link

BlueRaccoonTech commented Oct 3, 2022

I'm having this same problem with XCode 14 on a M1 Macbook Pro.

EDIT: Realized I should mention that this problem does indeed go away if I downgrade to xCode 13. Would like to stay on xCode 14, however, as I want to test applications on an iPhone 14.

@josorio-uber
Copy link

I am having this issue too. The fix that @clintmod provides it works.

@everuribe
Copy link

Confirming only works with Xcode 13

@fabianmuecke
Copy link

Facing the same issue, too. Tried ruby versions 2.7.4, 2.7.6 and 3.1.2. Tried Xcode 14.0.1 and 13.4.1. Nothing works. Is there a specific Xcode 13 version I need to use?

@josorio-uber
Copy link

@fabianmuecke I tried ruby 2.7.4 with Xcode 13.4.1. Don't forget to change Xcode select to 13 version.

@fabianmuecke
Copy link

Thanks @josorio-uber. In the end, the problem seemed to be related to my rbenv somehow. I uninstalled rbenv and installed Ruby 3.1.2p20 via brew. That solved the problem and I can now even use Xcode 14.0.1. No idea why, though. 🤷‍♂️

@clintmod
Copy link
Author

clintmod commented Oct 6, 2022

It's worth mentioning that once it's compiled with Xcode 13 the ruby_inline lib caches the results in ~/.ruby_inline/YOUR_RUBY_VERSION so if you archive these somewhere you can reuse them. This would also let you upgrade to Xcode 14 as it won't try to compile it again. This is probably what @fabianmuecke is seeing.

@sawalon
Copy link

sawalon commented Nov 5, 2022

#217 (comment)
fixed my issue.

@MhMudSalAh
Copy link

[!] Your Podfile requires that the plugin cocoapods-keys be installed. Please install it and try installation again.

I have this error in M1 MAX & Monterey 12.6.1 & XCode 14.1

I couldn't solve this problem with all possible solutions
and I did all steps in this Article
and setup "gem install cocoapods-keys" and I have the same error, however I have ruby version 3.1.2
please can any solve this problem ?!!

@mattneub
Copy link

mattneub commented Nov 20, 2022

In my case I encountered this issue, trying to run pod install under rbenv ruby 2.7.6 after having upgraded my M1 to macOS Ventura. This meant that I couldn't downgrade Xcode (or the Xcode command-line tools) to Xcode 13, as Ventura will not accept them. In the end I had to delete my hard drive and downgrade to macOS Monterey. I think this needs a real solution from within the gem, rather than these band-aid style workarounds. Neither use of Xcode 13 nor repeated use of arch -arch x86_64 is an acceptable option. Thx

@MhMudSalAh
Copy link

@mattneub
Thanks for your response
I am already tried your steps but also failed.

@orta
Copy link
Owner

orta commented Nov 21, 2022

After a quick look at different keychain gems, I'd recommend someone take a look at switching this gem to use https://rubygems.org/gems/ruby-keychain

@kdlogen
Copy link

kdlogen commented Nov 22, 2022

I've managed to install and use cocoapods-keys on Apple M1 Max chip. It worked for me with System ruby installation combined with Xcode 13.4.1. I also tried out different ruby versions using rbenv, but without any luck.

The best is that I can still use arm64 terminal, and no need to start reinstalling everything under Rosetta. 🎉

OS details:

$ sw_vers
ProductName:	macOS
ProductVersion:	12.6.1
BuildVersion:	21G217

$ uname -m
arm64

Ruby version

$ ruby -v       
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin21]

@mattneub
Copy link

mattneub commented Nov 22, 2022

@kdlogen The problem is that if you're using macOS 13 (Ventura) there is no such thing as Xcode 13.

@stoneark
Copy link

Totally same issue, it annoyed me for this whole week. Fortunately the error goes away this afternoon - although I'm not sure it was what that make it work.
My last action is using brew to install rbenv, then use rbenv to install ruby 2.7.7, to replace the 2.7.6 installed by chruby.

@jcavar
Copy link

jcavar commented Dec 4, 2022

We've had this problem in another gem that uses osx_keychain. I think most of this was mentioned above, but I will summarise it all here:

  • osx_keychain gem depends on RubyInline
  • RubyInline allows you to run C code from ruby
  • osx_keychain uses it to interact with keychain API
  • RubyInline generates some boilerplate C file from the code
  • This C file includes ruby.h and uses some symbols from there
  • When you run the gem this C file will get (re)compiled if needed (This is why it works when upgrading from Xcode 13 as the file is already compiled successfully)
  • The linking fails complaining that symbols cannot be found
  • The problem is that the generated clang ld command doesn’t actually link ruby dylib
  • This ld command is generated by RubyInline and takes LDFLAGS from RbConfig

The key to getting it working under Xcode 14 is linking ruby library. We can force do that by specifying LDFLAGS in install command:

CFLAGS=-Wno-error=implicit-function-declaration LDFLAGS=-lruby rbenv install 3.0.3

Why this works under Xcode 13 I am not sure, maybe there was some change in clang's behaviour, but I couldn't find it.

@tritter
Copy link
Contributor

tritter commented Dec 5, 2022

I rewrote the plugin with another ruby-keychain gem. All tests are working too. I just didn't have time to test/implement it in my projects over the weekend (to validate legacy support). Just to let you know! :) #235

@mattneub
Copy link

We solved the problem in our app by switching to another keychain gem, but on behalf of our entire company (unauthorized, this is just me talking) I'd like to thank @orta for making this utility available. It has done good service and our entire build process depended on it for years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests