Re: Applescript for XCode fails: error -1728, group can't be accessed
Re: Applescript for XCode fails: error -1728, group can't be accessed
- Subject: Re: Applescript for XCode fails: error -1728, group can't be accessed
- From: Christiaan Hofman <email@hidden>
- Date: Mon, 17 May 2010 14:46:10 +0200
On May 17, 2010, at 13:01, Patrick Iglesias-Zemmour wrote:
> Hi there
>
> To complete Cristiaan Hofman's answer. Write
>
> tell application "Xcode"
> activate -- or not, you can activate after the creation also.
> tell root group of active project document
> make new group with properties {name:"newname", path type:project relative}
> end tell
> end tell
>
> This script send a message to the object itself, your target. When you write "set myroot to whatever" AS make a reference to the target it doesn't duplicate it (why would he?). The object (here : root group of active project document) is unique. So finally you sent your message just to a pointer and not to the object you want to talk with. And the pointer doesn't understand your message, which is quite logic.
This is highly misleading. AS always refers to objects through a reference. It's just that there may be different ways to refer to the objects. In this case, as the 'root group' property or as a group element by id. Both references should be equally valid, in theory. The id version would even be the canonical way to refer to any group, including the root group. This is also why the variable will be set to this canonical form, because setting a variable will evaluate the expression. For sure one should expect that the /canonical/ reference should understand the message. But here it doesn't. I was actually surprised by this fact, because in almost all cases in AS it's the other way around: the canonical reference understands the message, but the secondary (like 'root group') does not, that's why in AS you almost always need to use an intermediate variable to evaluate an expression, or insert an extra 'get' in the statement to force evaluation (I consider this a bug in AS.) Here it's the other way around, which is actually strange (and makes me think it's a bug in Xcode rather than in AS.) Hence this is most definitely not logical, it's a bug.
Christiaan
>
> Hope this helps.
>
> -p
>
> P.S. By the way nobody answered me about where are located the shell user scripts of the User Scripts menu ? Nobody knows ?
>
> On May 17, 2010, at 1:02 PM, Stefan Bender wrote:
>
>> Dear list members,
>>
>> In an attempt to write a script that adds and removes files from an XCode projects I stumbled across a strange error message when trying to add a new group
>>
>> The following Applescript failed with the error message "Xcode received an error: group id 0867D691FE84028FC02AAC07 of project "mac_utils_xcode\" can't be read number -1728 from group id "0867D691FE84028FC02AAC07" of project "mac_utils_xcode"".
>>
>> The group ID "0867…" actually is the ID of the root group, I looked it up in project.pbxproj.
>>
>> The error happened when executing the "make new group" command.
>>
>>
>> on grouptest()
>> tell application "Xcode"
>> activate
>> set myroot to root group of active project document
>> tell myroot
>> set newgroup to make new group with properties {name:"newname", path type:project relative}
>> end tell
>> end tell
>> end grouptest
>>
>>
>> Mac OS X 10.6.3, XCode 3.2.1.
>>
>> is there anything obvious I'm missing? According to my research error code "-1728" means 'Can't get reference', but does this make sense here?
>>
>> It would be very nice if somebody could give me a hint how to get this script running.
>>
>> Thanks and best regards,
>>
>> Stefan Bender
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden