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

It doesn't seem possible to use this package as a dependency of another #115

Closed
valentary opened this issue Mar 15, 2024 · 3 comments
Closed
Labels
question Further information is requested

Comments

@valentary
Copy link

I was trying to separate out a component of ours into it's own swift package. This component manages uploads to our cloud service and relies on aws-sdk-ios-spm package.

In my app, the AWS package works just fine, but once I packaged all my code, and tried to add the AWS package as a dependency, I could not make it work, the dependency package would download, but there seemed no way to add it to any target. I would get errors similar to

"product AWSiOSSDKV2 required by package aws-sdk-test-package target aws-sdk-test-target not found"

I tried various different targets, products strings etc from what I could find in the AWS package file, but nothing would work

It can be recreated with any simple package structure, a default XCode created one works to replicate the issue, here is my swift.package file

// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "aws-sdk-test-package",
    platforms: [
        .iOS(.v15)
    ],
    products: [
        // Products define the executables and libraries a package produces, making them visible to other packages.
        .library(
            name: "aws-sdk-test-package",
            targets: ["aws-sdk-test-package"]),
    ],
    dependencies: [
        .package(url: "https://github.com/aws-amplify/aws-sdk-ios-spm.git", from: .init(2, 34, 0))
    ],
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .target(
            name: "aws-sdk-test-package",
        dependencies: [
            // Things that didn't work
            "AWSiOSSDKV2",
            // "aws-sdk-ios-spm",
            // "AWSCore",
            // .product(name: "AWSCore"),
            // .target(name: "AWSCore")
        ]
        ),
        .testTarget(
            name: "aws-sdk-test-packageTests",
            dependencies: ["aws-sdk-test-package"]),
    ]
)
@sebaland
Copy link
Member

sebaland commented Mar 22, 2024

Hi @valentary! Thanks for opening this issue.

To add a product from this package as a dependency, you'll need to set both its name and its package:

dependencies: [
    .product(name: [Product Name], package: "aws-sdk-ios-spm")
]

So your package file would look like this:

let package = Package(
    name: "aws-sdk-test-package",
    platforms: [
        .iOS(.v15)
    ],
    products: [
        // Products define the executables and libraries a package produces, making them visible to other packages.
        .library(
            name: "aws-sdk-test-package",
            targets: ["aws-sdk-test-package"]),
    ],
    dependencies: [
        .package(url: "https://github.com/aws-amplify/aws-sdk-ios-spm.git", from: .init(2, 34, 0))
    ],
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .target(
            name: "aws-sdk-test-package",
            dependencies: [
                .product(name: "AWSCore", package: "aws-sdk-ios-spm")
                // + other products your package uses, .e.g "AWSS3", "AWSPinpoint", etc
            ]
        ),
        .testTarget(
            name: "aws-sdk-test-packageTests",
            dependencies: ["aws-sdk-test-package"]),
    ]
)

@sebaland sebaland added the question Further information is requested label Mar 22, 2024
@valentary
Copy link
Author

Thanks!

Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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

No branches or pull requests

2 participants