LSP integration with CMake and nightly toolchains

Uh, trying to build with that ninja command gives me fun errors like <unknown>:0: error: module 'Swift' cannot be imported in embedded Swift mode. That seems strange considering it was building fine just now.

Yeah, I got pretty far in C++:

https://gitea.com/TeamPuzel/BlockGame

I figured I would port it to Swift in a day or two, but that does not seem to be the case, since Swift does not want to cooperate :slight_smile:

What is that file? I don't see one, is that mentioned in one of the documentation websites?

No, and I use 6.0.2 latest release toolchain.

Swift has some kind of comfort zone. If you use SPM and don't do cross-platform compilation, everything works fine (as I just said, Xcode, VSCode, Zed all work fine). But if you don't want to use SPM, or want to compile cross-platform, it's much more difficult.

I tried to compile an SPM project for iOS on macOS before, and tried many solutions, including setting parameters for sourcekit-lsp, but none of them worked (as shown in your picture, image: <<error type>>). In the end, I fell back to Xcode (with xcode-build-server) to solve it.

This is the type of thing I've found. A lot of it actually is in the C++ context, but my C/C++ compilers have historically been some flavor of gcc, so I'm not deeply familiar with using them with C/C++ either!

Honestly, in your place I might consider going ahead and using a package in C++ compatibility mode, moving it over piece by piece. You could then use the swiftpm section of the config.json to do some of the set up. That might go easier than wrestling with the ninja and cmake generators.

Hunh about the Ninja error b/c I did use Ninja with with embedded for a C/Swift embedded combo build... but that build file didn't use the CMake Swift mode, it used the custom_command call

I cribbed off the pico_w example in the embedded examples repo.

For what it's worth I did all the folders in that repo essentially just ignoring all the red squigglies. Why I'm doing all this myself. Going back and applying what I've learned to that is a goal.

I'm going to be unavailable for a couple of days starting shortly but I'll let you know if I get a library working.

In the mean time I hope you find a path that's going to work for you!

1 Like

This usually means the compiler only found the Desktop swift standard library. You can use -Rmodule-loading to help aid debugging.

1 Like

I can't use C++ interoperability as the C++ code is using C++ modules which Apple Clang disables for whatever reason, and if it didn't Swift does not support them.


Ok so the issue seems to be specific to modules:

Core works correctly as it has no dependencies, and the ones that exist use conditional compilation. Files correctly see each other, so for example Drawable.swift has access to Float.normalize from Math.swift and the LSP is able to suggest those methods and check errors.

Engine does not work, as files there depend on Core. import Core fails with an error SourceKit: No such module 'Core'. This is confusing because both CMake and Xcode through Package.swift resolve the modules perfectly fine, though Xcode is completely broken with the toolchain in other ways.

OpenGL.swift is the weirdest file. It has a @preconcurrency import GLAD which comes from a module map. What's strange about it is that it does work, in that I can hover over types like GLenum and I get a correct tooltip, but there is no error checking or completion happening at all.

More possibly tomorrow/weekend but confirming you found this? I've only done it with C, not C++

" Wrapping C/C++ Library in Swift"

ETA - it might be time to start a different thread since this isn't an IDE issue? I'll look for it.

Why isn't it an IDE/Editor issue? The language itself works fine, CMake does resolve the modules and build correctly

By the way it seems to be completely ignoring the .sourcekit-lsp folder

Sorry, though you'd switched to trying to make a Package.swift work with C++ interop and it wouldn't swift build, which isn't anything you said. Assumptions on my part.

1 Like

Interestingly, when I copied a file into a directory that is not part of any module, Xcode started showing completions — not errors though.
And in proper files it shows errors but not completions :slight_smile:

It shouldn't even be able to import these in a random untracked file?


I wonder what the AI is trying to do with these properties :thinking:

I managed to get it working, though only in VSCode (which I hate) and not without a Package.swift. Which is a problem because unlike CMake the Swift build system can't handle a module-less main file.

