a couple months ago, i got vim set up to play nice with sourcekit-lsp for an iOS app created in Xcode. the idea here was just to do my development in vim, build using a dummy Package.swift
configuration to get inline errors and autocomplete, and then manually refresh in Xcode and run previews and launch the simulator from there. a little janky, but better than the other options like self-signing my Xcode so i could stuff a mediocre vim clone inside of it (or actually using Xcode normally... shudder).
the process i used was basically identical to what folks have investigated for getting sourcekit-lsp to work for iOS apps developed in VSCode; references here and here.
i took a break from development for about two months, and now this system no longer works. in particular, if i'm in file A, sourcekit-lsp no longer seems to recognize symbols defined in file B.
to be extra clear, here's how i'm starting sourcekit-lsp:
xcrun sourcekit-lsp -Xswiftc -sdk -Xswiftc $(xcrun --sdk iphonesimulator --show-sdk-path) -Xswiftc -target -Xswiftc "x86_64-apple-ios$(xcrun --sdk iphonesimulator --show-sdk-version)-simulator"
here's my build command (note the identical options):
xcrun swift build -Xswiftc -sdk -Xswiftc $(xcrun --sdk iphonesimulator --show-sdk-path) -Xswiftc -target -Xswiftc "x86_64-apple-ios$(xcrun --sdk iphonesimulator --show-sdk-version)-simulator"
here's my directory structure:
toplevel/
|__Package.swift
|__MyApp/
|__Info.plist
|__MyApp.swift
|__A.swift
|__B.swift
here's what the Package.swift looks like:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "MyApp",
platforms: [.iOS(.v14)],
products: [
.library(
name: "MyApp",
targets: ["MyApp"]
),
],
dependencies: [],
targets: [
.target(
name: "MyApp",
dependencies: [],
path: "./MyApp",
exclude: ["Info.plist"]
),
]
)
here's file A.swift:
import SwiftUI
struct FooView: View {
var foo: Foo
var body: some View {
Text("sup")
}
}
and here's B.swift:
struct Foo {
var heh: String
}
i've tried moving Package.swift into the MyApp/ directory (and updating paths), which did nothing (it was broken in the exact same way). one thing i noticed is that the Swift version is 5.3.1:
$ xcrun swift --version
Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)
Target: x86_64-apple-darwin19.6.0
but if i try to change the swift-tools-version pragma to insist on 5.3.1, i get:
error: package at '/path/to/MyApp' is using Swift tools version 5.3.1 but the installed version is 5.3.0
this seems suspiciously like some sort of version mismatch, but everything is invoked with xcrun and it's not clear to me where the "swift tools" might live if not within $(xcrun swift)
(and additionally googling suggests that there is no such thing as swift-tools-version:5.3.1
).
any help would be appreciated (and hopefully this can help out others trying a non-Xcode iOS workflow post Xcode 12).