JamitLabs / Accio

A dependency manager driven by SwiftPM that works for iOS/tvOS/watchOS/macOS projects.
MIT License
664 stars 32 forks source link

Dependencies cannot be resolved when the target is in the same Package.swift #66

Closed mrylmz closed 4 years ago

mrylmz commented 5 years ago

I have an issue where i try to add a local library product as dependency to the main target. It seems that we are looking into the dependencies of the Package.swift file but for local targets there won't be an entry in dependencies so this always fails to resolve.

DependencyGraph: Could not find library product with name 'Target' in package manifest for project 'ProjectName'.

Jeehut commented 5 years ago

Could you please provide a complete Pakcage.swift contents so we can better understand the issue?

SentulAsia commented 5 years ago

I have similar problem @Dschee:

import PackageDescription

let package = Package(
    name: "DataStoreManager",
    platforms: [
        .iOS(.v8),
        .macOS(.v10_10),
        .watchOS(.v2),
        .tvOS(.v9)
    ],
    products: {
        var products: [Product] = []
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
#if os(iOS)
        products.append(contentsOf: [
            .library(
                name: "DataStoreManager",
                targets: [
                    "DataStoreManager-iOS"
                ]
            ),
        ])
#elseif os(macOS)
        products.append(contentsOf: [
            .library(
                name: "DataStoreManager",
                targets: [
                    "DataStoreManager-macOS"
                ]
            ),
        ])
#elseif os(watchOS)
        products.append(contentsOf: [
            .library(
                name: "DataStoreManager",
                targets: [
                    "DataStoreManager-watchOS"
                ]
            ),
        ])
#elseif os(tvOS)
        products.append(contentsOf: [
            .library(
                name: "DataStoreManager",
                targets: [
                    "DataStoreManager-tvOS"
                ]
            ),
        ])
#endif
        return products
    }(),
    dependencies: [
        // add your dependencies here, for example:
        // .package(url: "https://github.com/User/Project.git", .upToNextMajor(from: "1.0.0")),
    ],
    targets: {
        var targets: [Target] = []
#if os(iOS)
        targets.append(contentsOf: [
            .target(
                name: "DataStoreManager-iOS",
                dependencies: [
                    // add your dependencies scheme names here, for example:
                    // "Project",
                ],
                path: "Sources/DataStoreManager"
            ),
            .testTarget(
                name: "DataStoreManagerTests-iOS",
                dependencies: [
                    "DataStoreManager-iOS"
                ],
                path: "Tests/DataStoreManagerTests"
            ),
        ])
#elseif os(macOS)
        targets.append(contentsOf: [
            .target(
                name: "DataStoreManager-macOS",
                dependencies: [
                    // add your dependencies scheme names here, for example:
                    // "Project",
                ],
                path: "Sources/DataStoreManager"
            ),
            .testTarget(
                name: "DataStoreManagerTests-macOS",
                dependencies: [
                    "DataStoreManager-macOS"
                ],
                path: "Tests/DataStoreManagerTests"
            ),
        ])
#elseif os(watchOS)
        targets.append(contentsOf: [
            .target(
                name: "DataStoreManager-watchOS",
                dependencies: [
                    // add your dependencies scheme names here, for example:
                    // "Project",
                ],
                path: "Sources/DataStoreManager"
            ),
        ])
#elseif os(tvOS)
        targets.append(contentsOf: [
            .target(
                name: "DataStoreManager-tvOS",
                dependencies: [
                    // add your dependencies scheme names here, for example:
                    // "Project",
                ],
                path: "Sources/DataStoreManager"
            ),
            .testTarget(
                name: "DataStoreManagerTests-tvOS",
                dependencies: [
                    "DataStoreManager-tvOS"
                ],
                path: "Tests/DataStoreManagerTests"
            ),
        ])
#endif
        return targets
    }(),
    swiftLanguageVersions: [.v5]
)
yoiang commented 5 years ago

@SentulAsia can you clarify where the problem is occurring for you, or what the error output looks like?

For me the Package.swift looks like:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "MyProjectFramework",
    products: [
        .library(name: "MyProjectFramework", targets: ["MyProjectFramework"]),
    ],
    dependencies: [
        ...
    ],
    targets: [
        .target(
            name: "MyProjectFramework",
            dependencies: [
                ...
            ],
            path: "MyProjectFramework"
        ),
        .testTarget(
            name: "MyProjectFrameworkTests",
            dependencies: [
                "MyProjectFramework",
                ...
            ],
            path: "MyProjectFrameworkTests"
        ),
    ]
)

The resulting error I get is:

❌  DependencyGraph: Could not find library product with name 'MyProjectFramework' in package manifest for project 'MyProjectFramework'.
phimage commented 5 years ago

I have same issues with accio on accio, or on https://github.com/IBDecodable/IBGraph/blob/master/Package.swift (xcode 10.3, carthage 0.33.0)

I do not know how normally this could work but I try to make something by excluding local package dependencies But I do not thinks it is the solution, because target name could be different from product name

https://github.com/JamitLabs/Accio/compare/stable...phimage:fix/could_not_find_library?expand=1

ps: I make also comparing product name with ignore case, because I have an executable different case from target

fredpi commented 4 years ago

Closing this, as Accio is now deprecated.