Core Data Model Document AppleScript Interface Broken

Originator:rentzsch
Number:rdar://7289446 Date Originated:09-Oct-2009 12:25 AM
Status:Open Resolved:
Product:Developer Tools Product Version:3.2.1 (Xcode IDE: 1613.0)
Classification:Other Bug Reproducible:Always
 
Summary:
In Xcode 3.1 I could write AppleScripts that manipulate Core Data Model Files. This support no longer works in Xcode 3.2 and 3.2.1


Steps to Reproduce:
1. Open an .xcdatamodel file in Xcode.
2. Run the following AppleScript:
	tell application "Xcode"
		exists data model documents
	end tell


Expected Results:
Script result is true.


Actual Results:
Script result is false.


Regression:
This worked in Xcode 3.1 and earlier.

You can access the data model document with this script:
	tell application "Xcode"
		every document whose file type is "Data Model File"
	end tell

But the document's retrieved "entities" property is always empty.


Notes:
A feature of my Xmo'd plugin is the ability to auto-customize entity classes. This no longer works. Here's my script that used to work:

tell application "Xcode"
	activate
	if not (exists active project document) then
		error "No active project. Please open an Xcode project and re-run the script."
	end if
	set mainWindowFilePath to associated file name of main window
	if mainWindowFilePath does not end with ".xcdatamodel" then
		error "Please open an .xcdatamodel file and re-run the script."
	end if
	tell item 1 of (every data model document whose path is mainWindowFilePath)
		using terms from application "Finder"
			display alert "Autocustomize Entity Classes" message "Automatically customize all generic entity classes based on their names? (This is undoable.)" buttons {"Cancel", "Auto-customize"} cancel button 1
		end using terms from
		if button returned of result is "Auto-customize" then
			repeat with entityIt in (every entity)
				set object class of entityIt to name of entityIt & "MO"
			end repeat
		end if
	end tell
end tell
activate

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!