Somehow I cannot use the package (SQLite) from my code because the "import SQLite" is not found. This happens from a newly created and otherwise empty package as well.
How can I use the dependent package in my own package?
Sorry for the seemingly simple question but despite a lot of googleing and fiddling with targets/products, I don't get this to work. UI options in Xcode to add targets etc. exist only for apps, not for packages.
Any hints what I am doing wrong here greatly appreciated.
There's two places that you need to add dependencies to a swift package, and the second snippet isn't typically included in project READMEs - depending on the package, it can be a little quirky or hard to work out what to use.
The first piece is what you copied - that adds a dependency stanza to the overall Package declaration. The second is what I suspect you were missing - adding a reference to the target that needs the dependency.
The second place, that wasn't obviously referenced in the README of the library project, is the bit you add to a specific target:
Thank you so much! Exactly what I needed. Makes sense now that I see it but somehow couldn't figure it out from documentation. Weird package manager doesn't just automate these things from the UI.
I have created a new package (child package) in another package (parent package) and added child package into a group/folder inside parent package directory. I need to add this child package as a dependency in my parent package and also it should be available for other projects wherever we add parent package as a dependency. Can someone suggest the process on how to achieve this or please share the package.swift of parent package. I tried by adding child package into parent package's package.swift file under dependencies as .package(path: "../Packages/PackageName"), but I'm always getting "No such module ..." on import statement in parent package.
I would recommend to put the parent and the child packages in different folders on the same level (not one underneath the other). In the child's Package.swift you add the dependency to the parent (as given by the add package dialog) and then also add the dependency for the target as shown above. For both parameters in the target dependency, the package name should be fine.
1st is just flatten structure by uniting parent and child. If your packages so tightly bounded, that you need to make child available within parent use you, it makes a lot of sense to unite them. I agree that there might be cases when this make less sense, but in 99% that the best way.
2nd is to re-export child package (if first is not an option, I'd prefer this variant probably):
and similarly to previous add product in your parent package. It is kinda mix of first two, but at this point it is questionable why not to just flatten to one as in first point.