swift源码调试操作指引

2,140 阅读1分钟

环境

  • macOS:10.15
  • Xcode 11.1
  • cmake 3.19.1
  • Python 2.7.16
  • ninja 1.10.2

clone

export https_proxy="your agent"
mkdir swift-source
cd swift-source
git clone -b swift-5.2.4-RELEASE https://github.com/apple/swift.git
./swift/utils/update-checkout --clone --tag swift-5.2.4-RELEASE

build

./swift/utils/build-script -r --debug-swift-stdlib --xcode

debug

  • 1、打开Swift.xcodeproj
cd swift-source/build/Xcode-RelWithDebInfoAssert+stdlib-DebugAssert/swift-macosx-x86_64
open Swift.xcodeproj -a /Applications/Xcode.app
  • 2、scheme弹窗选择auto

  • 3、选中scheme swift

  • 4、edit scheme,Build Configuration 选择RelWithDebugInfo

  • 5、run swift-run

  • 6、新建target swift001,添加依赖 swift001-添加依赖

  • 7、测试代码

  • 8、设置断点 swift001-设置断点

  • 9、edit scheme swift001,修改Build Configuration 为RelWithDebugInfo

  • 10、run,append方法走到swift源码中的断点 swift001-走到断点

参考