applescript 将文件夹复制到 Xcode 中?

发布于 2024-10-12 18:13:57 字数 802 浏览 3 评论 0原文

我在使用 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 有任何想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾北清歌寒 2024-10-19 18:13:57

它对我有用:

--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 或同上)执行相同操作,然后引用复制的文件。然后我不会使用完整路径而是使用相对路径。使用相对路径将项目移动到另一个文件夹不会给您带来任何问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文