I have been trying to create the Xcode File Template that contains boiler plate files and code structure for MVVM design pattern.
I created a module successfully with custom template using the plist configuration and file structure as 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>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>MVVM Module Template.</string>
<key>Summary</key>
<string>MVVM Module Template</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Module Name:</string>
<key>Description</key>
<string>The module name.</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>Base</string>
</dict>
<dict>
<key>Identifier</key>
<string>View</string>
<key>Name</key>
<string>Also create View file for user interface</string>
<key>Description</key>
<string>Create a view file with the same name</string>
<key>Type</key>
<string>checkbox</string>
<key>NotPersisted</key>
<true/>
</dict>
</array>
</dict>
</plist>
Folder Structure For the Custom Template
The problem was that, when I checked the checkbox, all the files in the View folder was created, but when checkbox is not checked, non of the files are created.
What shall I do to achieve following cases:
Generate source files from the folder 'Source' when checkbox is unchecked.
Generate source files from the folder 'View' when checkbox is checked.
You're doing it right for when the checkbox is checked, but you need to change the "Source" to "default" for when the checkbox is unchecked.
Related
In Xcode 9, when you create a group it creates a linked folder in the file system, too. So you don't need to create folder for each group manually. A good explanation about the group and folder related changes in Xcode 9, see this.
I have a custom Xcode project template which generates a project and adds loads of Swift boilerplate source files in custom folders. My problem is that I can only create group folders like this: , which represents a Group not associated with a file system directory. It's not good because if you later rename a folder in Xcode, it will have no effect on the corresponding file system directory.
My goal is to write an Xcode project template that adds my custom boilerplate swift files in real reference folders like this: .
You can download my simplified template from here, place it under: ~/Library/Developer/Xcode/Templates
Then Xcode > File > New > Project, and select Custom-Template.
TemplateInfo.plist:
<?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>Kind</key>
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string>
<key>Concrete</key>
<true/>
<key>Identifier</key>
<string>custom-swift.xcodeTemplate</string>
<key>Description</key>
<string>Swift starter project for iOS projects</string>
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.cocoaTouchFramework</string>
</array>
<key>Nodes</key>
<array>
<string>Classes/Interfaces/CustomInterface.swift</string>
</array>
<key>Definitions</key>
<dict>
<key>Classes/Interfaces/CustomInterface.swift</key>
<dict>
<key>Group</key>
<array>
<string>Classes</string>
<string>Interfaces</string>
</array>
<key>Path</key>
<string>Classes/Interfaces/CustomInterface.swift</string>
</dict>
</dict>
</dict>
</plist>
It creates a project like this:
What I'd like to achieve:
Any help is much appreciated! :)
Update 1:
I found a small workaround.. Create your own complex folder hierarchy with the template script then simply delete the root folder - in my case "Classes". Then open the Trash and drag it back to Xcode, select "Copy items if needed" and select "Create groups". It will build the folder structure with real reference folders.
Here is what you need to do.
In the node section specify the group before naming the file.
<key>Nodes</key>
<array>
<string>MyGroup/File.swift:comments</string>
<array>
Next in the definitions provide the group name in the key like so:
<key>Definitions</key>
<dict>
<key>MyGroup/File.swift</key>
<dict>
<key>Path</key>
<string>File.swift</string>
<key>Group</key>
<string>MyGroup</string>
</dict>
Hopefully this will help.
For That purpose one can use Components as used in imessages template
Example of component is
<key>Components</key>
<array>
<dict>
<key>Identifier</key>
<string>com.apple.dt.unit.messagesextensioncomponentios</string>
<key>Name</key>
<string>___PACKAGENAME___ MessagesExtension</string>
<key>ProductBuildPhaseInjections</key>
<array>
<dict>
<key>TargetIdentifier</key>
<string>com.apple.dt.messagesOnlyApp</string>
</dict>
</array>
</dict>
</array>
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.
I am trying to add the App Transport Security keys to my Info.plist as described in the following Apple tech note https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/#//apple_ref/doc/uid/TP40016240-CH1-SW3 (Exclusions section)
When I edit the Info.plist file, I did the following:
Click on the '+' next to 'Information Property List' to create a new top level key
Clicked the dropdown to select "NSAppTransportSecurity'
However Xcode doesn't list the option in the drop down list (screenshot below).
Do I need to open the Info.plist file in a text editor and edit this manually?! Or am I missing some (probably obvious!) step?
I'm using Xcode 7.0.1
Thanks
Xcode 7.1 lists the option in the dropdown (App Transport Security Settings). In earlier versions you need to type the raw key NSAppTransportSecurity and set the type to dictionary.
Simply it is not already present in Xcode 7.0
You can use anyway Xcode but I suggest you to open the plist file with a text editor and add this to allow all connections to all domains:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- .......................... -->
<!-- Other keys already present -->
<!-- .......................... -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
To add specific exceptions to a list of domains add this instead:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- .......................... -->
<!-- Other keys already present -->
<!-- .......................... -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>domain.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
NSIncludesSubdomains is not necessary but permits to access subdomains like wiki.domain.com, blog.domain.com etc.
For a detailed tutorial have a look at this blog post
I uploaded a plist file but when I go to that link to get the ipa, the plist file is only displaying the text, and not doing anything else. Something is going wrong here and I don't understand what.
<!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://rentaid.info/clarktest/Clarktest2.ipa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.rentaid.testapp</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>Clarktest2</string>
</dict>
</dict>
</array>
</dict>
</plist>
you cannot just open the manifest file via standard HTTP scheme becasue nothing useful will happpen. you need to create a link to your manifest file with a special scheme, and that link can work on the device only.
the link with the custom sceme should look like this:
itms-services://?action=download-manifest&url=https://rentaid.info/clarktest/manifest.plist
IMPORTANT: make sure your server has proper SSL certificate, because on iOS7 or above the device won't download the IPA file, if the hosting server has no SLL certificate.
Just uploading the plist file and try to open up willn't help you to get the app. you should hyperlink like this
<a href="itms-services://?action=download-manifest&url=http://example.com/Application.plist">
Install This App
</a>
Check this out tutorial 1
Check this out tutorial 2
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.