Ruby
First, check the local Ruby environment. The version of the system may be a little old. It is recommended to install the new Version of Ruby
For users who simply use Ruby and do not do version compatibility. It is recommended to install Ruby using BREW
➜ ~ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
Copy the code
-
Install Ruby via Homebrew
The brew install [email protected]Copy the code
After the installation is successful, run ruby -v to view the version information. If the version is still old, you need to add system environment variables
Select.zshrc or.bash_profile, depending on your situation, and add the following line
The export PATH = "/ usr/local/Cellar/[email protected]/2.7.2 / bin: $PATH." "Copy the code
To take effect
ZHSRC or source ~/.bash_profileCopy the code
-
Install Ruby using RVM
-
Install the rv ‘m
curl -sSL https://get.rvm.io | bash -s stable Copy the code
-
Install ruby
RVM install ruby - 2.7.2Copy the code
-
Switch version
RVM 2.7.2 -- current && defaultCopy the code
-
Cocoapods source
-
Create a folder. Here, rubyDebug is used as an example
-
Download the source code of Cocoapods
git clone https://github.com/CocoaPods/CocoaPods.git Copy the code
Because what I need to debug here is version 1.9.3. So after the download is complete, switch to the corresponding tag
Git checkout 1.9.3Copy the code
-
Go to the Cocoapods folder and run bundle install to install the gem component
bundle install Copy the code
This step may take a long time, or some components may fail to download. There are two solutions:
-
Retry the bundle install
-
For the failed component, select the corresponding version to download from Github, and change the dependencies of Gemfile to the local library.
For example:
For example, if you failed to download Cocoapods-core, you can see that the dependent version is 1.9.3 through the gemfile. lock in the Cocoapods folder
Cocoapods - core (= 1.9.3)Copy the code
So I went to Github to download the corresponding library locally and put it in the same directory. The directory structure is as follows: Core-1.9.3 is the newly downloaded Core library
Then modify the Gemfile file under the Cocoapods file
group :development do cp_gem 'claide'.'CLAide' cp_gem 'cocoapods-core'.'the Core - 1.9.3'.path: true cp_gem 'cocoapods-deintegrate'.'cocoapods-deintegrate' cp_gem 'cocoapods-downloader'.'cocoapods-downloader'.path: true cp_gem 'cocoapods-plugins'.'cocoapods-plugins' cp_gem 'cocoapods-search'.'cocoapods-search' cp_gem 'cocoapods-stats'.'cocoapods-stats' cp_gem 'cocoapods-trunk'.'cocoapods-trunk' cp_gem 'cocoapods-try'.'cocoapods-try' cp_gem 'molinillo'.'Molinillo' cp_gem 'nanaimo'.'Nanaimo' cp_gem 'xcodeproj'.'Xcodeproj - 1.16.0'.path: true Copy the code
Change the second parameter repo_name to the name of the folder you downloaded, such as core-1.9.3, and add path: true, which means to find the file locally.
After that, proceed to bundle install and see information such as the following
In this step may encounter a lot of problems, which library has problems really can not try to download to the local retry. Be patient!
If you need to debug other components, you are advised to download them to the local PC and modify the reference to Gemfile. Convenient breakpoints.
-
RubyMine configuration
-
Open the rubyDebug folder from RubyMine
-
To configure debugging information, click Add Configuration -> Add -> Ruby in the upper right corner
-
Run script
Script path, because it is local debugging, so select your own Cocoapods/bin pod command
-
Script arguments
Script parameters. Fill in install here, and the compiler will find the pod filled in in the previous step, and then execute pod install. If you need to debug other execution, modify this
-
Working directory
Where the command is executed. Select example, which is the default given by Cocoapods, and select AFN. The runtime executes pod Install in this directory
-
Ruby SDK
Here we choose our own installed Ruby-2.7.2.
If there is no Ruby here that we downloaded. Open Preferences, search for Ruby SDK and Gems, and add the Ruby path you downloaded
-
-
Finally Apply the Apply configuration and click OK to complete the configuration
debugging
-
After the above configuration is complete, set a breakpoint in install.rb as shown in the figure above
-
Click the debug button in the upper right corner. The XXXX /Cocoapods/bin/pod install command is automatically executed in the preceding working directory. Breakpoint execution, success