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

PackagePlugin's PackageManager.getSymbolGraph does not support binaryTarget #7580

Open
1 task done
Kyle-Ye opened this issue May 18, 2024 · 1 comment
Open
1 task done
Assignees
Labels

Comments

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented May 18, 2024

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI.

Description

Background Context: SwiftPackageIndex/SwiftPackageIndex-Server#3061 (comment)

If a target has a dependency on binaryTarget. Then the call of PackageManager.getSymbolGraph to that target will get a directory contains no symbol graph.

It will break PackageManager.getSymbolGraph's client such as swift-docc-plugin.

The downstream user can generate doc using swift build and call docc convert to generate documentation. But if they migrate to swift-docc-plugin or swift-docc-plugin based service like SwiftPackageIndex, the documentation build will fail.

// ✅ Build Package Documentation via Xcode GUI

// ✅ Build Package Documentation manually
swift build --target DemoKit \
  -Xswiftc -emit-symbol-graph \
  -Xswiftc -emit-symbol-graph-dir -Xswiftc "./symbol-graph"

docc convert --additional-symbol-graph-dir ./symbol-graph ...

// ❌ Build Package Documentation via swift-docc-plugin
swift package generate-documentation --target DemoKit

Expected behavior

Produce SymbolGraph normally.

Actual behavior

Call swift-symbolgraph-extract with the arguments manually in terminal or adding the following patch to SymbolGraphExtract.swift

    public func extractSymbolGraph(
        ...
        try process.launch()
-       try process.waitUntilExit()
+       let result = try process.waitUntilExit()
+       if let error = String(bytes: try result.stderrOutput.get(), encoding: .utf8) {
+            print(error)
+.      }
    }

And you will get the following error message.

"<unknown>:0: error: missing required module \'MMKV\'\nError: Failed to load the module \'DemoKit\'. Are you missing build dependencies or include/framework directories?\nSee the previous error messages for details. Aborting.\n"

I have tried to add the framework manually via -F/-I/-L ${MMKV_framework_path} but none of them will work.

Steps to reproduce

For user side reproduce steps:

  1. Download the following DemoKit.zip package
  2. Run swift package generate-documentation --target DemoKit --verbose and no documentation will be created.

For swiftpm developer reproduce steps:

  1. Set up swiftpm repo development environment
  2. Build PackageDescription target first and then choose swift-package target
  3. Set working directory to DemoKit and the corresponding arguments on launch in Xcode
    4.(Optional) Apply the diff mentioned above.

DemoKit.zip

Note: Here I use MMKV.xcframework as an example but any binary framework would have the same issue. The binary framework have nothing special here.

Swift Package Manager version/commit hash

5.10

Swift & OS version (output of swift --version ; uname -a)

5.10 & macOS 14.4.1

@Kyle-Ye
Copy link
Collaborator Author

Kyle-Ye commented May 18, 2024

Is this an expected unimplemented feature or a bug we should fix? Checking the repository's Git history, I believe @MaxDesiatov would have some insights on this scope. Could you help give a look at this? Thanks

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

No branches or pull requests

2 participants