Xcode is still broken and so is Zed, but the latter doesn't surprise me, it never worked with Swift modules in the past.

For some reason the package did not want to recognize a modulemap for SDL3 with an absolute path. I had to copy all the SDL3 headers into the modulemap directory and mass rename their own includes to be relative, after which it now started working!!!


The compiler can finally compile to more than 2 platforms, there is a less janky build system thanks to CMake support, but the LSP is even worse than before :frowning:

What is going on? Why is the language server so janky, can Apple not afford development? :slight_smile:

I am very much confused by what the real problem is. There is the Xcode project format, the Swift Package Manager (SPM) format, and there is cmake. Those are separate project formats to begin with. And yes, a Swift file without a “module” is not a thing with SPM. Then you talk about mixing C++ with Swift, which is a special case.

I think you have special requirements in your project, in those “edge” cases so to speak a minor weakness in your project definition might lead to different result using different tools. I find it difficult to start with a general judgement about Xcode, you maybe should present a complete example so others can help. The output could of course be that Xcode is doing something wrong or is missing some features.

3 Likes
  • I did not mention Xcode projects but rather opening a Package.swift project in Xcode. And the only reason I am using a Package.swift in a Cmake project in the first place is because, as I said, sourcekit-lsp does not like my compile_commands.json and ignores it.
  • I did not mention mixing C++ with Swift, it was suggested to me, and it is not something I am doing in this case.

The issue is that there is no IDE or code editor which seems to work for my project.

My judgment of Xcode comes from the fact that despite having a "Toolchains" menu using anything but the one built in breaks something every month or two. This happens regularly. :slight_smile:

Usually it's the code completions.


Package.swift
// swift-tools-version: 6.2

import PackageDescription

let swiftSettings: [SwiftSetting] = [
    .enableExperimentalFeature("BuiltinModule"),
    .enableExperimentalFeature("Extern"),
    .enableExperimentalFeature("Embedded"),
    .unsafeFlags(["-wmo"])
]

let package = Package(
    name: "Minecraft",
    platforms: [.macOS(.v15)],
    targets: [
        .target(name: "GLAD", path: "lib/GLAD", swiftSettings: swiftSettings),
        .systemLibrary(name: "SDL", path: "lib/SDL3"),
        .target(name: "Core", path: "src/Core", swiftSettings: swiftSettings),
        .target(name: "Engine", dependencies: ["Core", "GLAD", "SDL"], path: "src/Engine", swiftSettings: swiftSettings),
        .target(name: "Minecraft", dependencies: ["Core", "Engine"], path: "src/Minecraft", swiftSettings: swiftSettings),
        .executableTarget(name: "Entry", dependencies: ["Core", "Engine", "Minecraft"], path: "src/Entry", swiftSettings: swiftSettings)
    ]
)

I don't think this is that special of a case.

Though for some reason, even on stable toolchains, I get this when trying to build in debug mode:

