在 VSCode 中开发 Swift 项目需要配置 SweetPad、触发任务、Swift 和 CodeLLDB。如果您在 VSCode 中打开 Xcode 项目,将会提示您准备 Swift 开发环境。您也可以通过按 (Cmd Shift P) > (Help: Welcome) 进行设置,或者按照以下详细步骤进行配置:
要确保您拥有使用 SweetPad 工作所需的所有必要工具,请运行以下命令,使用 Homebrew 安装所需软件:
# 如果尚未安装 Homebrew,请先安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
然后安装以下工具:
# 安装 swift-format
brew install swift-format
# 安装 XcodeGen
brew install xcodegen
# 安装 SwiftLint
brew install swiftlint
# 安装 xcbeautify
brew install xcbeautify
# 安装 xcode-build-server
brew install xcode-build-server
# 安装 ios-deploy
brew install ios-deploy
# 安装 tuist
brew install --cask tuist
{
"triggerTaskOnSave.tasks": {
"sweetpad: build": [
"**/*.swift"
]
},
"triggerTaskOnSave.on": true,
"triggerTaskOnSave.showNotifications": false,
"triggerTaskOnSave.restart": true,
"triggerTaskOnSave.delay": 1000,
"triggerTaskOnSave.resultIndicatorResetTimeout": 5,
"workbench.colorCustomizations": {},
"sweetpad.format.args": [
"--in-place",
"--configuration",
".vscode/.swift-format",
"${file}"
],
"[swift]": {
"editor.defaultFormatter": "sweetpad.sweetpad",
"editor.formatOnSave": true,
}
}
{
"indentation" : {
"spaces" : 4
},
"insertSpaces" : true,
"spacesAroundRangeFormationOperators" : false,
"tabWidth" : 8,
"version" : 1
}
{
"version": "0.2.0",
"configurations": [
{
"type": "sweetpad-lldb",
"request": "launch",
"name": "Attach to running app (SweetPad)",
"preLaunchTask": "sweetpad: launch"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"type": "sweetpad",
"action": "build",
"problemMatcher": [
"$sweetpad-watch",
"$sweetpad-xcodebuild-default",
"$sweetpad-xcbeautify-errors",
"$sweetpad-xcbeautify-warnings"
],
"label": "sweetpad: build",
"detail": "Build the app",
"isBackground": true,
"presentation": {
"reveal": "silent",
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
},
{
"type": "sweetpad",
"action": "launch",
"problemMatcher": [
"$sweetpad-watch",
"$sweetpad-xcodebuild-default",
"$sweetpad-xcbeautify-errors",
"$sweetpad-xcbeautify-warnings"
],
"label": "sweetpad: launch",
"detail": "Build and Launch the app",
"presentation": {
"reveal": "always",
"panel": "dedicated",
"showReuseMessage": true,
"clear": false
}
},
{
"type": "sweetpad",
"action": "clean",
"problemMatcher": [
"$sweetpad-watch",
"$sweetpad-xcodebuild-default",
"$sweetpad-xcbeautify-errors",
"$sweetpad-xcbeautify-warnings"
],
"label": "sweetpad: clean",
"detail": "Clean the app",
"presentation": {
"reveal": "always",
"panel": "dedicated",
"showReuseMessage": true,
"clear": false
}
}
]
}
按 Cmd Shift P 并运行:
SweetPad: Create Build Server Config
如果一切顺利,您应该已经准备好在 VSCode 中开发 Swift 项目了!
本站所有资源都是由网友投稿发布,或转载各大下载站, 请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则 产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:study_golang@163.com