The environment

  • 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 - RELEASECopy the code

build

./swift/utils/build-script -r --debug-swift-stdlib --xcode
Copy the code

debug

  • 1. Open Swift. Xcodeproj
cd swift-source/build/Xcode-RelWithDebInfoAssert+stdlib-DebugAssert/swift-macosx-x86_64
open Swift.xcodeproj -a /Applications/Xcode.app
Copy the code
  • 2. Select Auto in the scheme pop-up window

  • 3. Select Scheme Swift
  • 4. Edit Scheme,Build Configuration select RelWithDebugInfo

  • 5, the run

  • 6. Create target Swift001 and add dependencies

  • 7. Test code

  • 8. Set breakpoints

  • Edit Scheme Swift001, change Build Configuration to RelWithDebugInfo
  • 10, Run, append method to swift source breakpoint

reference

  • Swift – 5.3.1 – RELEASE the README
  • Swift source code compilation – make the bottom layer clearer
  • How to read the source code in the Swift standard library