简体   繁体   English

Xcode:在项目之间共享方法和价值

[英]Xcode: sharing methods and values between projects

I have an Xcode project that contains a couple sub projects. 我有一个Xcode项目,其中包含几个子项目。 I'm continuing the project but I was not the one that set up the project as it is. 我正在继续该项目,但我不是按原样设置该项目的人。 The main project has a utility method class and some plist values that I need to access in the subclasses. 主项目有一个实用程序方法类和一些我需要在子类中访问的plist值。 I'm confused as to how to do that. 我对如何做到这一点感到困惑。 项目设立

"Subproject 1/2" needs to access a utility class and some plist methods in "Main Project". “子项目1/2”需要访问实用程序类和“主项目”中的某些plist方法。

Is that possible? 那可能吗? What have I missed on the forums? 我在论坛上错过了什么?

Thanks for the help. 谢谢您的帮助。

I would pull the utility classes out of the main project into a 3rd subproject, and then have everyone who needs to use the classes reference the new subproject. 我将实用程序类从主项目中拉到第三个子项目中,然后让需要使用这些类的每个人都引用新的子项目。

Do the utility classes use the plist from the main project or is that separate? 实用程序类使用的是主项目中的plist还是单独的? Regardless, if the plist is a resource of the main project, it should be available to all app code provided it's copied into the app bundle. 无论如何,如果plist是主项目的资源,则只要将其复制到应用程序包中,所有应用程序代码都应该可以使用它。

To access the class from the subprojects all you need is to include the header for that class into the subproject. 要从子项目访问该类,您所要做的就是将该类的标题包含在子项目中。 Then upon building it will resolve the class type and available methods properly. 然后在构建时,它将正确解析类类型和可用方法。 The main project will build the class and compile it into the project, then when the subproject calls any of that class it will be present in the project and usable. 主项目将构建该类并将其编译到项目中,然后当子项目调用该类中的任何一个时,它将出现在项目中并可用。

As for the plist values, I would assume those are just read from files. 至于plist值,我假设这些只是从文件中读取的。 You should be able to read them into the subproject the exact same way as in the main project, but I'm much more fuzzy on plists. 您应该能够以与主项目完全相同的方式将它们读入子项目,但是我对plists更加模糊。 I know it works with regular files. 我知道它适用于常规文件。

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

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