Install CocoaPods to Mac
how-to-install-xcode-homebrew-git-rvm-ruby-on-mac
https://gorails.com/setup/macos/13-ventura
- Install ruby manager chruby
$ brew install chruby ruby-install
- Install the latest ruby using ruby-install
brew config // CLT: N/A // Xcode: 14.1 // If you see "14" in CLT or XCode $ ruby-install ruby -- --enable-shared // Install latest or $ ruby-install 2.7.5 -- --enable-shared // Install a specific version // If not $ ruby-install ruby // Install latest or $ ruby-install 2.7.5 // Install a specific version
- Add lines into ~/.zshrc file
Remember to change 2.7.5 version number to your appropriate one
source /usr/local/opt/chruby/share/chruby/chruby.sh source /usr/local/opt/chruby/share/chruby/auto.sh chruby ruby-2.7.5
$ source ~/.zshrc $ ruby -v. # Make sure it returns 2.7.5
- Install gem cocoapods
$ sudo gem install cocoapods
$ pod setup --verbose
Create pod file
- Close XCode
- Run following command inside project folder
$ pod init
Add library
Add Bluecap into Pod file
# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'SimpleBleCentral' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for SimpleBleCentral pod 'BlueCapKit', '~> 0.7' end
Install
$ pod install
*.xcworkspace file is created
From now on, open xcworkspace file to develop iOS project
How to change Swift version of a Pod library?
Add the following script at the end of Podfile, outside any block else
post_install do |installer| installer.pods_project.targets.each do |target| # You can add as many as pod libraries you like if ['KleanroomLogger', 'ActiveLabel', 'Kingfisher'].include? target.name target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '4.0' end end end end
Issues
error Your Ruby version is 3.1.2, but your Gemfile specified 2.7.5
This happens in React Native setup
- Install this ruby version
brew config // CLT: N/A // Xcode: 14.1 // If you see "14" in CLT or XCode $ ruby-install 2.7.5 -- --enable-shared // Install a specific version // If not $ ruby-install 2.7.5 // Install a specific version
- (Optional) If you get error ld: symbol(s) not found for architecture x86_64
brew install openssl --force
// Link openssl after install brew link openssl@3
// If you see "14" in CLT or XCode $ ruby-install 2.7.5 -- --enable-shared // Install a specific version // If not $ ruby-install 2.7.5 // Install a specific version
- Change ~/.zshrc
source /usr/local/opt/chruby/share/chruby/chruby.sh source /usr/local/opt/chruby/share/chruby/auto.sh chruby ruby-2.7.5 #chruby ruby-3.1.2
source ~/.zshrc
- Check ruby version
$ chruby * ruby-2.7.5 ruby-3.1.2
How to run Intel iOS project on XCode of M1 Mac?
Add the following lines into podfile
post_install do |installer| ... installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end ... end
Leave a Reply