使用 VSCode debug CocoaPods 和插件源码
gem install ruby-debug-ide
gem install debase
Gemfile
in project root and add the following content to itgem 'cocoapods', path: 'path/to/cocoapods/'
gem 'cocoapods-binary', path: 'path/to/cocoapods-binary/'
gem 'ruby-debug-ide'
gem 'debase'
bundle install
.vscode/launch.json
in project root{
"configurations": [{
"name": "Debug CocoaPods Plugin with Bundler",
"showDebuggerOutput": true,
"type": "Ruby",
"request": "launch",
"useBundler": true,
"cwd": "${workspaceRoot}/Testing",
"program": "${workspaceRoot}/cocoapods/bin/pod",
"args": ["install"]
}
}
Debug - Start Debugging
Don't waste your time! Use bundler now!
git clone https://github.com/CocoaPods/CocoaPods.git
git checkout `pod --version`
.vscode/launch.json
in CocoaPods' root folder{
"configurations": [{
"name": "Debug CocoaPods Plugin",
"showDebuggerOutput": true,
"type": "Ruby",
"request": "launch",
"cwd": "path/to/podfile/dir", // where the `pod` command execute (the folder should contain a `Podfile`)
"program": "${workspaceRoot}/bin/pod",
"args": ["install"] // `pod` command arguments
}]
}
bin/pod:L27 (# require 'bundler/setup')
Debug - Start Debugging
.vscode
to this folder.vscode/launch.json
cwd
: where the pod
command execute (the folder should contain a Podfile
)pluginPath
: path to the pluginargs
: pod
command argumentscocoapods/bin/pod:L27
require 'bundler/setup
to require_relative '../../.vscode/plugin_patch'
, just like this
Debug - Start Debugging
The CocoaPods version in this repository is
1.8.0.beta.1
, incase some version incompatible issue with CocoaPods-Core or other gems, you should install this version's CocoaPods in your Mac too
cocoapods/lib/cocoapods/command/install.rb:L46
cocoapods-binary/lib/cocoapods-binary/Main.rb:L101
Debug - Start Debugging
If you have any question, don't hesitate to fire a issue 😉
Appreciate a 🌟 if you like it.