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

CocoaPods compatibility with Apple DTK (Apple Silicon) #9907

Closed
MatrixSenpai opened this issue Jul 8, 2020 · 146 comments
Closed

CocoaPods compatibility with Apple DTK (Apple Silicon) #9907

MatrixSenpai opened this issue Jul 8, 2020 · 146 comments
Labels
AppleSilicon Issues related to newly introduced Apple's Silicon

Comments

@MatrixSenpai
Copy link

MatrixSenpai commented Jul 8, 2020

Currently, libffi +Ruby v2.6.0 seems to have some issues with Apple's DTK. Multiple development tools, including Homebrew (ref Homebrew/brew#7857) seem to have issues working. Some have workarounds, but the core seems to be hidden somewhere in libffi (ref libffi/libffi#571)

I will make sure to keep this issue up to date with fixes from libffi and anything else i can find.

I received my DTK yesterday, and will try to create a fork of libffi and get it to build. As mentioned in the linked ffi issue, support for arm64 already exists, and may just need to be fixed to apply to DTK/macOS devices. Assuming I can get it to work, I will also create a fork for CP with the working version of libffi and try to get it to build.

I believe this issue is also related to #9896 & #9890
edit: add related issue

@dnkoutso
Copy link
Contributor

dnkoutso commented Jul 8, 2020

Yes this was also filed as #9890 and was closed as this is an issue with the ffi gem that should be fixed.

Thanks for the work and effort here.

@MatrixSenpai
Copy link
Author

MatrixSenpai commented Jul 8, 2020

Cool. Would you mind leaving this one open and/or pinning while I work on a fix? I'll tie it to a PR, and that way people who come looking for answers know a fix is in the works

@segiddins
Copy link
Member

Working on the FFI gem here: https://github.com/segiddins/ffi/pull/1/files

@dnkoutso
Copy link
Contributor

dnkoutso commented Jul 8, 2020

@MatrixSenpai yes keeping this open.

@dnkoutso dnkoutso added the AppleSilicon Issues related to newly introduced Apple's Silicon label Jul 8, 2020
@amorde amorde pinned this issue Jul 9, 2020
@armen-outco
Copy link

armen-outco commented Jul 9, 2020

Seems the workaround suggested by @mskrischke works.

#9890 (comment)
Screen Shot 2020-07-08 at 10 29 16 PM

Update

https://armen-mkrtchian.medium.com/run-cocoapods-on-apple-silicon-and-macos-big-sur-developer-transition-kit-b62acffc1387

@Armenm
Copy link

Armenm commented Jul 10, 2020

❗ WORKAROUND ❗
Wrote a small post. My first published post :) https://armen-mkrtchian.medium.com/run-cocoapods-on-apple-silicon-and-macos-big-sur-developer-transition-kit-b62acffc1387

@MatrixSenpai
Copy link
Author

Please note that these are workarounds. And while they do help the community get up and running, this isn't an actual fix, but a temporary bandaid.
Realistically, we won't have a fix until libffi is up to date

@Armenm
Copy link

Armenm commented Jul 10, 2020

Hey @MatrixSenpai. Yes, these are totally workarounds.
However, I wanted to post it here so other people who received their DTKs and are excited as much as me, will be able at least to get their apps running.

I hope the fix for the libffi will be there soon. 🤞

p.s
I have updated the previous comment with a more clear workaround tag.

@stale
Copy link

stale bot commented Oct 11, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

@stale stale bot added the s1:awaiting input Waiting for input from the original author label Oct 11, 2020
@MatrixSenpai
Copy link
Author

I haven't checked on CP recently, been writing on my own machine recently instead of the DTK. Anyone else have any updates? I'd assume a new libffi has been put out...

@jacobokoenig
Copy link

jacobokoenig commented Nov 18, 2020

Hi, I have tried the workaround of running terminal with Rosetta with an actual Mac that runs on M1, and the error is the same. Posting it here in case someone else is also having this issue.

Trying to run pod install (directly) on a Flutter project. The error is as follows:

Command

