Making multiple versions of an iPhone application - iphone

I made an iPhone application, and now I would like to make multiple more versions of the same application with very slightly different functionality.
I was wondering if anyone knew what the best way was to go about duplicating a project with as little decoupling (I think that's the right term) as possible.
Maybe someone out there who has made a LITE version of their iPhone application? How they went about doing it and what lessons they learned from it?

Shoot, I'm sorry. Didn't find this when I was searching earlier, but looks like a lot of what I am looking for has already been answered here: How do I manage building a Lite vs Paid version of an iPhone app?

One low budget, low overhead approach that I've used that will keep things simple is as follows:
/******************************************
* Set to 'FREE_APP' or 'PAID_APP'
******************************************/
#define PAID_APP
Within your application, you then write code simimar to the following:
#ifdef PAID_APP
#interface myViewController : UITableViewController
#else
#interface myViewController : UITableViewController <CustomTableAppDelegate>
#endif
This is by no means the best all around approach as you still have update the info.plist file to set the executable name and bundle identifier. However, in a pinch, it works well to maintain one code base/project.

Here's another link
I've used this approach and it works pretty well.

Related

2 Simple questions related to xCode and Swift for someone new to Coding

Being new to coding I have a few newbie questions I'm hoping someone could confirm for me.
in xCode is the Playground just for testing code. Whatever I decide to actually be used needs to be copied to somewhere else to actually use it?
ViewController.swift - How do I decide what should go here or when to make a new "file"?
Yes, playgrounds are for playing with code and experimenting and getting immediate feedback without the usual build and run cycle. However, coding in them is slightly different to normal app programming. One thing you'll notice is that everything is top down, so you have to declare something above where it is used first, which you don't have to do in normal swift apps.
What you should put in ViewController.swift... such a broad question. You might be better off reading an iOS programming beginners book or guide, than asking that here. You should become familiar with MVC for what you put in a view controller. Potentially, you could put everything in ViewController.swift if you desired - but it wouldn't be very nice to work with. The only thing I would put in ViewController.swift, is the code for the ViewController class. I'd create a new file per class I create, new file for a protocol (most of the time), new file for defining constants usually. It's up to you, but at least a new file per class.

Outlets are null in ViewDidLoad with mvvmcross

In my view.designer.cs my outlets are generated by xcode.
When starting debug I have a null reference exception on my properties when adding bindings, in the code bellow this.SampleText is null.
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.AddBindings(
new Dictionary<object, string>()
{
{ this.SampleText, "{'Text':{'Path':'VMText'}}"}
});
}
I noticed the following error in Application's output :
"Application windows are expected to have a root view controller at the end of application launch"
what did I miss ?
It sounds like you might have a more general problem with your iOS setup - possibly some issues with the XIB file synchronisation between xcode and MonoTouch.
Before you try to add the MvvmCross binding take a look at the MonoTouch layer - if this.SampleText is null in the MonoTouch layer then you need to solve that before you can add the MvvmCross binding code.
The MonoTouch soft debugger is an excellent tool to help debug this - and the debug cycle with the simulator is pretty quick - so this often helps solve these problems.
From your partial answer to this question, it does sounds like you were trying to use a XIB in a Dialog based UI - that's probably not going to work - I think MonoTouch.Dialog is always based on a single Table - so it's not expecting a XIB (at least, that's my experience!)
As for "Application windows are expected to have a root view controller at the end of application launch" that sounds more like a general problem in your AppDelegate.cs perhaps. Alternatively it might be a problem in the presenter. Which presenter are you using?
That error message itself has a lot of hits on StackOverflow - e.g. Applications are expected to have a root view controller at the end of application launch - but I'm not sure which of these is appropriate to your case right now.
I must admit everything is not clear for me with iOS and MVVMCross
For coders coming from a C# background I don't think this is unusual - I think the jump from VS on Windows to MonoDevelop on Mac (with a little xcode) is a non-trivial leap. It takes more time to switch from WP to iOS development than it does from WP to Droid - this is the case independent of whether you use MvvmCross - if you are doing MT development you are doing native code, so you do have to take some time to understand iOS a bit (in my experience/opinion!).
For the most part, I've personally written tens of thousands of lines of code, authored hundreds of blog posts and stackoverflow answers, and presented maybe ten sessions on mvvmcross. I've done this across five distinct operating systems, four of which I've learnt as I've coded and all of which I've battled against platform and tooling bugs and idiosyncrasies.
I'll continue to post as much as I can - and continue to operate for 'free'
I do also encourage every user to post and blog about their experience too. In this way I hope knowledge will be generated and shared. To anyone who is reading this, using mvvmcross and learning something about cross platform coding - good or bad - then please do consider sharing that knowledge. For inspiration, check out some of the presentations and blog posts users have written - I try to list them on http://slodge.blogspot.co.uk/p/mvvmcross-quicklist.html. Thanks :)
Also, when asking questions, please can you indicate which version of mvvmcross you are using and which sample(s) you're basing your code on - there are differences between master and vNext and there have been fixes over time - so posting this info will help me try to understand and/or replicate the errors you are seeing.
Thanks :)
I know this is a little old, but I was just having the same issue.
My outlet properties in my View.designer.cs file were null when I attempted to access them when ViewDidLoad was called.
Turned out that my xib file in Visual Studio was no longer set to a Build Action of InterfaceDefinition.
Hopefully, this helps someone else who stumbles upon this issue.

