-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Can't import two dependencies from single repository #66
Comments
Thanks will fix. The work-around is to only specify the comment once per repository. |
I did try that #!/usr/bin/swift sh
import Basic // https://github.com/apple/swift-package-manager.git ~> 0.2.1
import Utility Which yields
Thanks! |
Yeah that is a different bug which is going to be very to fix. SwiftPM doesn’t vend products that we can depend on named the same as the module names it contains. I don’t have the bandwidth to fix this in the near future since it will basically involve a rewrite. |
Specifically the target that the script needs to depend on is called To determine this we can either depend on SwiftPM in swift-sh or parse the output from |
In this case #!/usr/bin/swift sh
import Utility // https://github.com/apple/swift-package-manager.git ~> 0.3.0
// Note: Basic depends on Utility. The order of these imports is thus significant.
import Basic
let path = RelativePath("~/Library/Developer") // RelativePath is part of Basic module
print(path.asString) |
I’ve been trying to figure out how we can make this work. Without depending on libSwiftPM ourselves (which is not stable, so would be a maintenance headache) it is a chicken and egg situation. We would need to write a Package.swift in order to resolve the deps so that we can write the Package.swift to specify the names of the products that are the dependencies of our script’s executable target. If you write a Package.swift without any targets, I believe it will resolve the deps still, then we can re-write it correctly after getting product names via Which will likely make build-times slower, oh well. |
I did have a similar issue, I had import Foundation
import PlatformLookup // mackoj/SimulatorControl
import CommandParser
import Shell Here let package = Package(
name: "PlatformLookup",
platforms: [.macOS(.v10_14)],
products: [
.executable(name: "cli", targets: ["cli"]),
.library(name: "CommandParser", targets: ["CommandParser"]),
.library(name: "SimulatorControl", targets: ["SimulatorControl"]),
.library(name: "Shell", targets: ["Shell"]),
.library(name: "PlatformLookup", targets: ["PlatformLookup"]),
],
dependencies: [
.package(url: "https://github.com/mrackwitz/Version.git", from: "0.7.2")
],
targets: [
.target(name: "cli", dependencies: ["PlatformLookup", "CommandParser"]),
.target(
name: "PlatformLookup",
dependencies: ["SimulatorControl", "Shell"]
), .target(name: "Shell"),
.target(name: "SimulatorControl", dependencies: ["Version"]),
.target(name: "CommandParser", dependencies: ["PlatformLookup"]),
.testTarget(
name: "PlatformLookupTests",
dependencies: ["PlatformLookup"]
), .testTarget(name: "ShellTests", dependencies: ["Shell"]),
],
swiftLanguageVersions: [.v5]
) It only worked when I put This was the actual solution. import Foundation
import CommandParser // mackoj/SimulatorControl
import PlatformLookup
import Shell I hope it help @mxcl. |
The workaround described above are no longer working in version I have a package that has the following structure (simplified/anonymized): let package = Package(
name: "MyModule",
platforms: [.iOS("11.4"), .macOS("10.13"), .watchOS("4.3")],
products: [
.library(name: "MyModule", targets: ["MyModule"]),
.library(name: "MyModuleExtension", targets: ["MyModuleExtension"]),
],
dependencies: [
.package(name: "SomeExternalLib", url: "[email protected]:xxx/xxx.git", from: "2.0.5"),
],
targets: [
.target(name: "MyModule", dependencies: []),
.target(name: "MyModuleExtension", dependencies: ["MyModule", "SomeExternalLib"]),
]
) Trying to use in a script: #!/usr/bin/swift sh
import Foundation
import MyModuleExtension // [email protected]:stefanhp/my-module.git == 1.4
import MyModule
print("Hello world!") It seems that the problem is that the package name If I fork the repo to Would there be another way to workaround this issue? Thanks |
Would it make sense to do the follow? ``
|
yields
The text was updated successfully, but these errors were encountered: