mac换了m1 pro电脑,原来的pod运行出问题。
旧pod系统不兼容
pod install --repo-update Ignoring ffi-1.12.2 because its extensions are not built. Try: gem pristine ffi --version 1.12.2 Updating local specs repositories
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Command
/usr/local/bin/pod install --repo-update
Report
What did you do?
What did you expect to happen?
What happened instead?
Stack
CocoaPods : 1.10.1
Ruby : ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
RubyGems : 3.0.3.1
Host : macOS 13.0 (22A380)
Xcode : 14.3.1 (14E300c)
Git : git version 2.39.2 (Apple Git-143)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : master - git - https://github.com/CocoaPods/Specs.git @ 1ebb892ec191a2a50cf16d247a22b91a080074ce
trunk - CDN - https://cdn.cocoapods.org/
Plugins
cocoapods-deintegrate : 1.0.4
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.1.0
cocoapods-trunk : 1.4.1
cocoapods-try : 1.1.0
Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '15.0'
target 'tikmc' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for voice timer
pod 'Google-Mobile-Ads-SDK', '~> 10.9.0'
#http network frame for swift
pod 'Alamofire', '~> 5.2'
pod 'CryptoSwift', '~> 1.4.0'
pod 'Kingfisher', '~> 7.0'
end
Error
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/lib/ffi_c.bundle' (no such file), '/Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/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.12.2/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/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.3.1/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-core-1.10.1/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:78:in `deprecated_local_podspecs'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:60:in `preheat_existing_files'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.10.1/lib/cocoapods-core/cdn_source.rb:257:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:135:in `block (3 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:134:in `block (2 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:133:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:133:in `block in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:131:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/sources_manager.rb:131:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:145:in `block in update_repositories'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:143:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:143:in `update_repositories'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:235:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:234:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/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.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
问了ChatGPT,它说是硬件兼容问题,要升级
The error you are seeing is due to the ffi gem not being compatible with your system architecture. You are running on an arm64 architecture but the ffi gem is trying to use x86_64.
You can try to reinstall the ffi gem with the following commands:
gem uninstall ffi
gem install ffi
If the problem persists, you can try to use Rosetta to run terminal in x86_64 mode. To open Terminal in Rosetta mode, find Terminal in Finder, press Command+I to get info, and check the box labeled "Open using Rosetta". Then try running the pod install --repo-update command again.
If none of these solutions work, you might need to install Ruby and CocoaPods using a version manager like rvm or rbenv to ensure compatibility with your system architecture.
于是用
sudo gem uninstall ffi
sudo gem install ffi
升级了ffi, 担心pod可能还有其它问题,同时升级pod
sudo gem install cocoapods
命令卡住了,是gem源问题 于是网上找了下怎么更换gem源
(base) MacBook-Pro-5:~ gem sources -l
ruby-china这个源不行, 中间换了腾讯的也不行, 最后用了阿里的
(base) MacBook-Pro-5:~ $gem sources -a https://mirrors.aliyun.com/rubygems/
https://mirrors.aliyun.com/rubygems/ added to sources
(base) MacBook-Pro-5:~ $gem sources -r https://mirrors.cloud.tencent.com/rubygems/
https://mirrors.cloud.tencent.com/rubygems/ removed from sources
这下安装成功了
(base) MacBook-Pro-5:~ $sudo gem install cocoapods
Password:
Fetching addressable-2.8.5.gem
Fetching cocoapods-downloader-1.6.3.gem
Fetching ruby-macho-2.5.1.gem
Fetching cocoapods-trunk-1.6.0.gem
Fetching cocoapods-core-1.12.1.gem
Fetching xcodeproj-1.22.0.gem
Fetching rexml-3.2.6.gem
Fetching molinillo-0.8.0.gem
Fetching cocoapods-1.12.1.gem
Successfully installed addressable-2.8.5
Successfully installed ruby-macho-2.5.1
Successfully installed rexml-3.2.6
Successfully installed xcodeproj-1.22.0
Successfully installed molinillo-0.8.0
Successfully installed cocoapods-trunk-1.6.0
Successfully installed cocoapods-downloader-1.6.3
Successfully installed cocoapods-core-1.12.1
Successfully installed cocoapods-1.12.1
Parsing documentation for addressable-2.8.5
Installing ri documentation for addressable-2.8.5
Parsing documentation for ruby-macho-2.5.1
Installing ri documentation for ruby-macho-2.5.1
Parsing documentation for rexml-3.2.6
Installing ri documentation for rexml-3.2.6
Parsing documentation for xcodeproj-1.22.0
Installing ri documentation for xcodeproj-1.22.0
Parsing documentation for molinillo-0.8.0
Installing ri documentation for molinillo-0.8.0
Parsing documentation for cocoapods-trunk-1.6.0
Installing ri documentation for cocoapods-trunk-1.6.0
Parsing documentation for cocoapods-downloader-1.6.3
Installing ri documentation for cocoapods-downloader-1.6.3
Parsing documentation for cocoapods-core-1.12.1
Installing ri documentation for cocoapods-core-1.12.1
Parsing documentation for cocoapods-1.12.1
Installing ri documentation for cocoapods-1.12.1
Done installing documentation for addressable, ruby-macho, rexml, xcodeproj, molinillo, cocoapods-trunk, cocoapods-downloader, cocoapods-core, cocoapods after 4 seconds
9 gems installed
不过在pod install时又报了cdn的错
(base) MacBook-Pro-5:tikmc $pod install --repo-update
Updating local specs repositories
[!] CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/deprecated_podspecs.txt Response: URL using bad/illegal format or missing URL
ChatGPT给了我这个答案
You seem to be facing an issue with the Cocoapods trunk. This could be due to a network issue or a temporary problem with the Cocoapods CDN. Here are a few things you could try:
Check your internet connection and try again.
If you're behind a proxy, make sure your terminal is set up to work with it.
Try resetting your Cocoapods master repo with the following commands:
pod repo remove master
pod setup
pod install
If the problem still persists, you can temporarily change the CDN url to the git repo url in your Podfile as follows:
source 'https://github.com/CocoaPods/Specs.git'
Then run pod install again.
Remember to change it back to the CDN url when the issue is resolved.
结合stack overflow这篇这个帖子 stackoverflow.com/questions/6…
最终尝试在podfile中添加了这一行解决了
source 'github.com/CocoaPods/S…'
加在podfile的开头
# Uncomment the next line to define a global platform for your project
platform :ios, '15.0'
source 'https://github.com/CocoaPods/Specs.git'