Storing app parameters like secret key

I'm working on a little SDK which has a configFile.plist file to store things like secret key.
Developer who implement this SDK in his app, and other users will download the app, they will be able to go into the app binary and change anything in the .plist file.
Is there any way to store this info without letting users modifing the parameters easily? I don't want users to have the ability to change the parametes in the .plist file.
Thanks in advance for any help!
When it comes to plist storage, it's easily accessible either way. Your best option is to provide a class file for configuration, and not a plist. Example below..
//Config.h
#define SHARED_SECRET #"2390849028349829384"
#define SOME_OTHER_VALUE 1
..and so on, this way, the class file is compiled with the App, and not visible to the user but accessible by the developer. Once you #import "Config.h", you can use SHARED_SECRET and SOME_OTHER_VALUE in place of the value itself within the code. If this suffices as a solution to your question, mark it as the answer. Hope it helps..
Keeping in mind that people are going to be able to see/change almost anything with the right tools, you can't prevent people from hacking this.
If the key is going to be different for each user of the SDK, then you might want to make it the Developer's responsibility and have them provide the private key to you using a delegate method. That will make it their problem, and it will make it easier for them to compile the key directly into code, which is going to be less obvious for the end-user to access.

make the language of my IPHONE app change from the app settings without changing the language of the device

I want to make the language changeable from the application settings. For that I made a settings.bundle and i forced the langauge using this code How to force NSLocalizedString to use a specific language , I also put the UIApplicationExitsOnSuspend to YES to make my app reload every time it goes to the background.
It partially worked for me but I have 2 problems :
- The splash screen (which is localized) is not changing with this method.
- I must enter/goBack twice to make the language change effective on the application Views an this only on the OS 4 and higher.
Has anyone a solution for that?
You need to create you own translation framework for that ! Sorry !
Unfortunately there's no built-in way. What would be probably easiest would be integrate service like GetLocalization.com, so that your app would download language file via API (then it's easy to add new languages and translations even app is already released). Then what you need is just simple loader that loads that language file to memory and function that replaces the original string with translated one in run-time. You can calculate hash for original string so it's fast to search them, good algorithm for this is Peter Weinberger's hashPJW.
The trick to use specific language by selecting it from the app is to force the NSLocalizedString to use specific bundle depending on the selected language ,
here is the post i have written for this http://learning-ios.blogspot.com/2011/04/advance-localization-in-ios-apps.html
and here is the code of one sample app https://github.com/object2dot0/Advance-Localization-in-ios-apps

Loading a private frameworks in MacRuby

I'm attempting to follow this tutorial 'Demystifying Mail.app Plugins on Leopard' to build a Mail.app plugin. Instead of using PyObjC I'm trying to use MacRuby. I've got MacRuby 0.6 loaded up and I've gotten to this step in the tutorial (PyObjC code):
MVMailBundle = objc.lookUpClass('MVMailBundle')
I've search the web a bit but can't seem to find any information about loading the private framework 'MVMailBundle' in MacRuby. Any ideas?
Thanks in advance - AYAL
I think the idea is that this plugin will be loaded into Mail.app, which will already have loaded the private framework in question. So we just want to look up a class at runtime (which is what that Python snippet is doing — not loading a framework). The way to do this in MacRuby is MVMailBundle = NSClassFromString 'MVMailBundle'.
(You will need to include framework 'Cocoa' in order to get the NSClassFromString method, but I assume you'll have already done this.)
MacRuby uses garbage collection and Mail doesn't. You can't load a GC bundle into a non-GC app. So this is a dead-end.