Get path to iOS application based on name or bundle identifier - ios

Is there an easier way to get the path to an iOS application, than searching /var/mobile/Applications?
I know both the name and the bundle identifier, however the path is not consistent on different iOS devices.
This is for use in a jailbreak tweak, so I can use PrivateFrameworks and other code not allowed by Apple.

If you're running code that executes in Springboard, this should be fairly simple. Get SBApplicationController's sharedInstance, then get the SBApplication you're looking for with the applicationWithDisplayIdentifier: method (or using whatever method you choose). The SBApplication class contains properties for path, containerPath, and bundle (among many others), one of which should be what you're looking for. I haven't tried this myself, so I can't guarantee it'll work, but based on a quick glance at the Springboard header files (you can take a look here, or dump the header files yourself), it should work.
On the other hand, if you're not running from Springboard (ie. if you're making an actual App Store-style application), then you may be out of luck. You could look into inter-process communication with Springboard and see if something can be done there, but it'd probably be more trouble than it's worth.

If running in an app, you can define:
extern NSString* SBSCopyBundlePathForDisplayIdentifier(NSString* bundleId);
and link to the SpringboardServices framework.

Or you can use the library AppList and then it's:
ALApplicationList *al = [ALApplicationList sharedApplicationList];
NSString *appPath = [al valueForKey:#"path" forDisplayIdentifier:bundleID];
In this case it's doing what Andrew R. mentions in his answer for you. (I assume the same requirements are necessary, i.e. must be running from Springboard.)
Update: This no longer seems to be working on iOS 11.

Related

Reading an app setting value from iOS Settings-MyApp using Ionic

I want to create a app specific setting(app preference) in iOS(iPad) and read that in my Ionic(v5) code. I have seen plugins like https://github.com/chrisekelley/AppPreferences/ this but not working with the cordova-9 as it was not updated. Looks like this project is abandoned.I was able to create a setting bundle during the build and place it under the settings->Myapp (key-value) but from the program reading is not working.
My requirement is very simple. I need to externalize the back-end server IP/name as it might change sometimes. I was thinking if I can create a property under Settings->MyApp->Server then I can edit it in the Settings and read it while starting the app.
Is there a different approach that I can follow?
Please let me know if you have any pointers.

JailBreak iOS: adding custom view to input call view

I need to add my custom view to input call view. I have got jail broken device with iOS 9.3.2. I've installed Theos to my MacBook. I've installed mobile substrate to iOS. And now I don't know what I need to do.
I found that I have to modify InCallService.app. But I cannot find needed class for tweak.
Also I don't understand how can I write logs. I tried to use NSLog(#"aaa") and %log(#"aaa") but I cannot find file with logs.
Thank you.
If you want to add something to the app, modifying the .app isn't the easiest way. If you have MobileSubstrate installed you can hook a method from the Phone application and using basic iOS paradigms like MVC you can find the views you need to modify and go from there. If you need the header files you can either dump them yourself with class-dump-z or see if these are still valid.
Logging data is also quite easy with Ryan Petrich's deviceconsole
Just run the command deviceconsole --process < YOUR HOOKED PROCESSES' NAME > in your console after installing deviceconsole onto your Mac, and anything in your code using %log(); will show up in the console.

In iOS, is it bad to ship to the app store with uncommented NSLogs?

I like to use these to debug (can you tell I'm a noob?) and have left them in my code as is when deploying to the app store. Are there any negative implications for this you can personally think of?
I have looked at these resources and I am getting the feeling it's not a good idea:
http://doing-it-wrong.mikeweller.com/2012/07/youre-doing-it-wrong-1-nslogdebug-ios.html
https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/LoggingErrorsAndWarnings.html#//apple_ref/doc/uid/10000172i-SW8-SW7
This was also a good resource:
http://www.theonlylars.com/blog/2012/07/03/ditching-nslog-advanced-ios-logging-part-1/
That said, when you ship to the store and DO keep NSLogs in there, what have you logged?
Create a snippet with the above settings. Where it says "debug statement", replace that with:
<#debug statement#>
Now, since the completion shortcut is set to "NSLog", every time you start typing NSLog, it will autocomplete to this snippet and you will have the "debug statement" part selected and ready to type over.
You'll never have to worry about commenting out your NSLog statements again, and you'll never have to forget about using #if DEBUG since the completion shortcut is what you would type anyway.
Apple's Official Documentation for creating a Snippet (I've included this link because I think it's really kind of sad that this is apparently the only way to do it?)...
And my explanation...
Copy and paste the following code into Xcode:
#if DEBUG
NSLog(<#debug statement#>);
#endif
Select the entire code block you just copy-pasted. Click, hold, and drag this code block down to the snippets section (usually in the bottom right corner).
Select this snippet to get a screen like this:
Click "Edit" and fill out the details. Give it a title and description. Leave platform on "All", and language on "Objective-C". Set the completion shortcut to "NSLog", and leave the completion scope on "Function or Method" (what this option defauts to may depend on where you pasted the code to originally and where you dragged it from).
As Aaron Brager's answer points out, NSLog could be a performance concern, particularly in loops (also in places that don't seem very much like loops but actually are, like cellForRowAtIndexPath...).
But more importantly, you may be exposing information you don't necessarily want to be made publicly available.
I'm not saying there doesn't exist something that might be useful to include to present to the end user in the log statements, but personally, I've yet to find it. How many times have you ever investigated the output of an app's log statements to diagnose an issue you were having with it? How many times have you contacted an app developer and they asked you to check these statements to help diagnose a technical issue you were having?
The Mike Weller post you linked makes the right call. NSLog is for user-facing warnings.
There also might be performance issues, especially within loops, since it uses a string formatter.
You can and should use DDLog or other tools to ignore the debug messages when you make your release build.

Is it okay to name every project "app" in Rails 4?

I don't like the idea of hardcoding brand names in my projects. I get the feeling they might change later, and sometimes I don't even have a name yet. So, can I do rails new app for my every project and just rename the directory? What problems could arise from that?
this could result in some issues
the name of the application has some implications on the internals and using several apps named "app" might have undesired effects and bugs.
for instance, sessions and cookies are named after the app name, so they will all be the same
further more, this have effects on outside sources such as AWS buckets, github repos, and even folder names - it will be pretty hard to figure out what all those /app folders are.
so if the only app you have and are working on is called app - it shouldn't be a problem (besides the name app, which is really lame, and if you are working on it at least call it by greek letters or something..)
if you are going to work on more that one app.. do yourself, your coworkers, your file-system, github, and everything else - name your app.
Also an important side note - how can you have an app and not know what it is about?
and if the name is not suiting anymore.. change it https://github.com/morshedalam/rename
If you rename your project, you must rename it in some files too. (routes.rb, environment.rb, application.rb, ...)
Heroku, for example, let you rename your app any time with apps:rename.

How to give the security permissions to delete file from my sdcard in blackberry?

How to give the permissions to delete a file from SDCARD. Following code is working on simulator but in the phone, It's not working. How to solve my problem?
FileConnection fileConnection1=(FileConnection)Connector.open("file path");
fileConnection1.setWritable(true);
fileConnection1.delete();
You can request permissions from the person running your application but you may not forcefully set them so you need to gracefully handle your request being rejected.
The API involved is ApplicationPermissionsManager
I suggest you look at and possibly use this sample code (depending on which OS versions you are supporting) because there are a few quirks also explained at this url.
The exact permission you are looking for might be: ApplicationPermissions.PERMISSION_FILE_API
But I suggest you check the versions you are developing against for deprecation as several permissions have been retired or changed names over the years.

Resources