如何获取您的应用程序iOS UIA自动化的Bundle Id

时间:2012-01-05 12:16:35

标签: ios automation ui-automation ios-ui-automation

如何获取我所在应用的套件ID?

3 个答案:

答案 0 :(得分:119)

您将使用:

[[NSBundle mainBundle] bundleIdentifier]

+ mainBundle“[r] eturns NSBundle对象,该对象对应于当前应用程序可执行文件所在的目录。”因此将返回应用程序包的NSBundle对象。

[- bundleIdentifier]返回“[t]接收者的包标识符,该标识符由包的信息属性列表中的CFBundleIdentifier键定义。”

答案 1 :(得分:8)

以下是我在UIA脚本中获取APP的Bundle ID的方法:

//code to get bundle id
var target = UIATarget.localTarget();
var app_name = target.frontMostApp().bundleID();
UIALogger.logDebug(app_name);

答案 2 :(得分:4)

您可以从plist中找到包ID。右键单击应用程序文件,然后单击“显示包内容”。你会在那里找到一个plist文件。使用任何文本编辑器打开它,您将获得包ID。