gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 18:33:19 25 4
gpt4 key购买 nike

我在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com