Different user interfaces for a core functionality - ios

I have a Swift project which contains a lot of screens (got from xibs and storyboard) with many core functionalities.
Now two different projects based on these core functionalities are needed. The requirements are these projects must have different headers, cells, colors, assets, etc.
Which strategy would you follow to get different interfaces based on target/project, from a single core framework?

static config:
maybe pull all project related variable, and put it in a plist file, working like archiving and unarchiving. when framework loaded, get boot info from that file.
or abstract all these info into a static class? works almost the same way.
some way dynamic config:
delegate pattern: every project who want to use your framework, must
implement one object with pre-designed protocol, use the object to bootstrap framework, your framework should get the project layer based question answers like header file, assets, etc.
sorry for my English, hope this helps.
;)

Related

Adding Realm objc files inside own static framework

I am creating framework in ObjC first time.
I want to store data inside realm dynamically. i.e. I have JSON for schema and data, and want to create classes, it's properties, objects, etc dynamically.
I have gone through their example code, they have provided DynamicTests.m where they have created data dynamically but I don't get it correctly.
Now I have few concerns and doubts.
What files/Folders should I include to create realm database at runtime? (ie. script folder, configuration Folder, swift folder, core folder?).
How to create dynamic schema and classes with their properties?
Is there any limitation or precaution that I should keep in my mind?
Good questions!
What files/Folders should I include to create realm database at runtime? (ie. script folder, configuration Folder, swift folder, core folder?).
Realm is no different than any other framework in this regard. When building a static framework that depends on another static framework, statically link the dependent framework all you'll be all set. No additional files are required.
How to create dynamic schema and classes with their properties?
By importing the Realm.Dynamic module, you can construct RLMProperty , RLMObjectSchema and finally RLMSchema instances which you can then pass in to RLMRealmConfiguration.customSchema. Also make sure to set the RLMRealmConfiguration.dynamic property to YES.
Is there any limitation or precaution that I should keep in my mind?
The dynamic APIs are a bit verbose and not included in the HTML API documentation, so you're using Realm in "expert" mode ;). That being said, the Realm team is happy to help with any issues you might encounter (I work at Realm).

Create Framework / Library / Module of Swift Objects in Xcode

I am a (very) novice iOS/Swift programmer with a basic question about moving reusable software objects to their own ... something.
I am developing three iPhone apps that present information from three distinct data sets. Those data sets contain unique information but are structurally similar. As such, the apps share some Swift classes that are identical, specifically the classes that model the data. As I continually refactor the code, I find that when I tweak a class in one app's project, I have to remember to go to the other two projects and make the same tweaks to the same classes for those apps. It's getting to be a big headache.
What I would like to do is have one class definition in its own ... something that I can share, link, import, or attach to/from each app's project. From my online research, I suspect that the ... something is a library? or maybe it's a framework? or a module? I have found all three terms are used, but I am not sure how they relate to each other.
Given that all of the software I am writing is in Swift, does Xcode support what I am trying to do? Thank you!
It seems you have the issue of needing the same Swift class in multiple projects. You could build a Framework (aka Module) for this class then copy it in to each project. This is probably the formally correct approach but it is a bit of overkill for just a single class.
Instead, you could just make the file in the Navigator panel a reference in each project to the one actual file.
You could also make a Workspace and then put each project into the workspace and just have the file at the top level (but this may introduce some build complexity).

How to share common classes with extension with many dependencies in a smooth way?

Im currently working on a iOS project where we now want to add some feature for the Apple Watch. Since the extension for Apple Watch is a different target I naturally can't access the code written for the App. I have searched here on stackoverflow and have found two different ways to solve this problem.
Create a dynamic frameworks. This would definitely be the best approach but unfortunately the app must support down to iOS 6, and what I have found this solution will only work on iOS 8+.
Link the files in either Build Phases -> Compile Sources or through Target Membership in File Inspector. The main problem here is that the two classes we want to use have many dependencies to many other classes, which also have other dependencies and so on. From what I understand I need to include all these other files as well if I want to make use of the classes I intend to use in the extension.
So my question is if there is any other better way for me to accomplish this. If I choose #2, first of all I need to include all files, and after that, from a maintenance point of view, if I make changes to there files, for example importing an other class, I need to include that one as well in Compile Sources / Target Membership. Would really appreciate any ideas or advice regarding this! Thank you!
I don't know how "deep" is your coupling regarding point 2. However if you can use interfaces(protocols) instead of direct class referencing you can separate just the classes you need.
Moreover you could re-think whether specific class really need some other class to operate(probably not) or just some methods from it. Those methods could be moved to protocol and your dependant class to implement it(now this class do not need to be part of AppWatch target).
This will be heavy work though if your project is really big and your classes are tightly coupled. I would advice you to read this article about Dependency Injection and especially 'Dependency is bigger than Testing part' :)

Create similar iOS apps reusing almost everything (with Xcode)

I want to make multiple apps which share the same structure and code, but have different images, fonts, names and urls.
I would like a simple way to make this apps without replicating the whole project, so that when I find a bug I'll have to correct it only once.
Thank you.
PS: It isn't important the language (Objective-C or Swift)
Create multiple targets within the same project. You can then include or exclude asset catalogues, configuration JSON files etc. on a per-target basis. If you're consistent with the names this should get you most of the way there. You can also look at target-specific build flags or constants.

How to have one core in several applications

My objective is developing several apps using the same core (code) just have different UI (color, asset's, etc.).
I don't know if I can compare to MVC but I want to reuse the Model and Controller having several Views
Important:
Can be only one project?
For example creating different target or other configuration project..
If I discover a bug I want resolve just once.
Generating separated build's.
The bundle have only the resources that I want (new target right?)
I saw several apps using this (theoretically) like sports apps (soccer, etc).
Thanks
**Edit**** More detail
I think you would like to use this : http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial
The Core can be a project, in which you're going to define the common classes. These common classes may be controllers and views. From MVC point of view, in your app these will be the Model.
I suggest you to prefer Cocoa (Touch) Framework classes.
I create many apps from a single workspace. I have created separate schemes/targets for each apps. I have separate resources/xib/plist/prefix/build files for each targets. In some places, particular target should execute a specific set of code. For this, I have added unique macros in the target'e prefix files.

Resources