iphone - applescript 将文件夹复制到 Xcode 中?

标签 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

有人对我缺少的内容或如何编写 Applescript 将文件夹复制到 XCode 中有任何想法吗?

最佳答案

它对我有用:

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

关于iphone - applescript 将文件夹复制到 Xcode 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4752040/

相关文章:

ios - CocoaLumberjack iOS - 我们可以更改日志文件名称和目录吗?

iphone - 如何迭代应用程序上的所有 UIViewControllers

iphone - 网站文本在 iPhone 上的随机区域显得更大

iphone - 如何更新字典中的所有项目? iPhone

Xcode 4 : Project does not honor $(inherited) Build Setting in Workspace?

swift - Xcode SpriteKit SKAction 未更改 SKSpriteNode 的属性?

ios - 成员初始化器如何在 Structs 中工作? (在 swift 中)

syntax - AppleScript 语法 a real number 不能跟在这个实数后面?

objective-c - 如何处理仅从键盘在 ObjC 源代码中键入嵌套消息调用?

applescript - 更改事件查找器选项卡