AppleScript 创建 Xcode 目标的副本

编程入门 行业动态 更新时间:2024-10-25 04:17:37
本文介绍了AppleScript 创建 Xcode 目标的副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有什么方法可以使用 AppleScript 创建目标副本.我正在使用以下代码,但它显示错误:Xcode 出现错误:无法复制目标.

Is there any way to create a duplicate of target using AppleScript. I am using below code but it shows Error : Xcode got an error: Targets can not be copied.

tell application "Xcode"
tell active workspace document
    set firstProject to (get first project)
    set firstTarget to (get second target of firstProject)
    tell application "Xcode" to duplicate firstTarget
end tell
end tell

以上脚本适用于当前在 Xcode 中打开的项目.

above scripts is for the project that is currently open in Xcode.

我有不同的方法来实现它,但不知道如何让它发挥作用.

I have different approach to achieve it but not getting how to make it work.

打开一个 Xcode 项目

Open an Xcode project

告诉应用程序查找器"打开 POSIX 文件/Users/TestUser/Desktop/CoBranding/source/tet/test.xcodeproj"最后告诉

tell application "Finder" open POSIX file "/Users/TestUser/Desktop/CoBranding/source/tet/test.xcodeproj" end tell

选择一个特定的目标并选择它(保持专注)

Choose a particular target and and select it (keep focus on it)

告诉应用程序Xcode"告诉活动工作区文档将 firstProject 设置为(获取第一个项目)将 projectDirectory 设置为(获取 firstProject 的项目目录)
结束告诉最后告诉

tell application "Xcode" tell active workspace document set firstProject to (get first project) set projectDirectory to (get project directory of firstProject)
end tell end tell

现在使用 Apple Scripts 的系统事件按编辑菜单下的复制.

Now press Duplicate under Edit menu using system events of Apple Scripts.

推荐答案

你可以使用这个脚本

tell application "Xcode"
activate
delay 3
tell active workspace document
    set my_project to (get first project)
    tell my_project

        tell application "System Events"
            keystroke "d" using {command down}
            delay 0.5
            tell application process "Xcode"
                delay 1.0E-3

                click button "Duplicate Only" of window 1


            end tell

        end tell

    end tell
end tell
end tell

只有一件事需要您的 xcode 项目处于活动状态:) 祝您好运

only one thing needed your xcode project should be active :) Good Luck

这篇关于AppleScript 创建 Xcode 目标的副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 14:05:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:副本   目标   AppleScript   Xcode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!