iOS——静态库与在多个其他项目中包含一个项目
我有一堆代码在多个项目中使用。现在,我通过复制粘贴来完成,这不太理想。据我了解,要让多个项目引用相同的源代码,我至少有两个选择:
1)创建一个静态库并将其包含在多个项目中
2)使用共享源代码创建一个项目,并将其导入到所有其他项目。
这些方法的优点和缺点是什么?我什么时候会更喜欢其中一种?
I have a bunch of code I am using in multiple projects. Right now, I am doing it by copy-and-paste, which is less than ideal. As I understand it, to have multiple projects refer to the same source code, I have at least two options:
1) Create a static library and include it in multiple projects
2) Create a project with the shared source code, and import that into all of the other projects.
What are the advantages and disadvantages of these approaches? When might I prefer one over the other?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将项目包含在静态库中,这将利用静态库和包含的项目的所有优点:)它工作得很好,不能说这种方法的显着缺点。
You can include project with static library, which will use all advantages from static library and included project :) It works well, cannot say anything about significant disadvantages of such approach.
在项目中包含静态外部库的唯一缺点是它的大小;如果您使用的是“通用”库(在模拟器 + 设备上工作),则必须以 i386 和arm(现在为armv7)为目标。
因此,您将使用无法用于您的移动解决方案的“死代码”来充实您的项目。
如果您包含一个具有共享源代码的项目,您将能够编译移动设备所需的内容,但每个人都可以看到您的代码...
The only disadvantage of including a static external librairy to your project would be the size of it; if you are using a library that will be "universal" (working on the simulator + the device), you'll have to target i386 and arm (today armv7).
So you will inflate your project with "dead code" that can't be used on for your mobile solution.
If you include a project with share source code, you'll be able to compile just what you need for you mobile device, but everybody can see your code ...