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

Fix binary targets which no longer resolve in SwiftPM. #18

Closed
furby-tm opened this issue Oct 18, 2024 · 3 comments
Closed

Fix binary targets which no longer resolve in SwiftPM. #18

furby-tm opened this issue Oct 18, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@furby-tm
Copy link
Member

furby-tm commented Oct 18, 2024

This is a bug that propagated after the addition of #17.

Figure out why binary target dependencies can no longer resolve.

git clone git@github.com:wabiverse/SwiftPM.git
cd SwiftPM

git checkout wabi-swift-evolution-target-linking-strategy
swift build -c release

Now build a testing SwiftPM package, using an alias for stackypm or some other alias to .build/arm64-apple-macosx/release/swift-build to build a package which depends on a binary artifact, you can use this SwiftPM Package.swift manifest for testing:

// swift-tools-version: 6.0
import PackageDescription

let package = Package(
  name: "TestSwiftPM",
  platforms: [
    .macOS(.v14),
    .visionOS(.v1),
    .iOS(.v17),
    .tvOS(.v17),
    .watchOS(.v10)
  ],
  products: [
    .library(
      name: "TestLibrary",
      targets: ["TestLibrary"]
    ),
    .library(
      name: "Boost",
      targets: ["Boost"]
    )
  ],
  targets: [
    .binaryTarget(
      name: "Boost",
      url: "https://github.com/wabiverse/MetaverseBoostFramework/releases/download/1.81.4/boost.xcframework.zip",
      checksum: "2636f77d3ee22507da4484d7b5ab66645a08b196c0fca8a7af28d36c6948404e"
    ),

    .target(
      name: "TestLibrary",
      dependencies: [
        .target(name: "Boost")
      ]
    )
  ]
)
@furby-tm furby-tm added this to SwiftPM Oct 18, 2024
@furby-tm furby-tm converted this from a draft issue Oct 18, 2024
@furby-tm furby-tm added the bug Something isn't working label Oct 18, 2024
@furby-tm
Copy link
Member Author

furby-tm commented Oct 18, 2024

Note if using powershell, which is a great cross-platform shell across macOS, Linux, and Windows:

  1. fire up a powershell instance in your terminal:
pwsh
  1. run this to open your powershell profile in code, or echo $PROFILE to open it in some other text editor:
code $PROFILE
  1. paste this in the .ps1 file
function StackotterPM {
  $ArgRest = ($Args).Where({$_ -ne 'build' -and $_ -ne 'run' -and $_ -ne 'test' -and $_ -ne 'package'})

  if(($Args[0] -eq 'build')) {
    & /Users/$env:USER/Wabi/SwiftPM/.build/arm64-apple-macosx/release/swift-build $ArgRest
  } elseif(($Args[0] -eq 'run')) {
    & /Users/$env:USER/Wabi/SwiftPM/.build/arm64-apple-macosx/release/swift-run $ArgRest
  } elseif(($Args[0] -eq 'test')) {
    & /Users/$env:USER/Wabi/SwiftPM/.build/arm64-apple-macosx/release/swift-test $ArgRest
  } elseif(($Args[0] -eq 'package')) {
    & /Users/$env:USER/Wabi/SwiftPM/.build/arm64-apple-macosx/release/swift-package $ArgRest
  } else {
    Write-Color -Text "stackypm: available options are (", "build ", "run ", "test ", "or ", "package", ")" -Color Blue, Yellow, Yellow, Yellow, Blue, Yellow, Blue
  }
}

# Run our fork of swiftpm.
Set-Alias stackypm StackotterPM
  1. then run the following to "source" the profile and make this command available to you:
. $PROFILE

now use it like the following:

stackypm build
stackypm run
stackypm test
stackypm package

@furby-tm
Copy link
Member Author

furby-tm commented Oct 18, 2024

Update: The test above, while a valid test to check if binary artifacts are working, I can only replicate this bug if the dependency graph is rather insane, like with MetaverseKit:

git clone git@github.com:wabiverse/MetaverseKit.git
cd MetaverseKit

stackypm build -c release

Should induce the following error message:

Fetching https://github.com/pvieito/PythonKit.git from cache
Fetching https://github.com/wabiverse/MetaverseVulkanFramework from cache
// ...
Fetching binary artifact https://github.com/wabiverse/MetaverseBoostFramework/releases/download/1.81.4/boost.xcframework.zip from cache
Fetched https://github.com/wabiverse/MetaverseBoostFramework/releases/download/1.81.4/boost.xcframework.zip from cache (32.82s)

error: InternalError(description: "Internal error. Please file a bug at https://github.com/swiftlang/swift-package-manager/issues with this info. unknown module: <ResolvedModule: Python, binary>")

@furby-tm
Copy link
Member Author

This is an issue in the main branch of SwiftPM, we did not cause this error, I should have tested SwiftPM main to get a good sense of any regressions before I started, but this bug is unrelated to anything we are doing.

@github-project-automation github-project-automation bot moved this from Backlog to Done in SwiftPM Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants