Creating a static library + UI from existing source - iphone

Ladies and gents,
I'm having a brain-itching issue with something I deem rather simple.
The case is as follows:
We created a native iOS app, and we want to create some customised versions of the app using the same source and resources. The project is rather large though, so creating multiple targets and linking against almost a 100 files would be overkill in my opinion. So I figured that it would probably be the best idea to create these customised versions of this app using a statically linked library of the original source. So I created multiple types of statically linked libraries using the many solutions our fellow developers provide on the internet. I've come across Jeff Verkoeyen's tutorial and the iOS Universal Framework, both providing me with an excellently built framework including my UIStoryboard files.
There's only one problem, after including the framework and finding the UIStoryboard files I've managed to get everything running. But after running the application the app instantly crashes notifying me that it couldn't find the custom classes I've used in the UIStoryboard to make the app work.
For instance, I've made subclasses for UIViewController (of which all my other ViewControllers inherit), so I could use my code more optimal. The actual subview (BaseViewController) is not to be found by the UIStoryboard. I'll have to note that the actual class files (.h and .m) are inside the framework I've created using any of the above methods.
So, what am I to do now. I really need a solution for either this problem or a hint to another solution that would be fitting for my current problem, which is; I want to create customised versions of apps using a single code base.
Thanks in advance!
Bryan

Related

Creating framework in IOS that contains controllers

If I create a IOS framework that will be shared between projects, can it contain things like ViewControllers? The project will only contain resources related to that project.
Are there other frameworks that contain view controllers? I would say certainly so.
The bigger question would be "can it contain the resources I want to use with those view controllers?"
It is possible, but it is a pain in the neck. Here is some reference on how to do so.
Also the FaceBook developer kit is a good example of how to do it.
Yes, your framework can have view controllers.

How to link a ViewController in Xamarin MonoTouch

I'm currently trialing MonoTouch and am impressed with it's capabilities thus far.
I'm wanting to create a library of iPhone apps that each will have the same User Logon screen. Therefore, I want to create the LogonScreen ViewController once and then share it amongst my projects.
I tried adding the files as a 'link' like you do with files in Visual studio but that seemed to create a disjoint between the Login.cs and the Login.designer.cs ie the Login.Designer.cs does not appear underneath the Login.cs in the Solution explorer.
The Login.cs has also lost the reference to the txtUsername textbox control I have in my xib.
Any ideas on how to solve this problem?
If I'm understanding your problem correctly this will get you on track: Dimitris Tavlikos Answer
This will produce a custom class which you can abstract into a common library for your applications.
-Nick
Would advise you to add your shared views in a separated project (iOS Library Project) and add this project as a reference.
You won't have the problems of linking separate files in each future project, which would get more and more complicated when you will have more shared views.
The reason why you lost the reference to your textfield is because it 'lost' the designer.cs file, which has these references.

Two very similar apps, with different texts and UI graphics