Bug
Assertion failed: (Specialization->isExternalDeclaration() && "Specialization should be a public external declaration"), function lookupPrespecializedSymbol, file Generics.cpp, line 3604.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/teampuzel/Minecraft/src/Engine/Context.swift /Users/teampuzel/Minecraft/src/Engine/Game.swift /Users/teampuzel/Minecraft/src/Engine/OpenGL.swift -supplementary-output-file-map /var/folders/tf/zch6121s4wd8hv092csrhrth0000gn/T/TemporaryDirectory.Zhb3TJ/supplementaryOutputs-1 -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -disable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -I /Users/teampuzel/Minecraft/build/debug -I /Users/teampuzel/Minecraft/lib/glad/include -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -color-diagnostics -g -debug-info-format=dwarf -dwarf-version=5 -module-link-name Engine -static -swift-version 6 -Onone -enable-experimental-feature BuiltinModule -enable-experimental-feature Extern -enable-experimental-feature Embedded -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/teampuzel/Minecraft/build/debug -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/SDL3/module.modulemap -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/glad/include/module.modulemap -module-name Engine -in-process-plugin-server-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.2 -target-sdk-name macosx15.2 -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -parse-as-library -num-threads 12 -o CMakeFiles/Engine.dir/src/Engine/Context.swift.o -o CMakeFiles/Engine.dir/src/Engine/Game.swift.o -o CMakeFiles/Engine.dir/src/Engine/OpenGL.swift.o
1.	Apple Swift version 6.2-dev (LLVM 4930d5a55e7728b, Swift ec5bee8bc94399a)
2.	Compiling with the current language version
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Non-Diagnostic Mandatory Optimizations, Serialization, Rest of Onone } on SIL for Engine)
4.	While running pass #4837 SILModuleTransform "UsePrespecialized".
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001080c8e60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001080c7544 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001080c94bc SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018f7f6e04 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018f7bff70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018f6cc908 abort + 128
6  libsystem_c.dylib        0x000000018f6cbc1c err + 0
7  swift-frontend           0x00000001083e8ca0 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) (.cold.2) + 0
8  swift-frontend           0x00000001031ea174 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) + 832
9  swift-frontend           0x0000000102e8df30 (anonymous namespace)::UsePrespecialized::run() + 1676
10 swift-frontend           0x00000001030197e8 swift::SILPassManager::runModulePass(unsigned int) + 856
11 swift-frontend           0x000000010301bbe8 swift::SILPassManager::execute() + 624
12 swift-frontend           0x00000001030164bc swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
13 swift-frontend           0x000000010301643c swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 68
14 swift-frontend           0x0000000103066db8 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 28
15 swift-frontend           0x0000000103033358 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 204
16 swift-frontend           0x0000000103016698 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 64
17 swift-frontend           0x00000001030492c4 swift::runSILPassesForOnone(swift::SILModule&) + 80
18 swift-frontend           0x00000001027f7700 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 260
19 swift-frontend           0x00000001025a6a78 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 820
20 swift-frontend           0x00000001025a6334 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1228
21 swift-frontend           0x00000001025b2774 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
22 swift-frontend           0x00000001025a7fd0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
23 swift-frontend           0x00000001025a769c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2328
24 swift-frontend           0x000000010237ad0c swift::mainEntry(int, char const**) + 3100
25 dyld                     0x000000018f440274 start + 2840

Perhaps sourcekit-lsp runs into this?

I believe this is the class that causes the issue, it goes away when commenting out copy

Class
public final class Texture {
    private let id: GLuint
    public var unit: GLuint

    public init(_ unit: GLuint = 0) {
        var id: GLuint = 0
        glad_glGenTextures(1, &id)

        self.id = id
        self.unit = unit
    }

    public func copy(_ drawable: some Drawable) {
        self.bind()

        let image = drawable.flatten()

        image.data.withUnsafeBytes { ptr in
            glad_glTexImage2D(
                GLenum(GL_TEXTURE_2D),
                0,
                GL_RGBA,
                GLsizei(image.width),
                GLsizei(image.height),
                0,
                GLenum(GL_RGBA),
                GLenum(GL_UNSIGNED_BYTE),
                ptr.baseAddress
            )
        }

        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_MIN_FILTER), GL_NEAREST)
        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_MAG_FILTER), GL_NEAREST)
        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_WRAP_S), GL_CLAMP_TO_EDGE)
        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_WRAP_T), GL_CLAMP_TO_EDGE)
    }

    public convenience init(_ unit: GLuint = 0, drawable: some Drawable) {
        self.init()
        self.copy(drawable)
    }

    deinit {
        withUnsafePointer(to: self.id) { id in
            glad_glDeleteTextures(1, id)
        }
    }

    func bind() {
        glad_glActiveTexture(UInt32(GL_TEXTURE0) + self.unit)
        glad_glBindTexture(GLenum(GL_TEXTURE_2D), self.id)
    }
}

I didn't notice since I don't use debug mode, it's a bit too slow :slight_smile:

If this is indeed useful I uploaded it here https://gitea.com/TeamPuzel/BlockGameSwift


At the moment it looks like swift build fails with linker errors:

Output
error: link command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture arm64:
  "_SDL_CreateWindow", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_DestroyWindow", referenced from:
      $defer #2 <A where A: Engine.Game>() -> () in static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Game.swift.o
  "_SDL_GL_CreateContext", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_GL_DestroyContext", referenced from:
      $defer #3 <A where A: Engine.Game>() -> () in static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Game.swift.o
  "_SDL_GL_GetProcAddress", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_GL_SetAttribute", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      ...
  "_SDL_GL_SetSwapInterval", referenced from:
      generic specialization <Minecraft.Main> of (extension in Engine):Engine.Game.isVSyncOn.setter : Swift.Bool in Block.swift.o
      generic specialization <Minecraft.Main> of (extension in Engine):Engine.Game.isVSyncOn.setter : Swift.Bool in Block.swift.o
  "_SDL_GL_SwapWindow", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_GetError", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_Init", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_PollEvent", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_Quit", referenced from:
      $defer #1 <A where A: Engine.Game>() -> () in static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Game.swift.o
  "_SDL_SetWindowMinimumSize", referenced from:
      generic specialization <Minecraft.Main> of static (extension in Engine):Engine.Game.main() throws(Engine.GameError) -> () in Block.swift.o
  "_SDL_SetWindowRelativeMouseMode", referenced from:
      generic specialization <Minecraft.Main> of (extension in Engine):Engine.Game.isCursorLocked.setter : Swift.Bool in Block.swift.o
  "_SDL_SetWindowTitle", referenced from:
      generic specialization <Minecraft.Main> of (extension in Engine):Engine.Game.windowTitle.setter : Swift.String in Block.swift.o
  "__swift_stdlib_getComposition", referenced from:
      Swift.Unicode._NFCNormalizer._resume(consumingNFD: (inout Swift.Unicode._NFCNormalizer) -> (scalar: Swift.Unicode.Scalar, normData: Swift.Unicode._NormData)?) -> Swift.Unicode.Scalar? in Application.swift.o
      Swift.Unicode._NFCNormalizer._resume(consumingNFD: (inout Swift.Unicode._NFCNormalizer) -> (scalar: Swift.Unicode.Scalar, normData: Swift.Unicode._NormData)?) -> Swift.Unicode.Scalar? in Application.swift.o
  "__swift_stdlib_getDecompositionEntry", referenced from:
      Swift.Unicode._NFDNormalizer.(decomposeSlow in _B136021ACF5AAEFA178D70CE67C7EEF0)((scalar: Swift.Unicode.Scalar, normData: Swift.Unicode._NormData)) -> () in Application.swift.o
  "__swift_stdlib_getGraphemeBreakProperty", referenced from:
      Swift.Unicode._GraphemeBreakProperty.init(from: Swift.Unicode.Scalar) -> Swift.Unicode._GraphemeBreakProperty in Application.swift.o
      Swift._StringGuts.checkIfInIndicSequence(at: Swift.Int, with: (Swift.Int) -> (scalar: Swift.Unicode.Scalar, start: Swift.Int)?) -> Swift.Bool in Application.swift.o
      Swift._StringGuts.previousBoundary(endingAt: Swift.Int, previousScalar: (Swift.Int) -> (scalar: Swift.Unicode.Scalar, start: Swift.Int)?) -> Swift.Int in Application.swift.o
      Swift._StringGuts.checkIfInEmojiSequence(at: Swift.Int, with: (Swift.Int) -> (scalar: Swift.Unicode.Scalar, start: Swift.Int)?) -> Swift.Bool in Application.swift.o
  "__swift_stdlib_getNormData", referenced from:
      Swift.(_stringCompareFastUTF8Abnormal in _835F230159459CFFE280B5F8E69D8077)(_: Swift.UnsafeBufferPointer<Swift.UInt8>, _: Swift.UnsafeBufferPointer<Swift.UInt8>, expecting: Swift._StringComparisonResult) -> Swift.Bool in Application.swift.o
      Swift.(_stringCompareFastUTF8Abnormal in _835F230159459CFFE280B5F8E69D8077)(_: Swift.UnsafeBufferPointer<Swift.UInt8>, _: Swift.UnsafeBufferPointer<Swift.UInt8>, expecting: Swift._StringComparisonResult) -> Swift.Bool in Application.swift.o
      (extension in Swift):Swift.UnsafeBufferPointer<A where A == Swift.UInt8>.hasNormalizationBoundary(before: Swift.Int) -> Swift.Bool in Application.swift.o
      Swift.(_findBoundary in _835F230159459CFFE280B5F8E69D8077)(_: Swift.UnsafeBufferPointer<Swift.UInt8>, before: Swift.Int) -> Swift.Int in Application.swift.o
      Swift.Unicode._NFDNormalizer._resume(consuming: () -> Swift.Unicode.Scalar?) -> (scalar: Swift.Unicode.Scalar, normData: Swift.Unicode._NormData)? in Application.swift.o
      Swift.Unicode._NFDNormalizer.(decomposeSlow in _B136021ACF5AAEFA178D70CE67C7EEF0)((scalar: Swift.Unicode.Scalar, normData: Swift.Unicode._NormData)) -> () in Application.swift.o
      Swift._StringGuts._opaqueComplexCharacterStride(endingAt: Swift.Int) -> Swift.Int in Application.swift.o
      ...
  "__swift_stdlib_isLinkingConsonant", referenced from:
      Swift._StringGuts._opaqueComplexCharacterStride(endingAt: Swift.Int) -> Swift.Int in Application.swift.o
      Swift._GraphemeBreakingState.shouldBreak(between: Swift.Unicode.Scalar, and: Swift.Unicode.Scalar) -> Swift.Bool in Application.swift.o
      Swift._GraphemeBreakingState.shouldBreak(between: Swift.Unicode.Scalar, and: Swift.Unicode.Scalar) -> Swift.Bool in Application.swift.o
      Swift._StringGuts.checkIfInIndicSequence(at: Swift.Int, with: (Swift.Int) -> (scalar: Swift.Unicode.Scalar, start: Swift.Int)?) -> Swift.Bool in Application.swift.o
      Swift._StringGuts.previousBoundary(endingAt: Swift.Int, previousScalar: (Swift.Int) -> (scalar: Swift.Unicode.Scalar, start: Swift.Int)?) -> Swift.Int in Application.swift.o
  "__swift_stdlib_nfd_decompositions", referenced from:
      Swift.Unicode._DecompositionEntry.utf8.getter : Swift.UnsafeBufferPointer<Swift.UInt8> in Application.swift.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[4/6] Linking Minecraft

I understand SDL, I didn't configure linking it, but what is unicode doing there? It seems to be working fine with Cmake

Thanks for the tip. I had done some ESP32 Embedded Swift development and didn't realize this was preventing me from using the normal Swift Package tools swift package init even after selecting the "build setting" in Xcode or using xcode-select

To fix it, I had to unset $TOOLCHAINS

export TOOLCHAINS=""

That means there’s a bug — please report it! It’s possible that this assertion failure is preventing some other part of the compiler from giving you a more understandable error about what it thinks is wrong in your code.

1 Like

I submitted the bug report here Compiler crash specializing generics · Issue #78167 · swiftlang/swift · GitHub :slightly_smiling_face:

2 Likes

if you are using nightly toolchains, you will run into a lot of compiler crashes. not just when compiling, but also when doing source edits against sourcekit-lsp.

if you are really dead set on using nightlies, you can compile a custom toolchain with noassert configuration, although there is a high likelihood that the assertions removed are meaningful and you could end up with miscompiled code. (the release toolchains are built in this configuration)

1 Like

With the amount of times I’ve had these miscompile I think I’d rather stay away from a configuration option that makes it worse :slightly_smiling_face:

Hopefully by the time I want to work on something more important it will be stable enough that I don’t have to use these

I do need the toolchains, they add a lot of cool features like the embedded mode or extern functions