I am developing an app for Jailbroken iOS devices that access Safari history. History.plist file is placed at following path.
/private/var/mobile/Library/Safari/History.plist
I have successfully installed my app on jailbroken iphone by following tutorial
Use your jailbroken iPhone in Xcode for developing
When I try to access above path using fopen command of C, I can not access it. My code is below
FILE *fp = fopen("/private/var/mobile/Library/Safari/History.plist","r"); // read mode
if( fp == NULL )
{
NSLog(#"This file does not exist");
}else{
NSLog(#"This file exists");
}
It returns NULL file pointer.
I have Googled this and got to know that since my app is still in sandbox so I am not able to access above path. Couple of posts including [Why SandBox in iOS 6.1.1 still exists for App even after I have jailbreak?][2]
[2]: Why SandBox in iOS 6.1.1 still exists for App even after I have jailbreak? and [how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5][2]
[2]: how to get the message when receiving the "kCTMessageReceivedNotification" notification on IOS5 suggest that the app needs to move outside sandbox in order to access the complete file system.
I am confused about this. Can you please guide me how can I access this path?
Best Regards
Usually you will get a message in the console saying that access was denied. If the sandbox is indeed doesn't allow you to access browser history then you need to move your application outside of the sandbox. To do that you can copy your application into /Applications directory where all system apps are. You can do it using ssh, iExplorer or anything else that can access root folder of iOS device. Read this, the "The actual signing part" part. You can skip ldid stuff, you don't really need to sign anything unless you need to sign your app with entitlements.
Related
In my cordova iOS app, users can back up their data to a file which is saved in the Documents folder within the app's container, which then should be synced to iCloud. However, though the file is saved it is never synced to iCloud, so clearly I must be missing something. These are the steps I have taken:
iCloud container registered on developer.apple.com and iCloud Documents capability enabled in xcode:
NSUbiquitousContainers dictionary added to Info.plist:
Archive build created and uploaded to App Store, build released to testers via Test Flight (Note: app has already gone through review process and been released to App Store).
Note, Cordova config.xml does not contain BackupWebStorage setting so cloud backup should be enabled (not sure exactly whether this affects document sync).
User saves backup file, which is saved to app's Documents folder (Note: the app uses the cordova-plugin-file plugin to save the file to the location denoted by the plugin variable cordova.file.documentsDirectory):
At this point I would have expected to see xBrowserSync appear in Storage & iCloud usage settings, but I do not:
And neither do I see an xBrowserSync folder appear in the iCloud Drive app:
And of course I never see the files synced to my Mac or on icloud.com.
Clearly I'm missing something but I can't see what. I've read many SO posts regarding getting this working and I find Apple's documentation unclear and confusing so I'm kind of stuck at this point. Could someone please point me in the right direction?
After some further reading I believe I know what's missing here. I hadn't realised you need to explicitly tell iOS to upload a file to iCloud Document Storage, which is what will allow files to appear in iCloud Drive on the user's devices.
So, I need to write some (iOS) code that utilise the FileManager class to:
Call the url(forUbiquityContainerIdentifier:) method in order to get the location of the local iCloud container and initialise it (at which point the app will appear in Storage & iCloud usage settings)
Tell iOS to upload the file to iCloud by calling setUbiquitous(_:itemAt:destinationURL:)
I'm building a very basic Cordova plugin to do this. I'll update this answer with a link when I'm finished.
Edit:
The cordova plugin I developed is called cordova-plugin-icloud-document-storage. It currently only implements uploading documents to iCloud (i.e. setUbiquitous), it doesn't implement the other iCloud functionality of the FileManager class (such as managing cloud updates or version conflicts). If anyone would like to develop this functionality please do submit a pull request.
I am trying to get the call history programmatically on iOS 8 as an in-house app targeting jailbroken devices. This question had the solution.
Problem: Database directory has changed in iOS 8. Rather than
/var/wireless/Library/CallHistory/call_history.db
its now
/var/mobile/Library/CallHistoryDB/CallHistory.storedata
And if I use new database file on FMDB I get "permission denied". So far as I can tell its caused because sandboxed apps are logged in as "mobile" user and are not allowed to reach
/var/mobile/Library
Tried: Moving the CallHistory.storedata to old directory where call_history.db is located (as root). It works within the app that way. But I need my app to function on its own and copying files again are not permitted within app.
Is there any way I can let my app get permissions for /var/mobile/Library or any other solutions from experienced jailbreak developers?
I am working on a library with a very verbose logger module that, on iOS, writes xml logs to NSDocumentDirectory in a consistent file tree. I want to come up with a way for the user of this library to easily access these logs.
I know it is simple to programatically retrieve files from this directory, but is it possible to access this directory on an iOS physical device in any way from outside Xcode to retrieve these logs? I feel like I have seen it somewhere before, something in the manner of extracting the .ipa file and going into the package contents, but I could be wrong.
---------------------------------------------------------EDIT------------------------------------------------------------------
This (Browse the files created on a device by the IOS application I'm developing, on workstation?) is how to do it with Xcode on a device, but I have to assume that there is some way we can create that gets the logs off of a device for a user.
is it possible to access this directory on an iOS physical device in any way from outside Xcode to retrieve these logs?
It is possible to expose the Documents directory by enabling iTunes file sharing. When file sharing is enabled through this method, the contents of Documents directory would be visible to the user in iTunes, which can also be exported. The documents would also be visible for export through some third party desktop apps like iExplorer.
Here is the link to Apple documentation. You may also refer this thread to understand how this is done.
If you're using a simulator (apparently your task doesn't seem to need te real device) you are in luck.
You should go to a folder similar to this one:
/Users/[YOUR_USER_NAME]/Library/Developer/CoreSimulator/Devices/[RANDOM_HASH_YOU_SHOULD_DISCOVER]/data/Containers/Data/Application/[RANDOM_HASH_2_YOU_SHOULD_ALSO_DISCOVER]
Once there, with finder, you'll get the "documents" folder of the simulator and the app you're trying to retrieve your logs from.
You might say: I don't know which 2 RANDOM_HASHES should I go to.
Yes, you're right. If you have MANY simulators installed and or being used, it might be tricky to discover which one is the one you're trying to debug.
The same thing with your APP, your app will live in another RANDOM_HASH folder, and you should browse them, one by one, and then discover your documents folder.
Someone needed to solve this "mess" and created a Xcode Alcatraz Extension that leads you to the exact live simulator and APP you're debugging in any given moment, and then you don't need to guess which 2 random_hash paths you need to navigate to.
If Xcode + Alcartaz plugin extension manager is somewhat out of your reach, you might need to google it. It's not a difficult process.
PS: That magical Alcatraz Extension is named "XCodeWay" (in case you are brave enough to install Alcatraz onto your copy of XCode).
EDIT: Useful link to get Alcatraz: http://alcatraz.io/ Follow its easy instructions and you're done.
EDIT2: If Xcode cannot be used, then the last question in this other thread might come in handy: Browse the files created on a device by the IOS application I'm developing, on workstation?
(Still, an external application in your users machine will be needed )
How can I pull the NSUserDefaults shared preferences from the command line? This would be for a development build. I'd like to use a shell script of some sort and call it to retrieve this info. Is this possible? If so, how?
UPDATE:
I also need to get it from the unrooted device not simulator unfortunately. Its because I want to grab the APNS token and store it somewhere. I am storing the APNS token in a NSUserDefaults currently. To be clear, I have a iOS app, and I want to get the APNS token that I'm storing in NSUserDefaults using a command line script on Mac. The reason I need it from the device is I can't do push notification from simulator so I wont get APNS token unless real device registers.
update: i saw this SO article Browse the files created on a device by the IOS application I'm developing, on workstation? but i want to automate this. Anyway to pull down the container from shell using xcode command ?
If you're using the simulator you can find them in
~/Library/Developer/CoreSimulator/Devices/<dev-uuid>/data/Containers/Data/Application/<app-uuid>/Library/Preferences/<app-bundle>.plist
dev-uuid is the UUID of the simulator (you can find a list of them with xcrun simctl list)
app-uuid is the UUID for this installation of the app
app-bundle is your app bundle (i.e. com.test.testApp)
First of all, you do not need to solve this problem. Just write some code to print data to console.
If you do need to do so, here is the solution for standard user defaults (group user defaults is stored in another path, which I can not handle now).
Make sure your app is not installed via App Store.
Install iExplorer (on Mac OS or iFunbox on Windows) and plug in your device.
Open iExplorer (or iFunbox) and browser to this app. Export the whole sandbox directory to you PC.
The user defaults is stored in Library/Preferences/<app-bundle>.plist. Open it with Xcode.
I'm developing an AIR app for iPad, and I found that when I uninstall the app, the documents directory data gets erased, is there a way to keep this data even when I delete the app or this behavior is regulated by iOS and there is nothing I can do about it?.
Thanks.
No you cant
From The iOS Environment
For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.
So you delete the application all the content regarding that particular app gets deleted.
as soon app get uninstalled the document directory folder also get deleted with that. Although you will not able to access that folder from other apps so there is no need to keep that.