Adding application section to settings? - iphone

How do you add a section to settings for an application, is it related to NSUserDefaults or is this something completely different? Just not sure what this is called or where to start.

It's a Bundle you add to your app called settings.
Here is the documentation: http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/UserDefaults/Preferences/Preferences.html
To add a settings.bundle, select New File.. then in the list select Resource > Settings Bundle. This will add a settings bundle to you project. Which contains some default example settings.
All settings changes made in the settings app are stored in the NSUserDefaults so you can easily access them.

Related

Creating a Lite version of an App using Targets

I would like to create a Lite version of an app, I'm not entirely sure on the process of doing so however. I duplicate the target. Then what? For instance, I changed the name of the duplicated target from AppName Copy, to AppName Lite, and also changed the name of the newly generated plist, however, in products the .app file is still incorrectly named and I can't change it. Is there some sort of official procedure that I could follow?
You need to change product name for target from Build Settings. Follow this blog

How to build a iPhone/Ipad application builder

What is the approach/methodology to build a iPhone app builder so that end users can develop apps without using code like they are doing in Mobile Roadie. How will the xcodeproj/ipa file will be generated from the website when we create our own app in websites like Mobile Roadie? Thanks in advance.
Well.. Its a Big Question -
First what you need is to crate a fully featured project that mobile roadie gives you when you select all the modules. You need to build this project keeping a settings.xml file in your resource this file should control the modules in your poject like if you want to disable a module in the app then you can disable that from this xml. You can also configure your other parts of the app using this xml like color theme and other settings like mobile roadie provide in there web interface.
Now you need to build a web interface to generate this settings.xml file. User choose modules, color theme, Images etc. and they get entered in the xml file. and finally a settings.xml file gets generated.
Third - now you have to manually download this xml file and drag in your project file and build the app.
Fourth - upload the app on appstore manually. (There is no automatic process for step 3 and 4 you have to do it manually)
Well the above approach is not very precise we your question if very very broad.

How can I modify a Settings.bundle in real time?

is there anyway to add new entries to the Settings bundle during run time?
We would like to be able to turn-off and on options depending on what information the user have entered. Seems like all Apple documentation talks about modifying preferences, but not the Setings page itself.
thanks!
The settings.bundle is read-only. You can NOT modify it during run time.
If you want to be able to change settings during run time, you have include the app settings from within the app.

Using info.plist for storing target-specific values for a multi-target app

I have a multi-target iPhone app which currently includes a header file with constant definitions that are conditionally included at build time depending on which target is being built.
However, I was wondering if it might be better to instead include this information in the info.plist for the build, as this generally holds target-specific meta, so logically seems more appropriate.
Therefore, my questions are:
Is it acceptable to include custom (non-Apple defined) keys in the info.plist file?
Is this a suitable place to include meta for the app which differ between targets?
It is acceptable and suitable.
The Info.plist file is preprocessed (must be enabled in project settings by setting Packaging / Preprocess Info.plist File to Yes) by the C pre-processor, so you can have variables (in the form of ${VARIABLE_NAME}). These variables can be defined in the User Defined section in Xcode's target info, making it very easy to switch their value from one target to another.

Setting a boolean property in Info.plist from a User Defined Setting

It's simple to set a property in an Info.plist file from a user defined setting, you just use ${YOUR_SETTING_NAME} as the value. However, is it possible to do this for a bolean property? The structure in the plist file for a boolean is:
<key>NSAppleScriptEnabled</key>
<false/>
It's not clear how to use a user defined setting here.
I'm not sure how to do what you're asking, but I'm pretty sure that for this particular key (NSAppleScriptEnabled) you can also use strings "YES" and "NO" and it will work.
plist files containing booleans within tags are not valid any more.
This solution works:
Add a new Run Script Build Phase to your target. Put in this:
if [ ${CONFIGURATION} = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :UIFileSharingEnabled NO" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi
So in my configuration, I'm setting the UIFileSharingEnabled to YES in my plist as a default and when I'm building for Release, then the step above happens and sets it to false.
What do you mean by "User Defined Setting" ...
If the user you are talking about is you (in other words, the app's developer), then you can just put whatever keys you want there, just like any other plist in your Xcode project.
If the user you are talking about is your app's end user, don't try to save their settings in your Info.plist. It is a part of the application. While it is sometimes possible for an app to change its own info plist on a mac, it often is not, depending on how the app was installed. On the iPhone it is never possible, since the app is read-only. In either event, changing your Info.plist would invalidate any app signing you have done.
If you want to change end user settings, use something NSUserDefaults.