How to get Bundle Id of Installed App in iOS?

Hi Team,

Could you show some light on how to get the Bundle Id of installed iOS app (from App Store) on iPhone/iPad ?

Thanks,
Sinduja

Hi @Sinduja

You can try one of two ways:

If you have the .ipa, change it’s extension to .zip, open the zip and look for a file with the extension .plist.
Open this file in any text editor and look for the bundle id - it will usually have the format com.company.appName.

Another way, if you are using java for your test scripts is to add the following snippet to your setup or test methods:

String applications = (String) driver.executeScript("experitest:client.getInstalledApplications()");
applications = applications.replace("\\n", " ");
Pattern pattern = Pattern.compile("\\w+.\\w+.<app_name>");
Matcher matcher = pattern.matcher(applications);
if (matcher.find())
{
System.out.println(matcher.group(0));
}

Thanks a lot!
The app we want to launch is downloaded/installed directly from AppStore (App name : Box), and we are using C# client libraries.

Could you please share any solution around this ?

Thanks,
Sinduja

Hi @Sinduja

First, add using System.Text.RegularExpressions; in your project.

Then add the following code snippet:

String apps = (String)driver.ExecuteScript("experitest:client.getInstalledApplications()");
Regex regex = new Regex("\\w+\\.\\w+\\.Box\\w*");
Match match = regex.Match(apps);

if (match.Success)
    {
             NUnit.Framework.TestContext.Out.WriteLine("Found Match for {0}", match.Value);
    }

You should be able to see the bundle id in the output:

Thanks a lot Nivi!

I have tried the above code snippet which you have shared. Now i am able to get the bundle id :slight_smile:

But When i run the command : driver.ExecuteScript(“client:client.launch(“nnet.box.BoxNet”)”);

I am getting below exception :
{“javascript error (javascript error. TypeError: Can not invoke method [jdk.internal.dynalink.beans.SimpleDynamicMethod Map com.experitest.image.agent.appium.backend.commands.browser.AppiumScriptClient.launch(String,boolean,boolean)] with the passed arguments; they do not match any of its method signatures. in at line number 1) (UnexpectedJavaScriptError)”}

Could you please help me with this ?

Hi @Sinduja

Can you try and run the command with the bundle id net.box.BoxNet? That is, remove the additional “n” before net.

I believe this is what’s causing the issue.

Thanks Nivi ,

I have run the command with the bundle id : net.box.BoxNet
Command : driver.ExecuteScript(“client:client.launch(“net.box.BoxNet”)”);

Still i am facing the same exception :

{“javascript error (javascript error. TypeError: Can not invoke method [jdk.internal.dynalink.beans.SimpleDynamicMethod Map com.experitest.image.agent.appium.backend.commands.browser.AppiumScriptClient.launch(String,boolean,boolean)] with the passed arguments; they do not match any of its method signatures. in at line number 1) (UnexpectedJavaScriptError)”}

Hi @Sinduja

Apologies for getting back to you only now.

Please try to run the launch command as follows:
driver.ExecuteScript(“experitest:client.launch(“net.box.BoxNet”, “false”, “false”)”);
For more information, see here.

The two Boolean parameters at the end are used to determine whether you want to launch the app in instrumented mode, and whether you want the app to be closed first in case it was already up and running when the test was initiated.

I hope this helps.

Thanks a lot Nivi,

I tried with the above launch command which you have mentioned :

driver.ExecuteScript(“experitest:client.launch(“net.box.BoxNet”, “false”, “false”)”);
Its working! :smile:

Thanks for sharing me the link, Its really helpful. :slight_smile:

2 Likes