Unable to Create PLISTs on 10.10

The below works on 10.8 and 10.9 to create and populate a plist. However, on 10.10, this error is returned:

tell application "System Events"
	-- create an empty property list dictionary item
	set the parent_dictionary to make new property list item with properties {kind:record}
	-- create new property list file using the empty dictionary list item as contents
	set the plistfile_path to "~/Desktop/example.plist"
	set this_plistfile to ¬
		make new property list file with properties {contents:parent_dictionary, name:plistfile_path}
	-- add new property list items of each of the supported types
	make new property list item at end of property list items of contents of this_plistfile ¬
		with properties {kind:boolean, name:"booleanKey", value:true}
end tell

Any ideas?

Adding this before the tell block fixed the issue for me. Seems like the plist file is not being created properly by system events. 10.10 is beta, after all. Maybe it’s a bug?


do shell script "defaults write ~/Desktop/example.plist test test"
do shell script "defaults delete ~/Desktop/example.plist test"

Speaking of defaults, why not just use:


do shell script "defaults write ~/Desktop/example.plist booleanKey -boolean TRUE"

Two:

  • Go to bugreport.apple.com and report it. If no-one reports it, it won’t get fixed.

  • This is the AppleScriptObjC forum, and if you’re using ASObjC you don’t need to use System Events. Just make a record, convert it to a dictionary, and save that to a file.