Coder Social home page Coder Social logo

x140yu / debug_cocoapods_plugins_in_vscode Goto Github PK

View Code? Open in Web Editor NEW
66.0 2.0 14.0 2.7 MB

Home Page: https://zxy.vercel.app/debug-cocoapods-with-vscode

Ruby 98.47% Swift 1.00% Objective-C 0.03% Python 0.44% Shell 0.05%
cocoapods cocoapods-plugin debugging-cocoapods vscode

debug_cocoapods_plugins_in_vscode's Introduction

Debug CocoaPods & Plugins in VSCode

中文版本点这里

使用 VSCode debug CocoaPods 和插件源码

Debug cocoapods

Debug plugin

Pre-requirements

Install Debug Gems

gem install ruby-debug-ide
gem install debase

Install VSCode Ruby Plugin

Ruby

Debug With bundler

  • Create a Gemfile in project root and add the following content to it
gem 'cocoapods', path: 'path/to/cocoapods/'
gem 'cocoapods-binary', path: 'path/to/cocoapods-binary/'
gem 'ruby-debug-ide'
gem 'debase'
  • run bundle install
  • Create .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"]
    }
}
  • Add some breakpoint within VSCode
  • Press F5 or hit menu Debug - Start Debugging

Debug without bundler

Don't waste your time! Use bundler now!

Debug CocoaPods

git clone https://github.com/CocoaPods/CocoaPods.git
  • Checkout cloned repo to match the version you have installed on your laptop
git checkout `pod --version`
  • Create .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
  }]
}
  • Comment bin/pod:L27 (# require 'bundler/setup')
  • Add some breakpoint within VSCode
  • Press F5 or hit menu Debug - Start Debugging

Debug CocoaPods & plugin

  • Create a new folder, all actions below are under this folder
  • Clone & checkout CocoaPods source code
  • Clone or create a CocoaPods plugin
  • Copy .vscode to this folder
  • Make some changes in .vscode/launch.json
    • cwd: where the pod command execute (the folder should contain a Podfile)
    • pluginPath: path to the plugin
    • args: pod command arguments
  • Change cocoapods/bin/pod:L27
    • From require 'bundler/setup to require_relative '../../.vscode/plugin_patch', just like this
  • Add some breakpoint within VSCode
  • Press F5 or hit menu Debug - Start Debugging

Example of debugging CocoaPods & plugin

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

  • Clone this repository
  • Open it with VSCode
  • Add a breakpoint somewhere you like to explore
    • eg. cocoapods/lib/cocoapods/command/install.rb:L46
    • eg. cocoapods-binary/lib/cocoapods-binary/Main.rb:L101
  • Press F5 or hit menu Debug - Start Debugging
  • All set 🌸

If you have any question, don't hesitate to fire a issue 😉

Appreciate a 🌟 if you like it.

debug_cocoapods_plugins_in_vscode's People

Contributors

dependabot[bot] avatar x140yu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

debug_cocoapods_plugins_in_vscode's Issues

vscode设置了端点debug下没有暂停

cocoapods/lib/cocoapods/command/install.rb:L46 为例设置了断点,vscode debug 有输出Fast Debugger (ruby-debug-ide 0.7.2, debase 0.2.4.1, file filtering is supported) listens on 127.0.0.1:1234但是设置的断点没有暂停

求助:gem install bundler

提示路径找不到
JiaweideMacBook-Pro:gittest jiaweidong$ bundle install
The path /Users/jiaweidong/Desktop/version/2.0.1/gittest/path/to/cocoapods
does not exist.

萌新求助:请问楼主怎么处理?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.