I'm going to developer two very similar apps, the logic is absolutely the same, but api calls base URLs, texts and UI graphics( such as backgrounds etc) will be different, but the all views will be the same (buttons, labels in the same places). It's quizes apps.
How to do it in the smart way? To not duplicate code etc.
I thought about to setup workspace, add bundles with UI, plists with texts and URL's, and than based on project name or identifier use one of the bundles, etc.
Maybe somebody can share smth else? More efficient way.
Thx.
I thought about [...] adding bundles with UI, plists texts and URL's
You wrote your own answer. Additionally you setup two targets. One for each project. Within the target you define an envorinment variable, which you can use in your code to switch between the bundles / URLs.
You should write a Helper Class to get the Ressources. That helper class checks the environment variable and gives back the correct ressource.
(You may want to write categories for UIImage and NSURL and write your own NSLocalizedString version. With that you don't need to check any conditions/settings anywhere else in your code.)

How do You structure an iPhone Xcode project?

What are good ways of building groups/folders?
I've tried by feature (UI for a feature plus model etc) with a common group. I've also tried by UI, model, etc.
The former keeps like things together which fits the iPhone paradigm nicely. The latter means I jump around a bit more.
What do you think?
The standard Xcode MVC folder structure is as follows.
CoreData : Contains DataModel and Entity Classes.
Extension : Contain One class(default apple class extensions+project class extensions.)
Helper: Contain Third Party classes/Frameworks (eg. SWRevealController) + Bridging classes (eg. Obj C class in Swift based project)
Model : Make a singleton class (eg.AppModel - NSArray,NSDictionary, String etc.) for saving data. The Web Service Response parsing and storing data is also done here.
Services : Contain Web Service processes (eg. Login Verification, HTTP Request/Response)
View : Contain storyboard, LaunchScreen.XIB and View Classes. Make a sub folder Cells - contain UITableViewCell, UICollectionViewCell etc.
Controller: Contain Logic or Code related to UIElements (eg. UIButton’s reference+ clicked action)
It's going to be very project dependent. In my last project I had mostly views, and so I organized the views by view-type.
Organizing code by type
Organizing code by type is ok for small projects but it's not a good practice for big ones.
Just imagine you have tons of files and folders organized by type, and when you work on a single feature, you have to open all of the folders. Which can confuse you and you can get lost many times while you scroll through files.
It looks something like on A.G's & Julian B.'s answers.
Organizing code by feature (intent)
Organizing code by feature (intent) is the best practice for big projects and big teams.
Cause usually teams work on a single feature, and they focus only on a single folder or group of files. They don't necessarily have to know about other features and files.
It looks something like this:
AppDelegate
Features
Feature 1
View Controllers
Models
Views
Logic
Feature 2
View Controllers
Models
Views
Logic
Networking
Models
Logic
Extensions
Resources
Also, to mention, this practice and technique (organizing project by feature) are implemented by the greatest companies around the world.

Common, reusable iPhone-App configuration screen

I'm writing code that will allow my iphone-app to have a "configuration page".
A grouped, scrolling, UITableView... with cells that contain the needed textFields, switches, sliders, etc.
It is an ENOURMOUS amount of code. Is there an easier way?
Is there a way I could create a simple text-file, contain all my desired design choices and have my (reusable) code build the TableView for me?
Or... can I just do the whole thing quicker/easier in Interface Builder instead of code?
Basically there are two approaches here :
you rely on what Apple gives you and implement a Bundle Settings (basically a dictionary that describes how the settings screen should look like), and then , your settings will be in the "Settings" application of the iPhone.
The drawback here is that what apple provides is quite limited and you won't be able to implement some of the most complicated settings you can see in "standard" (pre-installed) apple application settings.
That's why many developers are switching to "inapp" settings thanks to open source FWK or they reimplement everythingh from scratch but it can be a lot of code as you said.
You reimplement your own UIViewController for settings or you rely on some framework that will provide you the UIViewController to extend from and ease your implementation.
There are 2 good frameworks for that (Jesse cited one of them, but there's another one )
InAppSettings ( http://inscopeapps.com/blog/inappsettings-10/ )
InAppSettingsKit ( http://inappsettingskit.com/ )
A comparison of the two framework can be found here : http://inscopeapps.com/blog/inappsettings-vs-inappsettingskit/
(ok that's from one of the two authors but at least this gives an idea ;)
If you can live with the limitations of the standard application preferences in iPhone, you can actually create this using a settings bundle which only needs a plist and optionally a localized strings file.
You can check out Apple documentations for this:
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationSettings/ApplicationSettings.html
Claus
If you're looking for a ready made and reusable solution, you can check
http://www.inappsettingskit.com/
It's open source too, so it's useful as a base.
I never found an easy and efficient way to build complicated table view by using Interface Builder, so I think programming the settings view is more preferable.
If you're talking about using a text file or plist, you may want to mimic the Settings Bundle design of Settings app.
Load the plist data upon the app launch.
I've built something like what you're looking for. Going off Claus's answer as well, it basically just duplicates the interface of the Settings application using the same settings.plist file as the settings app. The only difference is that it's a view controller that you can put inside the app. There's a surprisingly small amount of coding involved, it was just a lot of looking at the settings app to see exactly how things were laid out.