applescript将文件夹复制到Xcode中?

Jam*_*sta 9 iphone xcode applescript

我在使用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
Run Code Online (Sandbox Code Playgroud)

有没有人对我遗失的内容或如何编写Applescript以将文件夹复制到XCode有任何想法?

dj *_*zie 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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

“如果需要,复制到目标文件夹”选项只需将文件复制到项目中(如果它们尚未存在),然后对复制的文件而不是原始文件进行文件引用。您可以使用 Finder 或 shell 命令(如 cp 或同上)执行相同操作,然后引用复制的文件。然后我不会使用完整路径而是使用相对路径。使用相对路径将项目移动到另一个文件夹不会给您带来任何问题。