Forum Xamarin.iOS

Retrieving data from Settings.bundle (iOS Settings)

Hello I'm new to xamarin iOS developping.

I want to get the data stored in the App Settings.
I Created the settings how it was shown in this Thread

I tried this code:
var ipadress = NSUserDefaults.StandardUserDefaults.StringForKey("Server_IP_Adress");

plist looks like this:
<dict> <key>AutocapitalizationType</key> <string>None</string> <key>AutocorrectionType</key> <string>No</string> <key>Server_IP_Adress</key> <string></string> <key>IsSecure</key> <false/> <key>Key</key> <string>name_preference</string> <key>KeyboardType</key> <string>NumbersAndPunctuation</string> <key>Title</key> <string>IP-Adresse</string> <key>Type</key> <string>PSTextFieldSpecifier</string> </dict>

I want the Code to retrieve or an other Value if its changed in App settings.
Can you Help me?


  • BradRobinsonBradRobinson AUMember ✭✭✭

    Hi Philipp

    You've got a couple of mistakes in your xml. The string you pass to StringForKey is the value associated with the key "Key".


    The default value should be assigned to a key "DefaultValue"


    Also, you didn't mention if the settings screen was showing up in the settings app - for that you need to make sure you've got the correct build action on the Root.plist (and that it's called Root.plist) and it's in a resource folder called "Settings.bundle".

    I've attached a test program that has all of this in-place, including how to get notified when the setting changes.

  • PhilippBartelsPhilippBartels USMember

    Thank you that work for me.

  • I realize it's been a while since this question was asked, but I downloaded the SettingBundleTest solution and the IP-Address entry doesn't even show up in the iOS settings. The SettingBundleTest settings pane is empty. I've tried this on iOS 6.1 and 7.0 simulators and an iOS 7 iPad 3.

    Any help would be greatly appreciated.

  • I'm not sure what exactly has changed since the solution was posted, but after another read of, I decided to take the part, "A Settings bundle has the name Settings.bundle and resides in the top-level directory of your app’s bundle", literally and moved the Settings.bundle folder to be out of the Resources folder and at the project root. Then it worked.

  • YellowbeardYellowbeard USMember

    So what is the officially and preferred location for the Settings.Bundle folder then?

    When doing native iOS development it is supposed to live in the top-level directory.

    Using Xamarin we can place it anywhere while making sure that the Root.plist Build Action is set to BundleResource?

    Other posts here indicate that needs to live in the top-level and Root.plist Build Action should be set to Content...

    Is both fine? Any pros/cons?

  • ricardoaoricardoao MXMember

    Hi everyone, I'm developing in Xamarin for iOS, I have a doubt:

    I want to show the configuration settings inside my app, I check the Apple documentation in

    But I cannot find how to achieve in Xamarin...

  • DaveHuntDaveHunt USMember ✭✭✭✭✭
    edited March 2014

    The documentation you linked does not discuss showing configuration settings inside your app. It describes creating a settings bundle so that your app's settings show up inside the built-in iOS Settings app. It does not involve any code (it's just plist files and localized string resources) so would have no equivalent in Xamarin.

    To show configuration settings inside your app, you simply provide a page or set of pages with your app's configuration options and provide a button or menu item somewhere to display the page(s). Your app would then write/read the users choices to/from a file.

  • XamQueryXamQuery Member ✭✭

    I am working on a cross platform app trying to do same thing with iOS. I just added a setting bundle to my Xamarin.iOS project and trying to access it in the shared project folder (PCL). I should be able to access the iOS setting using method "AppSettings.GetValueOrDefault" which accepts field key, default value and file name. But I am unable to access it. Any leads on this ?
    I am new to Xamarin World

Sign In or Register to comment.