How to get Bundle Id of your app iOS UIA automation
Asked Answered
B

3

39

How do I get the bundle Id of the app I am in ?

Bowes answered 5/1, 2012 at 12:16 Comment(0)
P
118

You'd use:

[[NSBundle mainBundle] bundleIdentifier]

+ mainBundle "[r]eturns the NSBundle object that corresponds to the directory where the current application executable is located." and hence will return an NSBundle object for the application bundle.

[- bundleIdentifier] Returns "[t]he receiver’s bundle identifier, which is defined by the CFBundleIdentifier key in the bundle’s information property list."

Peugia answered 5/1, 2012 at 12:53 Comment(2)
Thank you Tommy. Now I am able to get the bundle Id in the UIA Scripts as well.Bowes
For googlers, Check swathy's answer below to get bundle Id in UIA scripts.Traduce
B
8

Here is how I got the Bundle Id for my APP in the UIA Scripts:

//code to get bundle id
var target = UIATarget.localTarget();
var app_name = target.frontMostApp().bundleID();
UIALogger.logDebug(app_name);
Bowes answered 6/1, 2012 at 11:40 Comment(0)
A
4

You can findle the bundle id from the plist. Right Click in the app file and click on "show package contents". You will find a plist file there. Open it with any text editor and you will get the bundle id.

Anatropous answered 6/9, 2012 at 7:47 Comment(3)
Not false, but obviously the question was about getting the bundle id from code, not from the finder. You must read carefully the question, and other answers before answering.Steeplechase
The question was regarding UIA Automation and is not related to source code. We always use app or ipa file for that and not the source code, So you better re read that questionAnatropous
Funny, I would have sworn that "automation" would mean using a script, so, code.Steeplechase

© 2022 - 2024 — McMap. All rights reserved.