I'm having some trouble copying folders into XCode projects with AppleScript. Without Applescript I drag the folder into Xcode.
I've used a similar Applescript handler, as the one shown below, to copy libraries into XCode using "wrapper.library" for the file type. Below I am using "wrapper.folder" to try to copy a folder into XCode and it isn't working.
on addFolder(fname, fpath)
tell application "Xcode"
tell project "Unity-iPhone"
set my_targets to targets
set s_target to item 1 of my_targets
set compile_phase to compile sources phase of s_target
set link_phase to get link binary with libraries phase of s_target
tell root group
set a to make new file reference with properties {full path:fpath & fname, name:fname, file type:"wrapper.folder"}
add a to link_phase
end tell
end tell
end tell
end addFolder
Does anyone have any ideas on what I am missing or how to write an Applescript to copy a folder into XCode?
It is working for me:
--this is for xcode 3.x
tell application "Xcode"
tell active project document
tell root group
--Note: Large folders make it seems that the script is hanging. Give it some time to list all items in the given folder.
make new file reference with properties {name:"My Desktop Folder", full path:(POSIX path of (path to desktop folder)), file type:"wrapper.folder"}
end tell
end tell
end tell
The code for Xcode 4 is a bit different
--this is for Xcode 4.x
tell application "Xcode"
tell project 1
tell root group
--Note: big folders make it seems that the application (not the script like in Xcode 3) is hanging. Give it some time to list all items in the given folder.
make new file reference with properties {name:"My Desktop Folder", full path:(POSIX path of (path to desktop folder)), file kind:"folder"}
end tell
end tell
end tell
The option 'copy to destination folder if needed' just copy the files to the project (if they're not already in there) and then make a file reference to the copied files instead of the original files. You can do the same with the Finder or a shell command like cp or ditto, then make a reference to the copied files. Then I wouldn't use full path but relative paths instead. With relative paths moving the project to another folder won't give you any problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With