SwiftUI iOS Debug & HotReloading in VSCode
Demonstrating vscode development environment using xcodegen + HotReloading.
- Language Server Protocol for Swift with vscode-swift extension.
- Lint Swift with SwiftLint extension.
- Xcode project generating using XcodeGen
- Launch & debugging with lldb iOS Debug
- HotReloading & Injection with HotReloading
- SwiftUI injection property wrapper with Inject
Support HotReloading
One caveat to support HotReloading is to ensure the derivedDataPath
passed to xcodebuild
matches that when building with Xcode.
Xcode (by default) uses "Unique" build locations for each project: Xcode DerivedData Hashes
Once the xcodegen
task has been run the following command can be used to output the $BUILT_PRODUCTS_DIR
including the unique location (for this demo):
$xcodebuild -project ./Demo.xcodeproj -scheme Demo -showBuildSettings | grep -m 1 "BUILT_PRODUCTS_DIR" | grep -oEi "\/.*"
Output:
~/Library/Developer/Xcode/DerivedData/Demo-avuzscipzqxczrbltxhlvbnxujdo/Build/Products/Debug-iphoneos
This in turn means the .vscode/launch.json
iOS Debug program
needs to be updated to resolve to the output *.app
($CODESIGNING_FOLDER_PATH
)