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

[SR-688] Package.swift isn't respected for dependencies #5321

Closed
jpsim opened this issue Feb 7, 2016 · 7 comments
Closed

[SR-688] Package.swift isn't respected for dependencies #5321

jpsim opened this issue Feb 7, 2016 · 7 comments
Labels

Comments

@jpsim
Copy link
Contributor

jpsim commented Feb 7, 2016

Previous ID SR-688
Radar None
Original Reporter @jpsim
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee kkoval (JIRA)
Priority

md5: 843a95daa5865ec2651e488a650f2990

Issue Description:

Swift Package Manager doesn't respect its dependencies' Package.swift files, which means (among other issues) that packages with interdependencies fail to build when included as dependencies to other projects.

For example, take this Package description from the Swift Package Manager's documentation:

let package = Package(
    name: "Example",
    targets: [
        Target(
            name: "top",
            dependencies: [.Target(name: "bottom")]),
        Target(
            name: "bottom")
    ]
)

If I attempt to use this package as a dependency, {code:none}swift build

@mxcl
Copy link
Contributor

mxcl commented Feb 11, 2016

Seems unlikely that this bug exists, since SwiftPM builds itself and it has many targets with many dependencies.

@jpsim
Copy link
Contributor Author

jpsim commented Feb 12, 2016

My apologies, the specific scenario I provided in my initial report has no issues.

However, I just created a minimal repro case at https://github.com/jpsim/SR688Example demonstrating that the "excluded" key isn't being respected.

$ pwd
/SR688Consumer
$ tree
.
├── Package.swift
└── Sources
    └── main.swift

1 directory, 2 files
$ cat Package.swift
import PackageDescription

let package = Package(
    name: "SR688Consumer",
    dependencies: [
        .Package(url: "https://github.com/jpsim/SR688Example.git", majorVersion: 0)
    ]
)
$ cat Sources/main.swift
$ swift build
Cloning https://github.com/jpsim/SR688Example.git
Using version 0.0.1 of package SR688Example
Compiling Swift Module 'bottom' (1 sources)
Compiling Swift Module 'gibberish' (1 sources)
/SR688Consumer/Packages/SR688Example-0.0.1/Sources/gibberish/gibberish.swift:1:1: error: expressions are not allowed at the top level
invalid Swift
^
/SR688Consumer/Packages/SR688Example-0.0.1/Sources/gibberish/gibberish.swift:1:8: error: consecutive statements on a line must be separated by ';'
invalid Swift
       ^
       ;
/SR688Consumer/Packages/SR688Example-0.0.1/Sources/gibberish/gibberish.swift:1:9: error: expressions are not allowed at the top level
invalid Swift
        ^
/SR688Consumer/Packages/SR688Example-0.0.1/Sources/gibberish/gibberish.swift:1:1: error: use of unresolved identifier 'invalid'
invalid Swift
^~~~~~~
/SR688Consumer/Packages/SR688Example-0.0.1/Sources/gibberish/gibberish.swift:1:9: error: expected module member name after module name
invalid Swift
        ^
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swift-build-tool", "/SR688Consumer/.build/debug/SR688Example.o/llbuild.yaml"]

And the actual dependency package has no issue building at all:

$ git clone https://github.com/jpsim/SR688Example.git
Cloning into 'SR688Example'...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 10 (delta 0), reused 10 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
Checking connectivity... done.
$ cd SR688Example 
$ swift build
Compiling Swift Module 'bottom' (1 sources)
Linking Library:  .build/debug/bottom.a
Compiling Swift Module 'top' (1 sources)
Linking Executable:  .build/debug/top
$ .build/debug/top
bottom

@swift-ci
Copy link
Contributor

Comment by Kostiantyn Koval (JIRA)

Yes, there is really an issue. The exclude key is only handled for the root package, but it's not handled for dependencies.
Thanks for finding it.
Are there any other keys that are not handled correctly when working with dependencies?

@swift-ci
Copy link
Contributor

Comment by Kostiantyn Koval (JIRA)

This seems to be an easy fix. Need to add tests for that.

kostiakoval@600c0d9

@swift-ci
Copy link
Contributor

Comment by Kostiantyn Koval (JIRA)

It's fixed now and PR is waiting for merge.
#128

@swift-ci
Copy link
Contributor

Comment by Kostiantyn Koval (JIRA)

@jpsim This issue suppose to be fixed in master branch now. Can you please verify that and update issue status.

@mxcl
Copy link
Contributor

mxcl commented Feb 19, 2016

Marked as resolved, but will close when we get confirmation.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants