【问题标题】:applescript to copy folders into Xcode?applescript 将文件夹复制到 Xcode 中?
【发布时间】:2011-06-12 17:30:12
【问题描述】:

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

【问题讨论】:

  • 这个 Xcode 插件可能会有所帮助:github.com/larsxschneider/Xcode-Scripting-Interface
  • 我很想知道你是怎么解决这个问题的...
  • 除了手动移动文件夹外,我从未找到解决方案。我知道这是可以做到的,因为我使用了可以移动文件夹的已编译 Applescript。
  • 基于对这个问题的回答stackoverflow.com/questions/6022009/… Xcode AppleScript add 命令可能已损坏。
  • 如果添加命令被破坏,编译后的 AppleScript 是否仍然能够将文件夹添加到 Xcode 项目中?

标签: iphone xcode applescript


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

【讨论】:

  • 有趣。这会为项目添加一个文件夹文件引用。 (注意文件夹图标是蓝色的,而不是黄色的。)但是,这些文件不会添加到项目的构建或复制阶段。
猜你喜欢
  • 2010-10-28
  • 2018-05-17
  • 1970-01-01
  • 2015-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多