Feasibility of building SwiftSyntax for iOS?

I'm interested in building Swift developer tools for iOS and potentially browsers (when SwiftWasm is more stable). As pure Swift tools (swift-ast being the most promising) don't support all of the use cases, SwiftSyntax seems to be the most natural choice. Currently it looks like it can't be built for iOS, especially because the dependencies (LLVM etc) also can't be easily built for iOS.

Has anyone successfully done it? Interesting to know whether it's feasible at all or more effort should be put into libraries implemented in pure Swift, which are easily portable?

1 Like

swift-5.1 SwiftSyntax only needs the parser library, not a full toolchain. There's the build-parser-lib script which is designed to only build the parser library and nothing else. It's WIP to get it to build the parser library for iOS, and any contributions would be very welcomed.

Once you have the parser library then you only need to build the SwiftSyntax side for iOS by referencing its source files in an Xcode project that was setup for this.

2 Likes

Most of LLVM should be fundamentally possible to build on iOS either. Some parts of tool drivers that deal with processes and other things iOS restricts might need to be cut out, but the core LLVM and Clang libraries that support Swift don't fundamentally rely on anything like that. If SwiftSyntax doesn't end up suiting your needs and you want to build more of the compiler for iOS, that should be possible with some work as well.

1 Like

It would be cool to know what of the Swift infrastructure can be build on iOS. I mean there is Swift Playgrounds, the autocompletion is poor but it would be great if people could build Swift as a language for custom sandboxed applications like the playground app or potentially an IDE for Swift, following all iOS guidelines of course.

Do you mind clarifying a bit on why you think that ?

You mean the autocompletion part of the iOS playgrounds app? Well I don‘t find it as intuitive as let‘s say in Xcode. I‘d expect popups to appear near to the code I type, not the iOS suggestions like grey UI without any visual information about the suggested code (types, icons etc.).

With latest swift master you can use the build-parser-lib script to build the parser library for iOS:

utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build-ios --host iphoneos --architectures arm64

or

utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build-iossim --host iphonesimulator --architectures x86_64
4 Likes
Terms of Service

Privacy Policy

Cookie Policy