Set read only a .plist file item - ios

I have a plist file used to store informations as parameters of my application.
It can be configurable by Settings on device and I can set items value programmatically.
Everything working well, but I would like to set items Enable\Disable based on condition.
For example, for some reason I would like to put my item used to store a text information disabled, so the user on device can't edit this parameter on Settings device. Is it possible?
<?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>DefaultValue</key>
<string></string>
<key>Key</key>
<string>USERNAME</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>User</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
</plist>

If you want that kind of flexibility, provide a settings interface within your app rather than relying on the Settings app.

Related

How to modify info.plist?

So i need to disable ATS in my xcode project by typing
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
in my info.plist. However my info.plist file contains only
<?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>LastAccessedDate</key>
<date>2022-11-06T09:15:11Z</date>
<key>WorkspacePath</key>
<string>/Users/markmarus/Desktop/name/name.xcodeproj</string>
</dict>
</plist>
There also is a scm.plist which contains
<?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>Version</key>
<integer>5</integer>
</dict>
</plist>
After adding ATS settings and starting simulator up the info.plist file just deletes added lines so it changes nothing.
The Info.plist generated by Xcode starts with a uppercase letter and contains much more information than your obviously self-generated one.
If you want to modify the Xcode Info.plist do it the GUI in the Info tab of the target. After adding a custom key-value pair it appears also in the project navigator and you can open it as Source Code to modify the property list text directly.

How to turn off the OneDrive tutorial using a plist

I want to turn the tutorial off and set the default folder, so I'm not asked when the machine boots.
I have created a plist based on the instruction (https://learn.microsoft.com/en-us/onedrive/deploy-and-configure-on-macos), and when I log into OneDrive via the app, nothing changed. I'm still asked for the drive location, and the tutorial still runs.
Plist File: com.microsoft.OneDrive.plist
Location: /Users/syacko/Library/Preferences
<?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>DefaultFolder</key>
<dict>
<key>Path</key>
<string>/Users/syacko</string>
<key>TenantId</key>
<string>ee19ff16-4eb9-4f7e-acdb-XXXXXXXXX</string>
</dict>
<key>DisableTutorial</key>
<true/>
</dict>
</plist>

Change the title string of a setting defined via iOS settings bundle at run time?

I'm working on an iPad application that allows users to log in using Touch ID. Also I've included a preference called "Touch ID" in application settings bundle where users can switch on/off that option to enable or disable Touch ID authentication.
The following plist file is what I used to set up the settings bundle.
<?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>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Touch ID</string>
<key>Key</key>
<string>settingsTouchID</string>
<key>DefaultValue</key>
<false/>
</dict>
</array>
</dict>
</plist>
The following image is the screenshot of the application settings screen.
However, certain iPads feature "Face ID" instead of "Touch ID," and I'd like to provide the option name (title field in the Plist file) for setting bundle to "Face ID" instead of "Touch ID" for those devices.
Could someone kindly inform me if dynamic titles for the application settings options are possible? 
Note: I have got some alternative solutions like, creating a settings screen within my app itself, renaming the setting name to a generic one, etc.
there is no way to edit plist files at run time

iOS setting bundle not editable

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>

MonoTouch: Settings.bundle file issue

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.

Resources