I have 4 different xcode projects.i want to call viewcontroller of different project from one single project.How can i do this

707 views Asked by At

I have 4 different XCode projects for different modules on different branches of git. I want to make a common project/app through which i can call all 4 modules. There modules are to be displayed like list in table. Through a common login all modules will be called. How can i do this?

what i have Done till now: I have taken all modules checkout and added them in a single workspace. But without making them framework, i am unable to call them from the common project. Also my modules are large and framework classes to accessed need to public. So is there not any other good way to do this. Hope i am able to clearify my problem..

thanks

5

There are 5 answers

1
sam-w On

You've said above that

All projects are independent running projects

which suggests that each of your 4 projects is compiling its source files into an Application.

You seem to be building your own new application, so you don't care about whatever each of these four projects is building. You only care about the source files.

  • Ignore the project files.
  • Locate the .swift files which contain the objects you're interested in.
  • Add them to your own project.
  • Build.
1
S.Govind On

You can use Multiple URL scheme concept to achieve that feature.Just like in Android multiple flavour concept

0
SAURABH SANWAL On

I think what you want to say, is to open a particular View controller on your second application from you first application. You can achieve this by using URL Scheme in iOS.

  1. Go into your app's info.plst file.
  2. Add a Row to this and call it "URL types"
  3. Expand the first item in "URL types" and add a row called "URL identifier", the value of this string should be the reverse domain for your app e.g. "com.yourcompany.myapp".
  4. Again, add a row into the first item in "URL types" and call it "URL Schemes"
  5. Inside "URL Schemes" you can use each item as a different url you wish to use, so if you wanted to use "myapp://" you would create an item called "myapp

your structure should look something like this

Check this link, you will get better understanding, Thanks. iOS Custom URL Scheme

1
Rocket Garden On

To solve this you need a dependency management solution, because you want changes to the individual projects to be reflected automatically in the overall project. You have decided you can't use frameworks which are the natural choice for this, for practical reasons (the framework class size and access level).

The solution is to find a different dependency management solution for your source code.

The next most obvious option is to use git submodules, because this has been explicitly designed for modularising at the source level. If you use this in conjunction with the solution suggested by @sjwarner for project organisation you should be able to achieve what you need.

https://git-scm.com/book/en/v2/Git-Tools-Submodules

"Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate."

In other words you can continue to maintain each view controller separately, and the commits can be included into your overall project.

(Note that the submodules do not have to be the individual projects themselves, you could potentially make only the viewcontrollers separate submodules, but this might be a bit more complex to set up and maintain)

a) make each project containing the view controller you want a git repository if it is not already one.

b) create a git repository for your main project (if it is not already one)

c) add each project as a git submodule to your main git repo

d) follow @sjwarners suggestion on source code organisation for the overall project

0
Alex V. On

If you already have all the source files you need in your workspace as projects, you need to create a new target Framework and at add needed controller and its dependencies to the framework. (via right side panel first tab or directly from the build settings). Add this framework to the dependencies of you app and import it. Be careful you probably should make at least your controller public/open(if you need subclassing)