简体   繁体   English

如何在Xcode项目之间共享文件

[英]How to share files among Xcode Projects

I have made some categories of some classes such as NSArray and NSDictionary. 我对某些类做了一些分类,例如NSArray和NSDictionary。 I would like to use these categories in several projects. 我想在几个项目中使用这些类别。 I may modify the files in any project, and I want all other projects get the updated files. 我可以在任何项目中修改文件,并且希望所有其他项目都获得更新的文件。

What's the best way to share files among projects? 在项目之间共享文件的最佳方法是什么?

I have read this problem and this problem . 我已经读过这个问题和这个问题 Someone recommended to add targets into the same project. 有人建议将目标添加到同一项目中。 This is not a good solution in my situation, because my projects are not related to each other, and I have many projects. 在我的情况下,这不是一个好的解决方案,因为我的项目彼此不相关,并且我有很多项目。

In your case you can create a static library and put all of your classes, class methods or sub classes then you can link to your individual projects. 在您的情况下,您可以创建一个静态库并放置所有类,类方法或子类,然后可以链接到各个项目。

Static libraries provide a convenient mechanism for sharing code among multiple applications. 静态库提供了在多个应用程序之间共享代码的便捷机制。 On iOS, static libraries are the only supported library type. 在iOS上,静态库是唯一受支持的库类型。 This document explains how to extract code from your application into a new static library and how to use that static library in multiple applications. 本文档说明了如何将代码从应用程序中提取到新的静态库中,以及如何在多个应用程序中使用该静态库。

Whenever you want to add/edit/remove something you can edit and rebuild your library. 每当您要添加/编辑/删除内容时,都可以编辑和重建库。 Creating the Library and Creating a Static Library in iOS . 在iOS中 创建库创建静态库

When Xcode 6 and IOS 8 released IOS will support frameworks as well. 当Xcode 6和IOS 8发布时,IOS也将支持框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM