How to know bundle identifiers of all apps on iOS simulator
Asked Answered
O

3

7

How do I get the bundle identifiers of all the apps installed on an iOS simulator?

I want to automate uninstallation of a specific app called WebDriverAgent (used by Appium) via a script.

e.g.

xcrun simctl uninstall booted com.example.apple-samplecode.UICatalog
Osburn answered 4/5, 2018 at 18:29 Comment(3)
I have the same exact need, for the same exact goal πŸ˜ƒ Did you manage to find a way? In Xcode AppleScript I manage to get current scheme, but the only thing I can get is its name or its ID (but not Bundle ID…). – Thrifty
Don't remember if I did or not, but I think the bundle ID might be in a configuration file that each app has, so maybe use grep or find to get an array of those files, then parse the bundle ID from the file, I think maybe the file was called plist but not sure. – Osburn
Thanks for the answer. The issue is that in Info.plist, it just references $(PRODUCT_BUNDLE_IDENTIFIER). I ended up using this command gist.github.com/shazron/6093283#gistcomment-2360716 instead, and it works well :) – Thrifty
S
1

Apps are installed in this directory: ~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Containers/Data/Application/ [DeviceID] being the simulator's UDID you are using. Every time a new app installed a new directory is created.

I bet your WebDriverAgent lies in there and can be removed.

Soelch answered 4/5, 2018 at 20:7 Comment(8)
I was able to use useNewWDA=true capability – Osburn
Nice! Great you figured it out yourself. Maybe you can explain it a bit more in detail for future readers that have the same problem :) – Soelch
Only problem is these ids don't have names, they are just numbers. How to know which app they belong to? – Osburn
Are these bundle identifiers? What are they? – Osburn
One is the device-id for the device, the other one seems to be a random identifier for your application. It is not the bundle identifier, this most of the time follows this reverse domain structure, e.g. com.the_prole.myapplication – Soelch
Is it possible to find the bundle identifier inside one of these randomly numbered folders? – Osburn
You find several things in the application folder: one "hacky" way would be to check the Preferences folder for example and check for the plist file which has the bundle identifier as it's name. – Soelch
This is of course depending on your situation. You probably will only find an app in that folder. Getting the bundle ID from that won't be easy even if you look at the app package content. Guess that is really intentional by apple ;) – Soelch
S
17
xcrun simctl listapps {DEVICE_UUID}

Will list all of the installed applications on the Simulator

Swiftlet answered 30/11, 2021 at 0:19 Comment(4)
To find the device UUID, you could use xcrun simctl list devices --json – Impetuosity
perfect answer! – Detect
You can also uses the special identifier booted to specify the device. So xcrun simctl listapps booted – Diablerie
Is there a way to get this in JSON format? --json as with the list command does not work… A workaround is something like this when you need trhe bundle ID's: xcrun simctl listapps "$SIM_ID" | ag CFBundleIdentifier | sed 's/.*\"\(.*\)\".*/\1/' – Enlighten
G
3

for simulator

ideviceinstaller -l -o list_all

for real devices

ideviceinstaller -u <UDID> -l -o list_all
Geezer answered 21/7, 2020 at 19:20 Comment(0)
S
1

Apps are installed in this directory: ~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Containers/Data/Application/ [DeviceID] being the simulator's UDID you are using. Every time a new app installed a new directory is created.

I bet your WebDriverAgent lies in there and can be removed.

Soelch answered 4/5, 2018 at 20:7 Comment(8)
I was able to use useNewWDA=true capability – Osburn
Nice! Great you figured it out yourself. Maybe you can explain it a bit more in detail for future readers that have the same problem :) – Soelch
Only problem is these ids don't have names, they are just numbers. How to know which app they belong to? – Osburn
Are these bundle identifiers? What are they? – Osburn
One is the device-id for the device, the other one seems to be a random identifier for your application. It is not the bundle identifier, this most of the time follows this reverse domain structure, e.g. com.the_prole.myapplication – Soelch
Is it possible to find the bundle identifier inside one of these randomly numbered folders? – Osburn
You find several things in the application folder: one "hacky" way would be to check the Preferences folder for example and check for the plist file which has the bundle identifier as it's name. – Soelch
This is of course depending on your situation. You probably will only find an app in that folder. Getting the bundle ID from that won't be easy even if you look at the app package content. Guess that is really intentional by apple ;) – Soelch

© 2022 - 2024 β€” McMap. All rights reserved.