FelixHerrmann / swift-package-list

A command-line tool to get all used Swift Package dependencies.
MIT License
136 stars 18 forks source link

Error: The version of the Package.resolved is not supported #113

Closed JulesMoorhouse closed 6 months ago

JulesMoorhouse commented 6 months ago

I'm using Xcode 15.3 and the build phase for swift-package-list creates this error

Error: The version of the Package.resolved is not supported

I have the following

.package(url: "https://github.com/FelixHerrmann/swift-package-list.git", from: "4.1.0"),
.product(name: "SwiftPackageListUI", package: "swift-package-list"),

Earlier I had the old version 3.0.10, which had the same issue, upgrading didn't help.

Any suggestions please ?

Thanks,

Jules

FelixHerrmann commented 6 months ago

Xcode 15.3 introduces the 3rd version of the Package.resolved format. 3.1.0 added support for that in #73 and also changed the error message to indicate the (unsupported) version it received. Your error indicates that you still use 3.0.10 so please make sure you have it correctly installed. You can also give the SPM plugin a shot instead of the manual run script phase, this eliminates any local installation issue automatically, see #build-tool-plugin. Let me know if that helped!

JulesMoorhouse commented 6 months ago

Hmmm, I'm a bit confused as to whats going on.

I reverted back to Xcode 15.2 after I posted earlier and things seemed to be working. However, I didn't go into to acknowledgements screen to see what was being shown.

Before I posted the issue above, I was using Xcode 15.3, and was seeing swift-package-list 4.1.0 in my pacakges, and was getting the error I posted. So what you say confuses me.

Now, I've switched back to 15.3, I'm no longer getting the error, which puzzles me. I haven't added the build-tool-plugin to my spm, where I'm using swift-package-list, as I'm a bit confused about what I should add to my package file. I know you have a link the swift forums, but I'm not sure what to add.

Anyways, here's my build phase scripting... which was working previously.

if test -d "/opt/homebrew/bin/"; then
  PATH="/opt/homebrew/bin/:${PATH}"
fi

export PATH

if command -v swift-package-list &> /dev/null; then
    OUTPUT_PATH=$SOURCE_ROOT/$TARGETNAME
    #swift-package-list $PROJECT_FILE_PATH --output-path "$OUTPUT_PATH" --requires-license --file-type plist
    #mv "$OUTPUT_PATH/package-list.plist" "$OUTPUT_PATH/../Acknowledgements.plist"
    swift-package-list generate "$PROJECT_FILE_PATH" --output-path "$OUTPUT_PATH" --requires-license --file-type plist
else
    echo "warning: swift-package-list not installed, https://github.com/FelixHerrmann/swift-package-list"
    echo "use brew tap FelixHerrmann/tap"
    echo "use brew install swift-package-list"
fi

I've created the file... swift-package-list-config.json

{
    "projectPath" : "myapp.xcworkspace",
    "project" : {
        "outputType" : "plist",
        "requiresLicense" : false
    },
    "targets" : {
        "myapp" : {
            "outputType" : "plist",
            "requiresLicense" : true
        }
    }
}

I can also see that my package-list.plist is being updated, but not being changed, git isn't picking up changes, but the file is being modified.

Also, I can't see any of the licenses in my acknowledgements screen.

But I don't have a build error.

As I say I'm a bit confused.

JulesMoorhouse commented 6 months ago

Edit: Now, I've switched back to 15.3, I'm no longer getting the error, which puzzles me. -> Because I have 4.10

FelixHerrmann commented 6 months ago

It could be the case Xcode 15.2 reverted the Package.resolved format back to v2 and after going to 15.3 it remained like that (I think it only gets upgraded when you trigger an SPM update). Anyways let me clarify the 2 main options you have for you project so you don't mix up things that shouldn't be:

Homebrew installation + Run Script

SPM Plugin

FelixHerrmann commented 6 months ago

I haven't added the build-tool-plugin to my spm, where I'm using swift-package-list, as I'm a bit confused about what I should add to my package file. I know you have a link the swift forums, but I'm not sure what to add.

If you have a normal Xcode project (or workspace) you have to add the plugins via UI:

Screenshot 2024-05-05 at 22 04 24
JulesMoorhouse commented 6 months ago

Thanks for your help. I've got everything working.

There were some changes I wasn't aware of, which weren't immediately apparent.

AcknowledgmentsList(packageProvider: .propertyList())

Also more obvious file-type to output-type.