johnno1962 / InstantSyntax

SwiftSyntax binary frameworks
Apache License 2.0
44 stars 2 forks source link

libSwiftSyntax.a not found #3

Open smic opened 5 months ago

smic commented 5 months ago

Hi, I don't know if I use your package correctly. I just tried to use you package in a my own macro as a regular dependency as I saw that this package contain SwiftSyntax as precompile xcframeworks:

    dependencies: [
        .package(
            url: "https://github.com/johnno1962/InstantSyntax.git",
            revision: "339fd24f9caa88b576a495be2ab32e22aaa8c673"
        )
    ],

But this doesn't compile:

No such file or directory: '/Users/stephan/Library/Developer/Xcode/DerivedData/EquatableObservation-avgiqnpebtfekmbwcemjuhhusizf/SourcePackages/checkouts/InstantSyntax/509.1.1/libSwiftSyntax.a'

Is this not supported in this way?

johnno1962 commented 5 months ago

HI, to be honest I haven't tried this configuration as it is intended to be cloned then dragged onto your project as it says in the README. You need to do this as it has "unsafe linker arguments". I'm curious though, have you tried adding a name: "swift-syntax" argument to the .package statement? Is there no library file at the path mentioned? Is there are Package.swift in the directory above? What is the contents of the checkouts directory?

smic commented 4 months ago

The checkout contains following files:

README.md
.gitignore
.github
.github/FUNDING.yml
Package.swift
Sources
Sources/InstantSyntax/InstantSyntax.swift
package_syntax.sh
LICENSE.txt
swift-syntax.xcodeproj
509.1.1/SwiftCompilerPluginMessageHandling.xcframework.zip
509.1.1/unpack.sh
509.1.1/SwiftSyntaxMacrosTestSupport.xcframework.zip
509.1.1/SwiftSyntaxBuilder.xcframework.zip
509.1.1/SwiftOperators.xcframework.zip
509.1.1/SwiftCompilerPlugin.xcframework.zip
509.1.1/SwiftSyntaxMacroExpansion.xcframework.zip
509.1.1/SwiftParser.xcframework.zip
509.1.1/SwiftSyntax509.xcframework.zip
509.1.1/SwiftSyntaxMacros.xcframework.zip
509.1.1/SwiftDiagnostics.xcframework.zip
509.1.1/SwiftParserDiagnostics.xcframework.zip
509.1.1/SwiftBasicFormat.xcframework.zip
509.1.1/SwiftSyntax.xcframework.zip
509.1.1/libSwiftSyntax.a.zip
509.1.1/_SwiftSyntaxTestSupport.xcframework.zip

It contains the libSwiftSyntax.a, but zipped. But what is the purpose of libSwiftSyntax.a if there are already the xcframeworks?

johnno1962 commented 4 months ago

As per the README, you need to run the script "unpack.sh" in that directory. The library is there because compiler plugins are sandboxed and can't load dynamic libraries so the "unsafe linker flags" statically links them with this library. You won't be able to use the repo without cloning it and following the instructions in the README to use it as a local package which overrides the SPM dependency rather than making it an explicit dependency in your macro.