我在使用AppleScript将文件夹复制到XCode项目时遇到了一些麻烦。没有Applescript我将文件夹拖到Xcode中。
我使用了类似的Applescript处理程序,如下所示,使用“wrapper.library”将库复制到XCode中作为文件类型。下面我使用“wrapper.folder”尝试将文件夹复制到XCode中,但它无法正常工作。
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
有没有人对我遗失的内容或如何编写Applescript以将文件夹复制到XCode有任何想法?
答案 0 :(得分:1)
这对我有用:
--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
Xcode 4的代码有点不同
--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
选项'如果需要,复制到目标文件夹'只是将文件复制到项目中(如果它们尚未存在),然后对复制的文件而不是原始文件进行文件引用。您可以使用Finder或shell命令(如cp或ditto)执行相同操作,然后对复制的文件进行引用。然后我不会使用完整路径而是使用相对路径。使用相对路径将项目移动到另一个文件夹不会给您带来任何问题。