6

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.

Joe
  • 879
  • 3
  • 14
  • 37
Android teem
  • 780
  • 2
  • 13
  • 36
  • You can use `Targets`. You would need to create a target per client app. Each target should have its own localisation files for the text and you will want to add a configuration file per target to handle the colours. You will need to create outlets from your storyboard or xibs so that you can then change the colours in code using the configuration file and also so you can set ID's for the strings so the localisation files can kick in. – Hodson Jul 11 '18 at 12:26
  • You should take note of item **4.2.6** in the App Store review guidelines… _Apps created from a commercialized template or app generation service will be rejected unless they are submitted directly by the provider of the app’s content. These services should not submit apps on behalf of their clients and should offer tools that let their clients create customized, innovative apps that provide unique customer experiences…_ – Ashley Mills Jul 11 '18 at 12:35
  • @Hodson can you give me link for this, also tell me what do you mean by configuration file – Android teem Jul 11 '18 at 12:55

2 Answers2

3

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.

jglasse
  • 1,188
  • 12
  • 23
  • I was reading about it > framework. But in your answer I have couple of confusions. In step 1, how to create a workspace ? sorry I am new to whole ios world – Android teem Jul 11 '18 at 13:03
  • That is great. Just one last question: I read more about target. I can achieve that thing using target too. M I Right ?? also which is more suitable in my case, Where I have same codebase and just a little modifications needed in color scheme and strings as well per client ?? what would you suggest ? – Android teem Jul 12 '18 at 10:57
  • Not for what you want to do. The target is built from the same code, so you'll need distinct code to set the colors in each of your different targets. Better to do that with a framework and separate project files. Hope that helps. Feel free to mark my answer as having answered your question ;). – jglasse Jul 12 '18 at 21:30
  • yes I am feeling free. :) +1 can you please post here the good tutorial on How to make\ framework, – Android teem Jul 16 '18 at 07:50
  • its not working, I have a project and Want to make it library, lets call it libraryProject, now I have created a separate project, and then I gone to File> workSpace : I created the workspace. I draged my LibraryProject in it, but nothing happened. What should be done here ?????? – Android teem Jul 16 '18 at 11:15
  • Now you need to create another project in the same workspace which imports that library. – jglasse Jul 16 '18 at 18:42
  • https://stackoverflow.com/questions/25518077/how-to-reuse-swift-code-in-other-projects?rq=1 – jglasse Jul 16 '18 at 20:10
2

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.

Tejas
  • 1,050
  • 12
  • 23
A.s.ALI
  • 1,992
  • 3
  • 22
  • 54