简体   繁体   中英

Xcode: sharing methods and values between projects

I have an Xcode project that contains a couple sub projects. 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. 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".

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

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. 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. I know it works with regular files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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