/usr/local/bin/pod install

Report

  • What did you do?
    Run pod install on a Flutter project

  • What did you expect to happen?
    Pods should be installed

  • What happened instead?
    Error below

Stack

   CocoaPods : 1.10.0
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
    RubyGems : 3.0.3
        Host : macOS 11.0 (20A2411)
       Xcode : 12.2 (12B45b)
         Git : git version 2.24.3 (Apple Git-128)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : 

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-trunk       : 1.5.0
cocoapods-try         : 1.2.0

Podfile

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    target.build_configurations.each do |config|
    config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',

        ## dart: PermissionGroup.calendar
        'PERMISSION_EVENTS=0',

        ## dart: PermissionGroup.reminders
        'PERMISSION_REMINDERS=0',

        ## dart: PermissionGroup.contacts
        'PERMISSION_CONTACTS=0',

        ## dart: PermissionGroup.camera
        # 'PERMISSION_CAMERA=0',

        ## dart: PermissionGroup.microphone
        'PERMISSION_MICROPHONE=0',

        ## dart: PermissionGroup.speech
        'PERMISSION_SPEECH_RECOGNIZER=0',

        ## dart: PermissionGroup.photos
        # 'PERMISSION_PHOTOS=0',

        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        # 'PERMISSION_LOCATION=0',

        ## dart: PermissionGroup.notification
        # 'PERMISSION_NOTIFICATIONS=0',

        ## dart: PermissionGroup.mediaLibrary
        'PERMISSION_MEDIA_LIBRARY=0',

        ## dart: PermissionGroup.sensors
        'PERMISSION_SENSORS=0'
      ]
    end
  end
end

Error

LoadError - dlsym(0x7fbbeb6837d0, Init_ffi_c): symbol not found - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Nov 18, 2020
@jacobokoenig
Copy link

For anyone else struggling with this issue, I just found a way to solve it. In addition to running terminal in Rosetta (see above), I installed a gem that seems to be related to the symbol not found in the error:

sudo gem install ffi

After doing this, cocoapods runs as expected.

@aovestdipaperino
Copy link

@jacobokoenig incredible timing.

@EthanDamien
Copy link

EthanDamien commented Nov 22, 2020

I am having the same problem right now, even after I tried sudo gem install ffi. After running pod install after the fact I am getting an error where it says "No Podfile found in the project directory" when there clearly is one. Also, I am using flutter so I believe it may need a different approach to my problem.

Also, I am coming from a windows workspace and am very new to Mac in general, and I'm still a beginner developer so I apologize if this seems a little informal in terms of issue reporting. I've just been thrust into the world of mac so I've been working out issues all day.

@whitehat007
Copy link

whitehat007 commented Nov 24, 2020

I was able to get generic pod commands to work (i.e., pod env, pod setup, etc), but anytime I try to run an install or update command I get the following error:

mattc@Matts-DTK-Mac:Dollar Game > pod install --verbose                                                                                                                                                                                                         Preparing

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Dollar Game`: (``)
  Using `ARCHS` setting to build architectures of target `Pods-Dollar Game Tests`: (``)

Finding Podfile changes
  A GoogleMobileAdsMediationFacebook
  A GoogleMobileAdsMediationUnity
  - Firebase
  - Google-Mobile-Ads-SDK

Resolving dependencies of `Podfile`
[!] Couldn't determine repo type for URL: `https://github.com/CocoaPods/Specs.git`: Invalid ABI specified

/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:83:in `rescue in cdn_url?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:72:in `cdn_url?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'                                                                                                                                                                                                                                          /1.2s

@segiddins
Copy link
Member

@whitehat007 my guess is that's an issue with ethon interacting with libcurl via ffi

@NTJ3
Copy link

NTJ3 commented Jul 26, 2021

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

This works for Apple M1 Chip. Confirmed.

It's Works for me

@FlyKite
Copy link

FlyKite commented Jul 28, 2021

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

This works for Apple M1 Chip. Confirmed.

This works for me too! thx

@MelMayssonOwen
Copy link

