Missing package product, - swift

Here is a link to my package.
So after updating my Swift Package and its version tag,
I am getting the following errors when I try to update the package in my project that consumes the package.
Missing package product 'MyPackage1'
❕Package resolution errors must be fixed before building
https://github.com/ElevatedUnderdogs/PackageTest2.git
has no Package.swift manifest for version 1.0.1
1.0.0 is the original. 1.0.1 is my updated version.
Does this mean I need to create a new Package.swift for every single version? I don't even see a place in the Package.swift where I can signify the current version.
Things I've tried:
reseting the package cache in the consuming project.
"updating to latest package versions"
Deleting the Swift Package, and then trying to add it again. Before adding it completes, I get: "MyProject.git has no Package.swift manifest for version 1.0.1.
Package.swift is in the root directory.

In my case, the tag was updated on an incorrect remote branch which wasn't merged to yet, so the tag's corresponding commit didn't have the Package.swift file. It is a good practice to check the commit hash of the version you are trying to access to verify that it has the correct code.

Related

Trying to install package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references

I used NuGet Package Explorer (for the first time) to create a .nupkg to share with others. I have one DLL that targets NetStandardLibrary 2.0,
But when I try to add the package I receive the following error:
Could not install package 'iCANMVCSDK 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I thought that by using NETStandard 2.0 it could be installed in any .NET app. I also tried adding additional assemblies:
I rebuild, repackage, and I still get the same error. What am I missing?
I tried editing the project file like this:
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
When I try to build after adding net472, I receive the following error:
The type or namespace name 'Http' does not exist in the namespace 'System.Net'
What really makes no sense to me is that I can add the DLL directly into the project (the one that targes NET 4.72) and it works as expected. The problem is when attempting to install it as a NuGet package.

An unknown error occurred. could not find repository from <a valid local path> (-1)

Xcode isn't totally happy with my Package.swift file.
This is the line with an issue;
.package(name: "Utilities", url: "file:///Users/Alexander/Development/MMXX/Repositories/Utilities", from: Version("1.0.0"))
The package is a local package I have created, and is in use for a few other apps, so I know it is a valid package and its location is correct.
The Version 1.0.0 is "made up" in the sense that I haven't declared a version anywhere and didn't know what else to put there. It was the only thing I tried that Xcode was able to parse successfully -- it parsed the information, it just can't match it to my local repository.
The package was created using Xcode, and I didn't issue any commands to make it a git repository. Do I need to update my app's plist to allow disk access to a folder outside the app's sandbox?
Any pointers what else I can try would be most appreciated! Thanks.
Here is what finally worked:
in the dependencies: section
.package(path: "../Utilities")
in the targets: section
.product(name: "Utilities", package: "Utilities")
Edit:
I ran into this problem again. I dragged the package folder into the active project and it loaded the referenced libraries. But it wouldn't compile (couldn't find the new package).
Make sure you select the target and navigate to "Frameworks, Libraries and Embedded Content", click on the "+" and add the package:

Error saying "Module Not Found" when adding SPM which uses other SPMs as dependencies within itself

I have been creating a Swift Package Manager. It uses 2 other SPMs within itself. SPM compiles fine when compiled independently. As soon as the project is imported into an Xcode project I get a compiler error saying that:
No such module 'ModuleName'
Note: The ModuleName in the above error corresponds to the package imported within the package that is being imported to my project.
I have been stuck on this for a pretty while now and have tried the following:
Removed and readded the SPMs to dependencies to my SPM, and then tried importing my SPM to my project (I did this before and after each of the other steps too).
Checked to see where these packages where being added as dependencies. It shows up in the SPM main target Module -> Build Phases -> Link binary with libraries. I additionally added it to the Dependencies section to see if it changes anything.
Tried adding SPMs to ModulePackageDescription target to Dependencies section.
Added the dependencies in the Package.swift file as follows.
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "package1_url", .branch("master")),
.package(url: "package2_url", .branch("master"))
]
Adding this would import the other dependencies to my Xcode project. I don't exactly want this to happen because in case I try to use another version of the SPM that is being imported within my SPM, it would cause conflict between the two versions. But I'm willing to do this if it's the right way to go. But even adding dependencies in Package.swift didn't work for me. How would I resolve this issue? Let me know if anyone has faced the same issue.
Are the libraries public classes also need to contain constructors?
public struct NumbersA {
public init () {
}
}
also add them to the dependency Package.swft->dependencies: ["NumbersA"]),

SPM - Package contains revisioned dependencies

I am trying to install the MongoDB swift driver using the swift package driver. I followed their instructions and installed the mongo-c-driver using home-brew. I then created a new directory and within a new project using:
swift package init --type executable
I then added the dependencies to the Package.swift file.
When trying to run any command that summonsswift package resole in the directory, i get the following error:
error: the package PackageReference(identity: "mongo-swift-driver", name: nil, path: "https://github.com/mongodb/mongo-swift-driver.git", isLocal: false) # 0.0.2 contains revisioned dependencies:
PackageReference(identity: "swift-bson", name: nil, path: "https://github.com/mongodb/swift-bson", isLocal: false) # master
PackageReference(identity: "swift-mongoc", name: nil, path: "https://github.com/mongodb/swift-mongoc", isLocal: false) # master
I made sure that everything is up to date and that the first line of the Package.swift is // swift-tools-version:4.0
I would like to know what these revisioned dependencies are, as i have not found anything useful. And how this error can be resolved.
The Swift Evolution proposal that introduced the ability to specify branches instead of revisions in SPM packages (SE-0150 says this:
While this feature [specifying branches] is useful during development, a package's dependencies should be updated to point at versions instead of branches before that package is tagged for release. This is because a released package should provide a stable specification of its dependencies, and not break when a branch changes over time. To enforce this, it is an error if a package referenced by a version-based dependency specifies a branch in any of its dependencies.
It looks like the version 0.0.2 of the parent package that you're using did not follow the rule to switch to specific versions for its dependencies and SPM doesn't allow this.
If possible, you should try to use a newer version of the parent package that fixes this issue. If a newer version doesn't exist, you may have to override the dependency and fix it yourself (I believe you can use swift package edit to do that — or fork the dependency and point to your own repo, of course.)

Avoid dependency of a pure code snippet package

Example:
Nuget package A is a set of code snippets (it does not contain an assembly).
Nuget package B is a normal assembly and it is using package A - just for internal means.
Question: What can I do, to avoid, that package A is also installed, when somone installes package B?
Found something in documentation of nuget:
Starting from version 2.7, the pack command will ignore entries in the packages.config file which have an attribute developmentDependency set to true and will not include that package as a dependency in the created package. For example, consider the following packages.config file in the source project
That seems to solve the problem.