swfit源码编译

编译环境

mac 10.15.4
Xcode: 11.6
python: 2.7 3.7均有
ninja:brew install ninja
CMake:brew install CMake

编译步骤:(如前两步未成功,可直接跳转第三步)
1. clone swift源码
git clone --branch swift-5.3.1-RELEASE https://github.com/apple/swift.git
2. update-checkout(这步clone编译swift相关的库,非常关键,一定要成功!!!!)
./swift/utils/build-script -r --debug-swift-stdlib --lldb
3. 采用ninja编译

如果前两步未成功,则将前两步拉下来的源码直接下载到本地硬盘,继续执行以下命令进行编译操作

./swift/utils/build-script -r --debug-swift-stdlib --lldb
4、使用VSCode调试Swift
  1. 安装插件codelldb
    在这里插入图片描述

  2. 添加配置文件launch.json,并修改
    在这里插入图片描述
    文件内容如下, 确保与你编译的文件路径一致

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}/build/Ninja-RelWithDebInfoAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin/swift",
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}

点击debug运行,看到
在这里插入图片描述
过掉断点,继续看到如下结果便是运行成功了
成功示例

可能会出现的问题
  • 断点过程中,vscode不显示变量信息(左侧红圈标注)

    解决办法:

1、将 编译后的源码项目路径/build/Ninja-RelWithDebInfoAssert+stdlib-DebugAssert/lldb-macosx-x86_64/bin/里的内容拷贝到~/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/bin/路径下
2、拷贝编译后的源码项目路径/build/Ninja-RelWithDebInfoAssert+stdlib-DebugAssert/lldb-macosx-x86_64/bin/lldb文件到~/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/路径下, 并将文件重命名为liblldb.dylib,替换原有存在的liblldb.dylib文件

  • import six No module named six

解决:pip3 install six

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值