Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting an existing project into customizable framework

I am a android developer and I needed to create and IOS app. So I did and app is ready now. But now I want to make it a Library/Framework. I mean a same code base will be used in different projects per client and they will be able to change the text strings and colors of app. The rest of the business logic will be remain same.

So Simply I have two major question:

  • How to convert the Project into Framework? Do I need to create a separate framework elsewhere and then import the project into it as Coca touch Framework? Am I right??
  • How to make it customizable? What I meant from Customizable is simple two things.
    • 1) Colors of Views. I have two many views. I want A separate file of colors so that I can change color in it and it reflects changes in whole application
    • 2) String. I want to change the text string so that it can be changed in all over the projects.

Please tell me how can I achieve these things. Specially point number two is my main concern.

Note: The project that I want to convert in framework has two many viewControllers and all are built in one storyboard.

like image 549
Android teem Avatar asked Jul 11 '18 12:07

Android teem


People also ask

How do I add a framework to a Swift project?

In order to create an iOS Framework you need to click on File -> New -> Project (Shift + Cmd + N) -> Framework (under iOS tab, Framework & Library section). Framework under Framework & Library section.

How do you create a framework on a Mac?

Creating Your Framework. From Xcode, choose File > New Project to create your project. Follow the prompts to select the type of framework you want and where you want to put your project directory. The default templates that come with Xcode let you specify whether you want to create a Carbon or Cocoa framework.


2 Answers

With regard to how to create a framework, here's how I'd do it:

  1. Create a workspace: enter image description here

  2. Bring the project you want to turn into a library into that workspace by dragging it in from the Finder (make sure it's not open in XCode when you do this). Let's call that project FrameworkProj:

  3. Create a target for FrameworkProj of type Cocoa Touch Framework: CocoaTouchFramework

  4. Create a second project, which we'll call SampleProjWhichUsesFramework, and import the framework into it.

As for your question of IB elements being settable via the framework, simply make sure you have IBOutlets for those elements that are marked public, and they will be available to SampleProjWhichUsesFramework as properties of your framework.

like image 98
jglasse Avatar answered Oct 06 '22 16:10

jglasse


I think you do not have good idea of the workspace in IOS Xcode. Since in Android the workspace is dealt in another way. But there is a slight difference.

Lets me just tell you about Android and how do you made the Library and add several projects in Android studio. let say you have a Project in Android App, say App1, now you can go to menu and you can add another module as Library. That is fine and easy for you. Now you can create another project like this, GO to new menu, here you can select New Module and then from templates you can select Phone and Table Module. let's call it App2.

Similarly you can add as many projects/app in the same project (in IOS you can think of a Workspace), and in the end, All you need to do is adding Your library project as a module dependency in All App1, App2 projects you created.

So in IOS, workspace you create at first. And then You create App1, App2 in it. You add Library (Private Framework in IOS) in same project level (same directory) Then You can add the dependency of Library into Other App1, App2 and so on other projects you created.

In this way, your codebase will remain the same for others.

You can find the whole tutorial here. It is the best I have found just give it a try.

like image 43
A.s.ALI Avatar answered Oct 06 '22 16:10

A.s.ALI