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

5

9

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

Conserve answered 16/8, 2018 at 10:34 Comment(8)
Add them into one workspace?Epistrophe
but in workspace, i am unable to communicate between viewcontrollers of two projects e.g. push viewcontroller from another project.Conserve
Because you have to put the shared files into top level of workspace hierarchy? The best solution may be to create a private framework which will be shared in all of this projects and contain all needed classes etc.Epistrophe
All projects are independent running projects. I tried to make all projects like cocoapod and framework but it failed because for this i have to make all classes public.All projects are contains at good amount of files and assets.Thats why i am stuckConserve
I find more details in your comments than on the question itself. Please add details onto the question.Endoparasite
@Endoparasite thanks. i have added more details for the problemConserve
Are those projects written in ObjC or Swift?Steal
All modules are independent "Swift" project on 4 different branch..having their own podfile and workspace..Conserve
A
5

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

Agogue answered 26/8, 2018 at 11:11 Comment(1)
this seems to be the answerLenity
D
2

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.
Dispensary answered 16/8, 2018 at 13:5 Comment(1)
thanks. But for one time manual is good. But i want to automate this thing. so that for any update in any project , i will update only the library/framework and i got the final project with all updated projects .Conserve
B
2

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

Basidium answered 23/8, 2018 at 11:56 Comment(0)
C
0

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

Cavalryman answered 20/8, 2018 at 17:56 Comment(1)
Can u share a demo link?Conserve
E
0

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)

Euh answered 28/8, 2018 at 4:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.