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

huangapple go评论79阅读模式
英文:

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

问题

我创建了一个Swift包,编译没有问题。

我在项目中导入了这个Swift包。

项目中看不到包中的任何类,所以我将它们设为public。

我在需要的地方添加了 public init() {}

方法仍然看不到。

所以我在项目中修改了包中的代码,但Xcode不会编译包或检查任何错误。因此,我在包中看不到任何错误。

因此,我不得不关闭项目,打开包以查看错误,进行修改和测试,然后关闭包,再打开项目。

这是因为如果打开了使用它的项目,Xcode不会允许查看包。

真是让人恼火。

有没有办法在项目内部编译和调试包?不用关闭一个然后打开另一个?

从Xcode的顶部栏更改包不起作用。

为什么包内的public类和方法在项目中仍然看不到?我需要在清单中添加什么吗?

我的清单是由Xcode默认创建的。这个包没有依赖项,只是我多年来创建的一组类和类扩展。

*总结一下:我有一个“包”和一个依赖于该包的“项目”(作为本地Swift包)。当我打开项目时,包中的错误没有报告,即使它们已被声明为public也不可见。

英文:

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).

答案1

得分: 1

使用您描述的方法添加软件包似乎没有执行将其添加到目标的最后一步。如果您在目标的常规设置中执行此操作(在Frameworks、Libraries和Embedded Content中),它会起作用。尽管我必须承认,我不得不几次强制Xcode停止抱怨才行。

英文:

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.

答案2

得分: 0

我喜欢Xcode。解决这个问题的答案是从项目中移除该包并重新添加。

英文:

I love Xcode. The answer to solve this was to remove the package from the project and add it again.

huangapple
  • 本文由 发表于 2023年8月9日 17:13:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76866235-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定