Ad Hoc distribution fail for React Native project

789 Views Asked by At

The app thinning fails with: The operation couldn’t be completed. (AppThinning.StubError error 1.)

XCode version: 14.2 (14C18) Device: Macbook Air M1

In logs there is something that looks like an error:

2023-04-05 07:45:24 +0000  Output: ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]
/Applications/Xcode.app/Contents/SharedFrameworks/AppThinning.framework/Resources/ipatool:4135: warning: assigned but unused variable - prev
/Library/Ruby/Gems/2.6.0/gems/CFPropertyList-3.0.6/lib/cfpropertylist/rbCFPropertyList.rb:83: warning: assigned but unused variable - temp
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/date-3.3.3/lib/date_core.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/date-3.3.3/lib/date_core.bundle' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64))) - /Library/Ruby/Gems/2.6.0/gems/date-3.3.3/lib/date_core.bundle (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/date-3.3.3/lib/date.rb:4:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/CFPropertyList-3.0.6/lib/cfpropertylist/rbCFPropertyList.rb:4:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:65:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/CFPropertyList-3.0.6/lib/cfpropertylist.rb:3:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
    from /Applications/Xcode.app/Contents/SharedFrameworks/AppThinning.framework/Resources/ipatool:15:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- cfpropertylist (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Applications/Xcode.app/Contents/SharedFrameworks/AppThinning.framework/Resources/ipatool:15:in `<main>'
2023-04-05 07:45:24 +0000  JSON: error: Error Domain=NSCocoaErrorDomain Code=260 "The file “ipatool.json” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/var/folders/_l/gkxd9_pd1tg8qgd4rtxxy5kw0000gn/T/IPATool.bIAtDE9/ipatool.json, NSUnderlyingError=0x60000be9e280 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

I've tried installing this date gem by running sudo arch -x86_64 gem install date

but I also have rbenv setup and in uses different version of ruby (3.2.1). But still this command has failed with

Undefined symbols for architecture x86_64:
"_rb_alloc_tmp_buffer_with_count", referenced from:
      _s3e in date_parse.o
      _read_digits in date_strptime.o
  "_rb_ary_new_capa", referenced from:
      _Init_date_core in date_core.o
  "_rb_ary_new_from_args", referenced from:
      _d_lite_marshal_dump in date_core.o
      _rt_complete_frags in date_core.o
  "_rb_ary_push", referenced from:
      _Init_date_core in date_core.o
  "_rb_backref_get", referenced from:
      _date__parse in date_parse.o
      _date__iso8601 in date_parse.o
      _date__rfc3339 in date_parse.o
      _date__xmlschema in date_parse.o
      _date__rfc2822 in date_parse.o
      _date__httpdate in date_parse.o
      _date__jisx0301 in date_parse.o
      ...
1

There are 1 best solutions below

1
anothermh On

You are running an x86_64 version of Ruby rather than arm64. You can tell from this line:

ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]

And this line:

(have (arm64), need (x86_64))) - /Library/Ruby/Gems/2.6.0/gems/date-3.3.3/lib/date_core.bundle (LoadError)

Additionally you say you've installed Ruby 3.2.1 through rbenv but all your error messages are referencing system Ruby with version 2.6.8 -- the version that ships with macOS -- and not rbenv's version.

You've gotten yourself into a deep hole. You've managed to mix up:

  • System Ruby and rbenv Ruby and their libraries
  • x86_64 and arm64 versions of Ruby and their libraries
  • sudo installed libraries and non-sudo installed libraries

Any one of those on their own is a painful process to unwind. All three at once is kind of a nightmare. While the following instructions are meant to help dig you out of the hole that you're in they aren't 100% prescriptive and some will apply to your situation and some may not. I suggest using these as a framework to troubleshoot and resolve the problems you're having.

First off, it's safe to assume that you did not properly and completely follow the installation instructions for rbenv. You should:

  1. Uninstall rbenv completely
  2. Restart your terminal/shell
  3. Run arch and ensure it says arm64

If you see i386 then your Terminal is running with Rosetta emulation and that needs to be disabled so that all your commands run as native arm64 commands. To fix this:

  • Open Finder and browse to /Applications/Utilities
  • Right-click Terminal and click Get Info
  • In the window that opens uncheck the box Open using Rosetta
  • Quit Terminal completely (Terminal menu > Quit Terminal)
  • Re-open Terminal
  • Run arch again and confirm it says arm64

Then continue with the following steps:

  1. Run gem uninstall -aIx to uninstall all the gems that you previously installed under system Ruby
  2. Run sudo gem uninstall -aIx to uninstall all the gems that you previously installed using sudo (and then never use sudo ever again when running any kind of Ruby commands; using sudo has been a major contributor to your problems and will break things)
  3. Reinstall rbenv and carefully follow every instruction to the letter, especially when it comes to configuring your shell
  4. Restart your terminal/shell
  5. Run which ruby to confirm it is pointing to rbenv's version of Ruby
  6. Make whatever configuration you need to make in Xcode to ensure it is pointing at your rbenv version of Ruby and not at system Ruby
  7. Retry your original operation

One last thing to take into consideration is that the operation that you're running may be starting a non-interactive shell and not loading your shell configuration. If your shell configuration isn't loaded then rbenv won't be loaded and when that shell looks for ruby it's going to find system Ruby, which you don't want to have happen. You may have to do this operation manually in a terminal window rather than automatically to ensure it loads through an interactive shell.

It's also possible that it's loading an alternative shell, like bash, when your normal shell is zsh. If that's the case then when you're configuring rbenv you need to follow the instructions for both bash and zsh so that when it loads bash it also loads rbenv. (or for any other shells you might be using instead)