A sample iOS app designed for cross-compilation on Linux.
This is a sample project from my SwiftTO talk "Beyond Xcode: Batteries Not Included".
See Slides.pdf.
Note that this has been tested on Ubuntu 22.04 for AArch64. Your mileage may vary on other Linux distros/setups.
Prerequisites:
- ideviceinstaller (on or after 7fbc6d1)
- libimobiledevice CLI tools (for debugging)
- Swift 5.9
- Install my
swift-package-manager
fork- Clone the repo:
git clone https://github.com/kabiroberai/swift-package-manager -b kabir/develop
. - Run
swift build
. - Copy the built
swift-package
,swift-build
,swift-run
,swift-experimental-sdk
tools (in.build/debug
) into your Swift 5.9 toolchain's bin directory, overwriting existing files.
- Clone the repo:
- Build and install my Darwin SDK: see the
develop
branch of https://github.com/kabiroberai/swift-sdk-darwin - Obtain signing resources from your Apple Developer account (TODO: add commands):
- Create a local RSA keypair and certificate signing request.
- Upload the CSR to https://developer.apple.com/account to obtain a certificate.
- Create
Resources/identity.p12
with the private key, certificate, as well as Apple's intermediate and root CAs. - Generate a wildcard provisioning profile on Apple's member center, and save it at
Resources/embedded.mobileprovision
.
- Done. Run
make do
and sit back :)
These steps are designed for VSCode but you can adapt them to your preferred LSP-compatible IDE.
- Set up SourceKit-LSP for your IDE. For VSCode, this means installing the "Swift" extension.
- Update the paths in
.vscode/settings.json
to use your home directory instead of/home/kabiroberai
Note that SourceKit-LSP does not officially support SwiftSDKs yet. While this repo implements a workaround, IDE experience will be sub-optimal until official support lands. See swiftlang/sourcekit-lsp#786.
- Install the app on your device with
make do
. - Start debugserver: run
make debug
in a background terminal window. Keep this running. - Connect LLDB to debugserver. If you're in VSCode, just use the "Attach" configuration. Otherwise, you want something along the lines of:
(lldb) platform select remote-ios
(lldb) target create --no-dependents .build/debug/MyApp.app/MyApp
(lldb) process connect connect://localhost:1234
(lldb) process attach --waitfor
- Launch the app on your device.