如何自动化 XCode 项目变更?

发布于 2024-09-19 02:36:29 字数 259 浏览 5 评论 0原文

我有一项繁琐的任务,每次构建 iPhone 项目以发送给非程序员同事时都需要重复:我在项目文件夹之外引用的所有库和标头都需要复制到项目文件夹或其子文件夹中,因此我可以压缩源代码并传递它。

我知道您可以使用 AppleScript 自动化 XCode,但我一生都找不到可用命令的任何正确文档。如果我在 google 上搜索 XCode AppleScript 自动化,就会得到一堆有关在 Xcode 中编写 AppleScript 应用程序的搜索结果。

任何帮助将不胜感激!

I have a tedious task that I need to repeat every time I build my iPhone project for sending to non-programmer colleagues: all libraries and headers that I reference outside the project's folder need to be copied into the project folder or a subfolder thereof, so I can zip up the source and pass it on.

I'm aware that you can automate XCode with AppleScript, but I can't for the life of me find any proper documentation of the commands available. If I google XCode AppleScript automation, I just get a bunch of hits on writing AppleScript apps in Xcode.

Any help will be greatly appreciated!

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

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

发布评论

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

评论(2

秋风の叶未落 2024-09-26 02:36:29

这里有一个演示可以帮助您入门。既然您知道如何查找字典,那么如果您习惯使用 AppleScript,那么剩下的事情可能会很容易:

tell application "Xcode"
    -- of course, use your project's name instead of Alias
    set projectName to "Alias" 
    set xcProject to project projectName

    repeat with idx from 1 to the count of (get every file reference of xcProject)
        set fileRef to (file reference idx) of xcProject
        get path of fileRef
        get id of fileRef
        get name of fileRef
        get properties of fileRef

        set newPath to path of fileRef
        -- add logic and alterations here
        set path of fileRef to newPath
        -- ...
    end repeat
end tell

here's a demo to get you started. since you know how to locate the dictionary, the rest may be easy if you are comfortable using AppleScript:

tell application "Xcode"
    -- of course, use your project's name instead of Alias
    set projectName to "Alias" 
    set xcProject to project projectName

    repeat with idx from 1 to the count of (get every file reference of xcProject)
        set fileRef to (file reference idx) of xcProject
        get path of fileRef
        get id of fileRef
        get name of fileRef
        get properties of fileRef

        set newPath to path of fileRef
        -- add logic and alterations here
        set path of fileRef to newPath
        -- ...
    end repeat
end tell
猥琐帝 2024-09-26 02:36:29

根据您的描述,在 xcode 中创建自定义目标来执行此任务会更容易。 xcode 可以运行各种用于复制、压缩等的 UNIX 实用程序。所以……shell 脚本编写应该更容易。如果您愿意,您还可以将此目标设置为依赖项,因此它始终保持最新(但对于常规开发来说有点慢,说实话。

是的,您可以在很多情况下将 applescript 与 xcode 一起使用,但它会继续对于你所概述的任务来说要困难得多。

based on your description, it would be easier to create a custom target in xcode to perform this task. xcode can run all sorts of unix utilities for copying, zipping, etc. soo... shell scripting should be much easier. you can also set this target up as a dependency if you'd like, so it always stays up to date (but a little slow for regular development, tbh.

yeah, you can use applescript with xcode in many cases, but it is going to be much more difficult for the task you've outlined.

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