gem uninstall -aIx
and
brew install cocoapods

works for me

@Chaarangan
Copy link

sudo arch -x86_64 gem install ffi

Then

arch -x86_64 pod install

This works for Apple M1 Chip. Confirmed.

This works for me too! Thanks

@arkthur
Copy link

arkthur commented Sep 22, 2021

Note. The entire installation process can be completed without Rosetta. Here's what I did after getting M1.

  1. Ensure OS is updated to macOS Big Sur 11.3.1
  2. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. brew install cocoapods

Here's all the related components version

xxx@yyy-MacBook-Pro ~ % brew --version
Homebrew 3.1.5
Homebrew/homebrew-core (git revision 1220c78920; last commit 2021-05-08)
xxx@yyy-MacBook-Pro ~ % pod --version
1.10.1

Works like a charm 🪄

@wallacerenan
Copy link

Is it still needed in current versions and native react 0.66?

@amiralidev
Copy link

amiralidev commented Nov 3, 2021

  1. right click on your terminal, then choose open with rosetta
  2. after that install sudo gem install ffi

@Armenm
Copy link

Armenm commented Nov 5, 2021

What's the current state. Is this still a helpful solution?

❗ WORKAROUND ❗
Wrote a small post. My first published post :) https://armen-mkrtchian.medium.com/run-cocoapods-on-apple-silicon-and-macos-big-sur-developer-transition-kit-b62acffc1387

@devethan
Copy link

devethan commented Nov 8, 2021

Hey, you just uninstall all of cocoapods installed with gem, then try to install with brew.

sudo gem uninstall cocoapods

brew install cocoapods

That's all.

@mesqueeb
Copy link

mesqueeb commented Nov 16, 2021

@devethan I just got my M1, and have today installed cocoapods with brew install cocoapods

it has in turn installed ruby as a dependency it seems. I have no other ruby related code nor rvm or anything.

Yet my Capacitor project still fails at the cocoapods step:

✖ Updating iOS native dependencies with pod install - failed!
✖ update ios - failed!
[error] ERR_SUBPROCESS_NON_ZERO_EXIT

Do you have any advice for me? I'd rather not install weird rosetta builds of Cocoapods and mess up my system.

PS: cocoapods seem to work, but something about ffi

@itsmefordyfy-changingdigital

Hey, you just uninstall all of cocoapods installed with gem, then try to install with brew.

sudo gem uninstall cocoapods

brew install cocoapods

That's all.

Confirm working in M1 Max

kito99 pushed a commit to kito99/capacitor-site that referenced this issue Mar 8, 2022
Ruby gem installation is a pain for CocoaPods on Apple Silicon Macs. Brew  works for Apple Silicon Macs (and presumably for Intel Macs as well). See: CocoaPods/CocoaPods#9907 (comment).
@NatanCieplinski
Copy link

Hey, you just uninstall all of cocoapods installed with gem, then try to install with brew.

sudo gem uninstall cocoapods

brew install cocoapods

That's all.

Works for me too, Thanks!

@AntonBelousov
Copy link

AntonBelousov commented Jul 8, 2022

I have the same issue (with ffi) on my M1 when I try to push my private pod to private repo
pod repo push [repo_name] [spec].podspec

It seems it tries to pull trunk repo (don't know why) and failed. After it any pod ... command fails, but if I delete folder ~/.cocoapods/repos/trunk pod ... commands work well

UPD. this happens, when I have dependencies in subspec (!) in my private podspec

@sunshiningsoo
Copy link

sunshiningsoo commented Nov 20, 2022

In my case this problem came out after I updated my Xcode version to 14.0.1 (m1 pro)

lots of terminal command didn't work to me, like brew install cocoapods, sudo gem install cocoapods..

so I just down my project format from Xcode 14.0 to Xcode 13.0 and it works well!
202895193-088ee1bd-7e98-411d-a2c0-ff0407e9a70a

hope you guys get some clue of this problem..🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AppleSilicon Issues related to newly introduced Apple's Silicon
Projects
None yet
Development

No branches or pull requests