1

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

9 Comments

#import "../Projectname" Did not work. am I missing anything? Is my folder structure wrong?
If it did not work, you must be missing something. You'd better post your folder structure if you can, so I can go into more detail. And the folder structure doesn't mean Xcode's groups structure, it mean the REAL file organization that you can see it in your Finder.
Btw, the header searching example I talked above is based on the condition that app A and app B is put in a big folder, so that each file of app A could use a relative path to find app B's header.
ProjectMerge folder has ProjectA(folder), ProjectB(folder) and workspace file. ProjectA and B individually have their own .xcodeproject file and all other controllers , libraries and frameworks.
Based on what you just said, that's hard to say what the problem is. I just created a demo for you. You can check about it. It seems like Xcode project has to drag one file into its field when you add a file from outside after simply adding that file to its compile source. Btw, you can see App A->ViewController.m, it imports a header in App B. And you can run App A to see the result.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.