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

Dashes in product name breaks dependency resolving #164

Open
philprime opened this issue Aug 27, 2021 · 1 comment
Open

Dashes in product name breaks dependency resolving #164

philprime opened this issue Aug 27, 2021 · 1 comment

Comments

@philprime
Copy link

philprime commented Aug 27, 2021

When importing a package which contains dash in the library name, they are automatically replaced by the Xcode build system to underscores, which breaks the dependency resolving and makes them unusable.

Example: the package AppStoreConnect-Swift-SDK by @AvdLee

The product name is defined in the Package.swift as the following:

...
products: [
    .library(name: "AppStoreConnect-Swift-SDK", targets: ["AppStoreConnect-Swift-SDK"])
],
...

which requires the import to be the following:

import AppStoreConnect_Swift_SDK    // AvdLee/appstoreconnect-swift-sdk
// instead of
import AppStoreConnect-Swift-SDK    // AvdLee/appstoreconnect-swift-sdk

as dashes are automatically replaced with _.

This results in the following error:

'test' /Users/Philip/Library/Developer/swift-sh.cache/1f801762d2aba590bc4b77b62e521b02: error: product 'AppStoreConnect_Swift_SDK' not found in package 'appstoreconnect-swift-sdk'. it is required by package 'test' target 'test'.
warning: dependency 'AppStoreConnect-Swift-SDK' is not used by any target
error: 1 <(/usr/bin/swift build -Xswiftc -suppress-warnings)

Minimal Example to reproduce:

#!/usr/bin/swift sh

import AppStoreConnect_Swift_SDK    // AvdLee/appstoreconnect-swift-sdk

Ideas to fix the issue:

  • add option to define the product name, e.g.
#!/usr/bin/swift sh

import AppStoreConnect_Swift_SDK    // AvdLee/appstoreconnect-swift-sdk#appstoreconnect-swift-sdk
  • inform package authors about the name-convention breaking and provide a duplicated target, e.g.
products: [
  // original:
  .library(name: "AppStoreConnect-Swift-SDK", targets: ["AppStoreConnect-Swift-SDK"]),
  // new:
  .library(name: "AppStoreConnect_Swift_SDK", targets: ["AppStoreConnect-Swift-SDK"])
],
@mxcl
Copy link
Owner

mxcl commented Sep 24, 2021

We parse the output from dump-package to try and get these things, probs needs updating since we switched to swift-package-tools version 5.1

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

2 participants