So basically I have this application made from AppleScript. Now I'd like to customise some information (e.g. bundle identifier, version number, etc.) However, it seems as if even the slightest changes to the info.plist will cause the script to… not work.
Any idea how to change the info.plist of the AppleScript application without breaking it?
There are only three requirements for editing a plist file:
Don't change anything on the first four lines. They should always 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>
Don't use anything except plain-text characters (no curly quotes, rich text, strange characters, etc). I recommend using the free version of BBEdit, which will keep things nice.
Don't break the hierarchical key-value structure. Plist entries have the form:
<key>KeyWord</key>
<value-type>whatever data</value-type>
where the value-type can be 'string', 'real', 'integer', 'date', 'data', 'array', 'dict', of one of the booleans 'true' or 'false'. It's standard XML style, with opening and closing tags (distinguished by a slash) and singleton tags for true and false (where the slash is at the end of the word rather than the beginning). Dictionaries can have key-value pairs within them, arrays have lists of values without keys, you can nest as deeply as you like, but you must always open and close tags in the proper order.
Common errors are:
accidentally deleting an opening or closing angle-bracket
overlapping opening and closing tags for nested elements (e.g., open tag for a dict, open tag for an array, close tag for the dict, close tag for the array)
separating keys from their values (value elements must come immediately after key elements
An additional concern in modern days is that applets are now codesigned by default. This means if you modify any part of the applet (including Info.plist) outside of Script Editor, after creating it, it will now have an invalid code-signature.
For some purposes, that won't matter, or be noticeable — but, especially if you control "System Events" or use accessibility features, you'll get obscure, confusing failures until you fix this.
Luckily, it's easy enough to re-sign the application-bundle after you've modified the Info.plist — simply run the following in the Terminal:
codesign -fs - --preserve-metadata=entitlements /Applications/YourApplet.app
The -f overwrites the existing (now incorrect) code-signature; the -s - allows it to be an ad-hoc signature (same as what was already present); and the --preserve-metadata=entitlements is the important part that maintains the Script Editor configuration of your script's permissions.
Related
I have an issue, I wouldn't say it's a problem at the moment, but I can see how it could turn into one in the future.
I'm following some tutorials from Ruby, so I have a folder with a bunch of different files. In one of them, I was studying Hashes, and they showed that I could name its keys like :key. No problem so far.
The issue came when I was studying Classes and I had to declare the class attributes, IntelliSense (I guess, maybe it is another extension) would recommend code completion with the keys I declared in that Hashes ruby file.
So I tested some stuff and:
It wasn't unique to that file (of course).
It's not just in hashes, it will recommend any type of :attribute I create. Whether it is classes or hashes (which is what I have tried so far), it doesn't matter.
It isn't unique to that folder. If I have the files in different folders, with different depths let's say, it will still appear.
The only way I found to get rid of that was to erase the file, and that's no solution at all.
I guess my precise question is: How can I disable that code completion characteristic?
You can ignore file or folder in code completion by adding it to files.watcherExclude setting.
Files must be closed in editor: if ignored file is open, it will still be used for autocomplete.
I want to be able to open a file with my application from finder
click on the file and and select open with then select my application.
I am not using NSDocumentController and I have put this in my applicationdelegate
-(BOOL) application:(NSApplication *)sender openFile:(NSString *)filename;
as I am more or less guessing my way through this can any one tell me if I am on the right track
also is there something I need to do in order to tell the os what king of files I can except
Regards Christian
You have to register with the file types your program is associated with , you can do this by adding "LSItemContentTypes" key to your plist and specifying the file types.
Something similar to described in this post.
How do I associate file types with an iPhone application?
When a user opens the file the delegate method will get called .
-(BOOL) application:(NSApplication *)sender openFile:(NSString *)filename;
File name parameter will be with the path , then you can work with the file using that.
You also need to specify Launch Services keys in Your Info.plist file.
from: Launch Services Programming
The CFBundleTypeName key specifies the document type’s kind string, a user-visible description used to characterize documents of this type on the screen (such as in the Finder’s Get Info window or in the Kind column of the Finder’s list view). This key can be localized by including it in the InfoPlist.strings file of the appropriate .lproj subdirectory. CFBundleTypeIconFile identifies the file containing the icon image to be used for displaying documents of this type on the screen. LSTypeIsPackage specifies whether the document is a packaged bundle (true) or a single file (false).
Files belonging to a given document type may be characterized by their file types, filename extensions, or MIME types. The CFBundleTypeOSTypes key in the type-definition dictionary specifies an array of four-character file type codes that characterize documents of this type; similarly, CFBundleTypeExtensions specifies an array of filename extensions and CFBundleTypeMIMETypes an array of MIME types. Any of these individual keys can be omitted if the corresponding file characteristic is not relevant, but at least one of them must be present for the file type to be nonempty. To allow an application to accept files of unrestricted file type or extension during drag-and-drop operations, you can use the special wild-card values '**' or '*' for CFBundleOSTypes or CFBundleTypeExtensions, respectively. (These are honored only in drag-and-drop operations and not when the user opens a document by double-clicking.) Finally, the CFBundleTypeRole key specifies the role that the application claims with respect to documents of the given type, as described under “Application Roles.”
Here's example from TextEdit.app for rtf files:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFile</key>
<string>rtf.icns</string>
<key>CFBundleTypeName</key>
<string>NSRTFPboardType</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSIsAppleDefaultForType</key>
<true/>
<key>LSItemContentTypes</key>
<array>
<string>public.rtf</string>
</array>
<key>NSDocumentClass</key>
<string>Document</string>
<key>NSIsRelatedItemType</key>
<true/>
</dict>
</array>
Thanks all one more thing I found open file is callecalled before applicationdidfinishlaunching
And is where I am creating my view controller which contains my file open method
Cheers christian andersen
I'm making a word game, and storing the words in a plist that I'm editing manually.
It now contains more than 600 words. When I write in new ones I'm always concerned, that the words already exist. I always have to search before I type a new one in, and this is really slows down the whole process.
Is there any way that I can check the list for duplication when I type in immediately, or check the whole plist for duplication and delete the duplicated words?
Make yourself a helper tool.
The tool will read in the array of strings from the plist and convert it to a set. Then it will accept new strings as input, adding them to the set. Duplicates simply won't be added. Convert the set back to an array before writing the file out.
I have written syntax highlighting for a slightly unfamiliar language (Cadence SKILL) in sublime text 2.
Its working like a charm, however I miss the feature of CTRL + R , which locates all the symbols (functions) in the present file in an easily accessible way.
Can anyone please suggest how to tell Sublime Text where to look for a pattern of function (procedure) declaration?
Thanks!
Take a look at Default/Symbol List.tmPreferences. You can create this preference file and specify scopes to include in the symbol list. You may also want to look at Java/Symbol List <some specifier>.tmPreferences for examples of a language specific symbol list. Alternatively, you can ensure the things that you want to include have the scope entity.name.function or entity.name.type.
edit
You will need to look at your color scheme file. These files are Plist, so you may want to use something like PlistJsonConverter to make it a little more readable (though this is more of a personal preference). In this file, you will see a number of dictionary entries. One of the keys to these entries is scope. When a matching scope is found as defined by your language definition. You will also see a "settings" key that defines details about color, font style, etc. Since you want different colors, you will need to apply different scopes. You will need to define a custom Symbol List preference file so everything gets included properly. The following is from the Java package.
<?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>name</key>
<string>Symbol List: Classes</string>
<key>scope</key>
<string>source.java meta.class meta.class.identifier</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
</dict>
<key>uuid</key>
<string>22E489AE-989E-4A76-9C18-89944CF5013D</string>
</dict>
</plist>
You will define whatever scopes are being applied to the entries you want to appear in the list.
I too made one myself for Cadence Skill. You can try it out here
https://github.com/noisyass2/SublimeCadenceSkill
I've made a plist with a bunch of strings. Now it turned out that I have written the strings in the wrong way. I want all the strings to the right be placed left and all the strings to left be placed to right. Is it possible?
There can be two ways to do this -
You need to do all the stuff manually.
You can have a script which will do this task for you. For similar sample scripts you can refer - http://macscripter.net/viewtopic.php?id=20152
Nothing as such is available in Xcode to do this for you.