下載pod源碼
工程目錄如下
先忽略TestLibrary
目錄下的Podfile.lock、Pods、TestLibrary.xcworkspace
文件
NM1tloXcveDrx3B.png
創建Gemfile文件
新建TestLibrary
xcode 工程,并創建一個Podfile
文件(不要執行pod install
)。
platform :ios, '10.0'
use_frameworks!
target 'TestLibrary' do
pod 'AFNetworking'
end
將Cocoapods
源碼和Xcode
工程放到同一目錄下,并在該目錄下新建一個Gemfile
文件(ps:bundle init
)
安裝bundle(已安裝可以忽略)
gem install bundler
編寫Gemfile
source 'https://rubygems.org'
# 指定本地CocoaPods路徑
gem 'cocoapods', path: './CocoaPods'
# Ruby調試的依賴庫
gem 'ruby-debug-ide'
gem 'debase'
創建 launch.json
用VSCode
打開目錄文件夾,在根目錄下,新建.vscode
文件夾,在.vscode
文件夾下,新建launch.json
文件,目錄結構如下所示。
xderk8W6CKJLsfu.png
在 launch.json
中,配置程序啟動參數:
{
"configurations": [
{
"name": "Debug CocoaPods Plugin",
"showDebuggerOutput": true,
"type": "Ruby",
"request": "launch",
"useBundler": true,
// pod 命令執行的路徑。會在該路徑下尋找Podfile文件。
"cwd": "${workspaceRoot}/TestLibrary",
// 指定使用的pod解釋文件。
"program": "${workspaceRoot}/CocoaPods/bin/pod",
// 執行的命令參數,在這里執行的是 pod install --verbose
"args": ["install", "--verbose"]
}]
}
執行bundle install
- 創建好工程依賴后,在終端執行
bundle install
- 在
Podfile
里面設置一個斷點 -
Debug
調試(F5)
7wzRovSxFqrTOmg.png
dbClHmjWz8r5YKJ.png
到此就能夠完成調試了
常見問題
[!] No Podfile' found in the project directory.
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
在 .bash_profile
或者.zshrc
文件里面,添加export LANG=en_US.UTF-8
即可解決這個問題。
如果還不行,請重啟終端和vscode