0

I'm trying to make an application which shows the bundle ID of installed applications on the iOS device using Objective-C.

UILabel *bundleIdentifier = [[UILabel alloc]initWithFrame:CGRectMake(10,10,200,50)];

bundleIdentifier.text = [[NSBundle mainBundle] bundleIdentifier];

[self.view addSubview:bundleIdentifier];

By using this code in the application's code, I can display the bundle ID of the application I'm creating...

How can I get the bundle id of other apps to display?

In the header SBApplication.h I found -(NSString*)bundleIdentifier;

Is this useful?

Thanks!

CandyGum
  • 461
  • 3
  • 7
  • 19
  • Hm, have you tried "allBundles" and "allFrameworks" for NSBundle yet :) https://developer.apple.com/reference/foundation/bundle/1413705-allbundles https://developer.apple.com/reference/foundation/bundle/1408056-allframeworks – Lepidopteron May 15 '17 at 13:17
  • My objective-c is really bad and I really don't know how to use this in my app :( Any chance you can help me with this? – CandyGum May 15 '17 at 13:29
  • [[NSBundle mainBundle] allBundles]; and [[NSBundle mainBundle] allFrameworks]; <-- borth return a NSArray. You can log this the following way: (will be A LOT) NSLog(@"%@",[[NSBundle mainBundle] allBundles]); – Lepidopteron May 15 '17 at 13:31
  • @Lepidopteron Here is my code as well as errors when compiling: https://ghostbin.com/paste/cvmro, you got any idea of what I'm doing wrong? – CandyGum May 15 '17 at 13:49
  • You want to retrieve all the BundleID's of the app installed by the user on their device? This is not possible. You can can't access the file system outside of your apps directory. The only option was using app url scheme, but this has been greatly reduced by Apple since iOS 9 by only allowing you to query 50 schemes. – rckoenes May 15 '17 at 14:15
  • @rckoenes This is what I want to do --> http://i.imgur.com/oj5KPOf.png It's possible ^_^ – CandyGum May 15 '17 at 14:19
  • No not by scanning the user device, since you don't have access to the file system. Your only option is to user app url scheme, but this is restricted. If you can user [`[UIApplication canOpenURL:]`](https://developer.apple.com/reference/uikit/uiapplication/1622952-canopenurl) but you will have enter all the apps you want to URL in your apps `info.plist`. Also there is now way to get the bundle ID. – rckoenes May 15 '17 at 14:22
  • @rckoenes How is this application doing it? http://i.imgur.com/oj5KPOf.png – CandyGum May 15 '17 at 14:25
  • Ask the developers! It can only be done on a jailbroken device or the app uses the app URL scheme way to detect the apps and has a list of the correct bundle id. – rckoenes May 15 '17 at 14:26
  • @rckoenes Alright, I am trying to make this for jailbroken devices ^_^ And I'll try to contact the authors though I doubt it will be possible, this is a 4 year old app. – CandyGum May 15 '17 at 14:30
  • @rckoenes Do you know how to do it on a jailbroken device? – CandyGum May 15 '17 at 14:31
  • I have zero experience on jailbroke device, but my guess is you need to path the application install directory, then loop trough the the sub-directories an grab the `info.plist` for each app. From there it should not be that hard. – rckoenes May 15 '17 at 14:33
  • @rckoenes Do you have Skype, a mail address or something else which I can contact you trough? I'd like to ask you some simple things if you don't mind :) – CandyGum May 15 '17 at 15:27
  • Please check my this question: http://stackoverflow.com/questions/26969923/get-list-of-all-installed-application-in-ios-8, here you get all other apps as well as their bundle ids too. Also, make sure that this is by using private apis, so you cant put your app on app store with this. – Mehul Thakkar May 16 '17 at 06:46
  • @MehulThakkar I get this error from that code: https://ghostbin.com/paste/nhs9f – CandyGum May 19 '17 at 14:29
  • This is working perfect with objective-c, probably you are using objective-c ++, that may be making problem. Please check your code for the same – Mehul Thakkar May 19 '17 at 20:05

1 Answers1

-1

You can see, which frameworks and bundles are available by making use of the properties:

These properties return an array with all available bundles/frameworks (1) You can loop through the array and look for the bundle you are interested in (2)

// (1) get all frameworks and bundles that seem to be available and put them in one array
NSMutableArray *bundles = [NSMutableArray new];
[bundles addObjectsFromArray:[NSBundle allFrameworks]];
[bundles addObjectsFromArray:[NSBundle allBundles]];

// (2) Loop through the array and look for the stuff you are interested in
for (NSBundle *bundle in bundles)
{

    // Do whatever you want with the bundle or private frameworks.
    // https://developer.apple.com/reference/foundation/nsbundle?language=objc
    NSLog(@"------");
    NSLog(@"%@",bundle);
    NSLog(@"%@",bundle.bundleURL);
    NSLog(@"%@",bundle.bundlePath);
    NSLog(@"%@",bundle.bundleIdentifier);
    NSLog(@"%@",bundle.infoDictionary);
    NSLog(@"------");
}
Lepidopteron
  • 6,056
  • 5
  • 41
  • 53
  • Thank you, I will try this soon, but, just a question, which might be stupid but I really don't know... If I use NSLog, **where will the logs go**? I mean if I put this code and compile it and run the app, what will happen? a blank screen? – CandyGum May 16 '17 at 14:43
  • They will go to the devices console. If you go Xcode installed on your Computer, go to Window->Devices and select your iPhone there, then you will have at the bottom the device log. Another opportunity would be certain scripts, but I think the Xcode approach is easier for you – Lepidopteron May 16 '17 at 14:45
  • @CandyGum not available any longer – Lepidopteron May 22 '17 at 08:52