简体   繁体   English

如何在iOS中将一个Xcode项目使用到另一个Xcode项目中?

[英]How to use one Xcode project into another Xcode project in iOS?

I want to add one Xcode project to another Xcode project. 我想将一个Xcode项目添加到另一个Xcode项目。

For example currently I have Test1.xcodeproj and this project have .h and .m files. 例如,当前我有Test1.xcodeproj ,此项目有.h.m文件。 It also includes images/assets or storyboard files. 它还包括images/assets或情节提要文件。

I again created new Test2.xcodeproj and I also want to import Test1 files to my Test2 project. 我再次创建了新的Test2.xcodeproj ,我还想将Test1文件导入到我的Test2项目中。

What is the best solution to solve this issue? 解决此问题的最佳解决方案是什么?

Can I create static library or framework for Test1.xcodeproj ? 我可以为Test1.xcodeproj创建静态库或框架吗?

How to access Test1 files to Test2 project? 如何访问Test1文件到Test2项目?

Any help or direction would be appreciated. 任何帮助或指示,将不胜感激。 Thanks! 谢谢!

if you need classes and storyboard or xibs etc then you can open your files in finder and then can copy and paste in your another project! 如果您需要classes and storyboard or xibs等,则可以在finder中打开文件,然后可以复制并粘贴到另一个项目中! and you can access it as you have created that classes in that project. 您可以在该项目中创建该类后对其进行访问。 It is as like you drag and drop third party library in your project. 就像在项目中拖放第三方库一样。 Library are nothing but bunch of classes. 图书馆不过是一堆类。

If you have storyboard and xib also then you need to manage some things like, you have to use multiple storyboard if you have another storyboard in current project. 如果您同时具有情节提要和xib,那么您需要管理一些事情,例如,如果当前项目中还有另一个情节提要,则必须使用多个情节提要。

If you want to include assets and storyboards you'll need to create a Cocoa Touch Framework. 如果要包括资产和情节提要,则需要创建一个Cocoa Touch Framework。 Go to File->New->Project and select Cocoa Touch Framework. 转到文件->新建->项目,然后选择Cocoa Touch Framework。 Add all your Test1 files to this project. 将所有Test1文件添加到该项目。 Add the framework project Test1 to your Test2 project. 将框架项目Test1添加到您的Test2项目。 You can do this via File->Add File To... 您可以通过File-> Add File To ...

To get the code to link with Test2 you will need to add it as an embedded binary. 为了使代码与Test2链接,您需要将其添加为嵌入式二进制文件。 Go to the general tab of the project settings and scroll down to the bottom. 转到项目设置的常规选项卡,然后向下滚动到底部。 Click on the plus sign in the embedded binaries section and choose the Test1 project. 单击嵌入式二进制文件部分中的加号,然后选择Test1项目。 This will also add Test1 to your linked frameworks and libraries and the target dependencies of the project. 这还将把Test1添加到链接的框架和库以及项目的目标依赖项中。

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

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