cocoapods-keys: Problem with XCode 14 and m1 mac.

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.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 4
  • Comments: 18 (2 by maintainers)

Most upvoted comments

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! 😃 https://github.com/orta/cocoapods-keys/pull/235

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.

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.

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. 🤷‍♂️

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.