2

I have written an script for duplicate target of Xcode project and got Error "Xcode got an error: AppleEvent handler failed.

My script is:

 tell application "Xcode"
activate
delay 3
tell active workspace document
    set my_project to (get first project)
    tell my_project
        set make_target to (get first target of my_project)
        set target_name to "ScriptDemoCopy"
        tell application "System Events"

            keystroke "d" using {command down}

            --set my_new_target to make target with data make_target with properties {name:target_name}
        end tell

    end tell

end tell

end tell Can someone tell me where am i wrong ?

Thanks in advance.

user123456
  • 81
  • 7
  • you may find what your looking for here http://stackoverflow.com/questions/2694750/how-to-automate-creation-of-new-xcode-targets-from-applescript-automator-shell-s – mcgrailm Jul 29 '14 at 08:18
  • There is a clear sentence "Duplicate an existing target and rename it (not implemented)", So I have not tried that one :) – user123456 Jul 29 '14 at 08:56
  • ok so maybe that says that you have to go the long way about it , or that it's not possible – mcgrailm Jul 29 '14 at 11:25
  • In that case I need proper documentation that says it is not possible. :( – user123456 Jul 29 '14 at 12:01
  • I wrote a script for a client which duplicates targets by scripting the interface. Once you accurately select the target(the hard part), you can use keystroke "d" using command down – adayzdone Jul 29 '14 at 12:08
  • @user123456 if only people would document the things that are not possible ;) – mcgrailm Jul 29 '14 at 12:14
  • @adayzdone can you tell me where am i doing wrong?, I doubt i am using wrong way to set the target_name but not sure how to do this, I have no idea about apple script :( – user123456 Jul 29 '14 at 12:28
  • @adayzdone even also I have tried with command line but not succeed :( – user123456 Jul 29 '14 at 12:29
  • @user123456 You need to script the interface with System Events to send keystrokes and reference/select UI elements. It is far from ideal, but it does work. – adayzdone Jul 29 '14 at 12:36
  • Thanks for guidance but still could not get how to select one the options of popup getting with these command keystroke "d" using {command down} – user123456 Jul 30 '14 at 07:36
  • @adayzdone btw in which Xcode version have you written Script? – user123456 Jul 30 '14 at 09:15
  • I am editing my question by which I am getting alert but don't know how select duplicate only? – user123456 Jul 30 '14 at 11:30
  • @adayzdone You have used apple script right, Please look my question edited. – user123456 Jul 30 '14 at 11:33
  • @adayzdone Can you show the code to me? – user123456 Jul 30 '14 at 11:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/58349/discussion-between-user123456-and-adayzdone). – user123456 Jul 30 '14 at 11:53

0 Answers0