swiftswift-package-managerswift-package

How to debug and build a swift package from a project and why public classes inside the package are still not seen?


I have created a swift package that compiled fine.

I have imported the swift package in a project.

No class inside the package is seen on the project. So I made them public.

I added public init() {} where needed.

Methods are still not seen.

So I modify code in the package from within the project, but Xcode does not compile the package or check any errors. So, I do not see any errors in the package.

Thus, I have to close the project, open the package to see the errors, do and test the modifications, close the package, open the project.

This is necessary because Xcode will not allow to see the package if the project using it is opened.

For duck's sake, that is annoying as hell.

Is there a way to compile and debug the package from within the project? Without this insanity of closing one and opening the other?

Changing the package from Xcode's top bar, does nothing.

And why the public classes and methods inside the package are still not seen on the project? Is there something I have to add to the manifest?

My manifest is the one created by default by Xcode. The package has no dependencies and is just a collection of classes and class extensions I created over the years.

In resume: I have a "package" and a "project" that depends on the package (as a local Swift package). When I open the project, the errors in the package are not being reported and the classes are not public, even after they have been declared as so (I've added this comment by Sweeper to clarify things).


Solution

  • Adding a package using the method you've described doesn't seem to perform the final step of adding it to the target. If you do that (in Frameworks, Libraries and Embedded Content in the general settings for the target), it works. Though I confess I had to kick Xcode a couple of times to get it to stop complaining.