Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftTemplate fails to build due to Invalid manifest #1322

Open
markst opened this issue Apr 2, 2024 · 6 comments
Open

SwiftTemplate fails to build due to Invalid manifest #1322

markst opened this issue Apr 2, 2024 · 6 comments

Comments

@markst
Copy link
Contributor

markst commented Apr 2, 2024

We're using a XcodeBuildToolPlugin to generate mocks using Sourcery as mentioned in this issue:
#1229

This works when running in Xcode, however occasionally when running tests using xcodebuild the following can occur:

⚠️ /Users/vagrant/Library/org.swift.swiftpm/configuration is not accessible or not writable, disabling user-level cache features.
⚠️ /Users/vagrant/Library/org.swift.swiftpm/security is not accessible or not writable, disabling user-level cache features.
⚠️ /Users/vagrant/Library/Caches/org.swift.swiftpm is not accessible or not writable, disabling user-level cache features.
❌ error: '2.2.2': Invalid manifest (compiled with: ["/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc", "-vfsoverlay", "/var/folders/yy/6kcn9mkd5svdbqnznwf474f00000gn/T/TemporaryDirectory.rZXXGv/vfs.yaml", "-L", "/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-target", "arm64-apple-macosx13.0", "-sdk", "/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk", "-F", "/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks", "-I", "/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-L", "/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-swift-version", "5", "-I", "/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-sdk", "/Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk", "-package-description-version", "5.7.0", "/Users/vagrant/Library/Developer/Xcode/DerivedData/Listen-fvqyfexjyixxxlfwlponyonxlklz/SourcePackages/plugins/Listen.output/ListenTests/SourceryPlugin/SourceryPlugin/Build/SwiftTemplate/8AA32FFF-75B5-408E-9C19-FCDB218A2B59/2.2.2/Package.swift", "-Xfrontend", "-disable-implicit-concurrency-module-import", "-Xfrontend", "-disable-implicit-string-processing-module-import", "-o", "/var/folders/yy/6kcn9mkd5svdbqnznwf474f00000gn/T/TemporaryDirectory.NscvFM/2.2.2-manifest"])
❌ error: fatalError
@markst
Copy link
Contributor Author

markst commented Apr 2, 2024

This repeatedly occurs when attempting to build using Bitrise continuous integration platform

@markst
Copy link
Contributor Author

markst commented Apr 2, 2024

We're currently using Sourcery 2.2.2.

I've attempting passing buildPath arguments to sourcery using both outputDirectory and NSTemporaryDirectory()

private func createBuildCommands(
    tool: PluginContext.Tool,
    configPath: Path,
    outputDirectory: Path
) -> [Command] {
    let cachePath = outputDirectory.appending(subpath: "SourceryPlugin/Cache")
    let buildPath = outputDirectory.appending(subpath: "SourceryPlugin/Build")
    return [
        .prebuildCommand(
            displayName: "Generate mocked types for target",
            executable: tool.path,
            arguments: [
                "--config", configPath,
                "--cacheBasePath", cachePath,
                "--buildPath", buildPath,
                "--disableCache",
                "--verbose"
            ],
            environment: ["DERIVED_SOURCES_DIR": outputDirectory],
            outputFilesDirectory: outputDirectory
        )

@markst
Copy link
Contributor Author

markst commented Apr 2, 2024

I'm now struggling to reproduce locally, the output appears to succeed:

        Raw compilation of SwiftTemplate took: 7.120736837387085

@markst
Copy link
Contributor Author

markst commented Apr 3, 2024

as a sidenote, the SwiftTemplate binary is built each time which leads me to think the executableCacheKey is changing despite no change in code?

image

@art-divin
Copy link
Collaborator

as a sidenote, the SwiftTemplate binary is built each time which leads me to think the executableCacheKey is changing despite no change in code?

image

Hi @markst , aside from other issues you've reported, for which there are billions of thanks ❤️ ,
SwiftTemplate binary is compiled once (in single threaded mode of running Sourcery), and then re-used. Other components are cached on per-execution basis.

You can verify this by using --verbose flag when running Sourcery starting 2.2.2 release. It is clearly shown when SwiftTemplate is reused from cache, and when it is re-compiled again due to a different cacheKey.

@swwol
Copy link
Contributor

swwol commented Apr 22, 2024

You can normally resolve this issue using swift package purge-cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants