简体   繁体   中英

How to import standalone Xcode Project as a module to another project?

Both projects use same frameworks. both have appdelegates. Successfully added both projects in workspace. but can not access each others controllers. making a static library of one project did not help. making a framework of one project?? which way to go?

Because you're talking about making a static library, I think your project is an OC project. So here's the thing, if you're going to merge these two apps , you should first take out the contents that can't be duplicated, like AppDelegate and some other app settings.

You said you put two projects into one workspace but you can't access to one project's view controllers from another. That's because you did not import the header in a right way.

For example, each project has its own header search path, which can be set at your xcodeproj-Build Settings->search header search path. By default, the current path(".") of one xcodeproj's header search path is at where your xcodeproj placed. And Xcode search all of the headers in that folder recursively.

If you want to access app B's header from app A. Assumed that you had a view controller in your app A's root folder. To Access app B's header, your import may seem like so:
#import "../app B/somekindofVC.h"
If you just want to import "somekindofVC.h", you can add "../app B" as a header search path in Build Settings, and select the 'recursive' option if necessary.

That's how your xcodeproj can find another's headers.

There is one more important thing should be done is that you should add app B's shared code into compile source. Since your app A could know a class of app B through header, the compiler doesn't know what is the implementation of app B's classes. So before you run your project, remember to add '.m' files you need in Build Phases->Compile Sources.

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