If application has been reinstalled through xcode all kept settings are cleaned. How to avoid such behaviour?
More detailed: An app has been installed, then I made changes in settings ( settings bundle) and they were stored. After I reinstalled the application through xcode (I didn't remove the app) and all my settings have been cleaned that I made before . I would like to keep my settings after installing application or perhaps there is another way to keep settings of app after installing of it.
Example:
I created Settings Bundle ( File -> New -> File -> Resourses -> Settings bundle)
Changed Root.plist and added there new dict for address value. See below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Server</string>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Address</string>
<key>Key</key>
<string>server_address_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>IsSecure</key>
<false/>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
</dict>
</array>
To keep the settings of your app use UserDefaults, it's the same concept as SharedPreferences in Android development. So, you can store there user related settings as well as everything else which should remain untouched after updating (Xcode reinstallation) of the app.
UserDefaults Apple doc
Example of usage.
Setting value:
UserDefaults.standard.set(true, forKey: "someValue")
Retrieving value:
let boolValue = UserDefaults.standard.bool(forKey: "someValue")
Related
I've got an Alloy app and I'm trying to put some configuration into the Settings app in iOS.
I've added the Root.plist file here:
/app/platform/iphone/Settings.Bundle
The file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Service</string>
</dict>
<dict>
<key>DefaultValue</key>
<string></string>
<key>Key</key>
<string>username</string>
<key>Title</key>
<string>Email address</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
</array>
But nothing appears in the settings app for me. Any suggestions?
There used to be an iOS bug in the simulator where if your app was running, even in background, when a new version was installed, the settings were not updated until you completed closed the app and relaunched it. Closing the simulator with the app running did NOT resolve the issue. TBH, I have not tested this lately, I am just in the habit of closing my app before I rebuild. Try completely closing your app, then relaunching it and see if the settings update.
Is there a way to create an option in Bundle settings of iOS 7+ in such a way that it's only readable for a user. The user shouldn't be able to edit this within the option menu.
During the first use of the application I will set the above property and unique value.
Writing down the unique id in a database is not a option. The user should see this value in the settings menu of the app, provided by iOS.
Using the IMEI is not a option since the value is undergoing some kind of validation mechanism in the app itself.
You can use a PSTitleValueSpecifier for this. It will display a value that is readonly. Below is an example Root.plist file that shows a user Account Number in the App Settings. When the application start up, you can programmatically update the value and it will show up as read-only on the App Settings page.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier </string>
<key>Title</key>
<string>Account Number</string>
<key>Key</key>
<string>account_number_preference</string>
<key>DefaultValue</key>
<string>012-345-6789</string>
</dict>
</array>
</dict>
</plist>
I have built the application in Xcode 6.1. It is not downloading in ios 8, showing the error LoadExternalDownloadManifestOperation: Ignore manifest download, already have bundleID: com....... I have tried many solutions:
Postfixing some character in the bundle-id of the plist.
Downloaded the provisioning profile again.
List item
Changed the plist by adding display-image and full-size-image tags.
When I implement these solutions, first 2-3 times it's getting downloaded, but after sometime it's failing.
I guess this can be an issue of plist.
I would like to know how to create a plist from Xcode 6.1?
Got a plist from .xarchive in XCode 6.1(shown below) but not working.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList- 1.0.dtd">
<plist version="1.0">
<dict>
<key>ApplicationProperties</key>enter code here
<dict>
<key>ApplicationPath</key>
<string>https://....../App.ipa</string>
<key>CFBundleIdentifier</key>
<string>com.abc.xyz.efg</string>
<key>CFBundleShortVersionString</key>
<string>1.0.40</string>
<key>CFBundleVersion</key>
<string>1.0.40</string>
<key>IconPaths</key>
<array>
<string>https://....../icon-76.png</string>
<string>https://....../icon-60.png</string>
</array>
<key>SigningIdentity</key>
<string>Company Limited</string>
</dict>
<key>ArchiveVersion</key>
<integer>2</integer>
<key>CreationDate</key>
<date>2014-12-11T06:46:25Z</date>
<key>Name</key>
<string>App</string>
<key>SchemeName</key>
<string>App</string>
</dict>
</plist>
I'm trying to upload an app to a website that expects a .plist along with the app's ipa.
The screenshot below is from the website.
I noticed that xCode6 has removed the checkbox to save for enterprise distribution from both the "ad hoc" and "enterprise" distribution option. I'm signing the app with a profile from a 299$/year enterprise program. Still I get no plist. How can I distribute an app using xCode6 to get the enterprise plist option?
Here's what I expect and saw in xCode5(there's no such checkbox in xCode6)
This isn't using Xcode, but as a fallback you can just manually/programmatically edit the plist file. I do this because my continuous integration server distributes the builds, so I can't use Xcode's GUI to make the plist file.
Here's what an Enterprise distribution .plist looks like (copied from this gist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>http://dl.dropbox.com/u/1001/myawesomeapp.ipa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.company.application</string>
<key>bundle-version</key>
<string>0.0.16</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>My Awesome App</string>
</dict>
</dict>
</array>
</dict>
</plist>
I've been trying to setup settings for my app but I can't seem to get this working even though I've looked over it over and over again and compared it to an example in a book and the example on Craig Dunn's blog.
I understand that the syntax has to be perfect and this file is pretty simple at the moment I am just trying to display one textfield for now. I did get this working briefly on a brand new project however I haven't managed to get it to work since.
Here is the XML of my Root.plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Root</key>
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Title</key>
<string>Group Name</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>Key</key>
<string>usernameTextField</string>
<key>Title</key>
<string>Username</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
</array>
</dict>
</dict>
</plist>
As I said I've looked over it quite a lot of times and I can't see any problems with it. The file build action is set to Content and the Copy to Output Directory is set to Always Copy. The version of MonoTouch that I'm using is 6.0.7.
I'd appreciate any help with this issue. Thanks
Make sure that the Settings.bundle directory is included at the top level of the project. By top-level, I mean that on the file system, the Settings.bundle directory should be in the same directory as your ProjectName.csproj file. In MonoDevelop, it will appear as one of the top-level folders under the project node.
Set the Root.plist Build Action to BundleResource (do not enable "Copy to Output Directory". Hint: if you find yourself setting "Copy to Output Directory", don't do it - it's almost always the wrong thing to do - we've actually discussed removing the option altogether.)
Now, for the plist file format - here's what it should look like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Group Name</string>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Username</string>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>usernameTextField</string>
<key>DefaultValue</key>
<string></string>
</dict>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
Looking at your Root.plist file, it appears that the PreferenceSpecifiers key is not in the top-level dict node (it needs to be). In other words:
get rid of the following lines at the top of the file:
<dict>
<key>Root</key>
...and one of the following lines at the end of your file:
</dict>
That should do it...
Now... all that said, I just recently figured this out myself while trying to add settings to my personal side project and decided that we, at Xamarin, need to make this easier. I've already fixed a few minor issues in the upcoming MonoDevelop 3.1, but I hope to get the time I need to add templates for Settings.bundle to MonoDevelop's "Add New File" wizard. I'd also like to add plist key/value hinting like we do for Info.plist and Entitlements.plist so that MonoDevelop's plist editor can better guide you when editing these plist files.
For starters, you are missing your closing plist </plist> tag. My current one only has one setting in it, but it works. You can compare to yours to see the differences:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Stay Signed-In</string>
<key>Key</key>
<string>staySignedIn</string>
<key>DefaultValue</key>
<true/>
</dict>
</array>
</dict>
</plist>
I hope this helps.