Importing AddressBook data into the iPhone Simulator - iphone

Is there an easy way to import AddressBook data into the iPhone Simulator?
Right now my only assumption is to manually modify the SQLite files found in the /Library/Application Support/iPhone Simulator/User/Library/AddressBook.

I was looking for the exact solution, and this worked perfectly for me on a non-jailbroken phone. It works by extracting your iPhone address book from an unencrypted backup.
Quit the iOS Simulator
Download iPhone/iPod Touch Backup Extractor
Run it, and select the last option "iOS Files"
Create a folder on your desktop and extract all files to that folder
When complete, go to your extract folder and navigate to Library/AddressBook
Copy both files (AddressBook.sqlitedb and AddressBookImages.sqlitedb) to:
~/Library/Application Support/iPhone Simulator/{SDK}/Library/AddressBook
Run the Contacts application in iOS Simulator

DummyContacts is an application that allows you to add Contacts to AddressBook and can be a handy tool for all iOS devices as well as simulators. DummyContacts is a life saver and pretty easy to setup. One click adds 100 records and one click also removes all 100. It also supports iOS6. So check it out at : https://github.com/Janak-Nirmal/DummyContacts .

Here's a simple app I've made which you can install in the simulator
https://github.com/cristianbica/CBSimulatorSeed

Just sign in to your iCloud account on the simulator and turn "Contacts on" under iCloud. All your contacts, photos etc will appear on the simulator. Obviously, this assumes you are backing up your contacts to iCloud on your iPhone. Hope it helps!

As Marc pointed in his answer https://stackoverflow.com/a/27582281/4598931 for a similar question it can be done just exporting contacts to vCard and drag and drop the generated file to iphone simulator.

or if your iPhone isn't jailbroken, you can extract the sqlite db from a backup using the shell script here: http://0xced.blogspot.com/2009/01/using-your-own-address-book-in-iphone.html
(note you'll need to change the simulator path it copies it to, as in the current SDK it's a bit different due to the addition of the OS version folder - easiest thing would be to just change it to your home directory and copy manually from there)

Right this is the only way i know with a "legit" iPhone
But if you have a jailbroken iPhone, you can download the iPhone AddressBook database with ssh, and replace the simulator one by the iphone one.

Related

Look inside Apps folder

is there a way to navigate inside the folder structure in iPad or iPhone, check what is inside of any app folder? I tried already xcode but can not identify the folders. Thanks...
You can't do it on a real device, but you can have a look on the simulator. Up until iOS 7 each iOS version maintains it's own set of apps under
Library/Application Support/iPhone Simulator/7.1/Applications/
followed by a cryptic number representing your app. Replace 7.1 with another iOS version. To display the Library folder in Finder, click Go from the Finder menu while holding down Option.
Since iOS 8 those locations have moved and are harder to find. See here: http://pinkstone.co.uk/where-is-the-documents-directory-for-the-ios-8-simulator/
Yes, you can use programs like "iExplorer" which let you navigate your device even without jailbroken devices. I often use it to check that my app is correctly creating files according to my coded file structure.
You can see only contents of Documents Directory on Simulator or device. If you want to see documents directory in device then you have to set UIFileSharingEnabled key to YES in your application's Info.plist file. Then you can see it via iTunes app in Mac os x.
There is not way to see bundle contents in application. Just you can see bundle contents in xcode.
Regards.

Is it possible to view data stored in Core Data on a development iphone?

Is there a way to grab/view the coredata db (sqlite store) off of the development iphone through xcode or some other means? While I've been able to inspect the db created through the simulator on my mac, I'd like to validate what's on the actual phone (without having to create debugging views in the app, etc.) as i'm reading sensor data and storing it in coredata.
Yes you can using Xcode organizer.
Select you phone, then app, and you can export and import files from/to the sandbox
http://developer.apple.com/library/ios/recipes/xcode_help-devices_organizer/articles/copy_app_data_from_sandbox.html#//apple_ref/doc/uid/TP40010392-CH14-SW1
I'm not sure if there is an official way to do this but I use a piece of software called iExplorer formerly iPhone Explorer. http://www.macroplant.com/iexplorer/
You can then browse the Apps directory similar to the simulator and find your app and goto the documents directory and grab the sqlite file.
Hope this helps

Not loading all content of ipa file into device while using itunes

i developed an app which is meant to read books(pdf book reader).i loaded 25 books(total size of 320MB) into the app using absolute path.all the books are been seen in the simulator and also i can load all the books into my device through xcode(build and run).
my requirement:
when i loaded the above obtained ipa file into the same device or other device which are in ad-hoc distribution using itunes , it is strange that only few books are being seen in the device.
note: i made sure that all the books are present in the .ipa file,i deleted old app in the device which i run via xcode. the device is in ad-hoc distribution.
while code signing i used the iphone developer certificate.
is it necessary to use distribution certificate instead iphone developer certificate which i feel that might be one reason for my problem?
plz anyone suggest me with exact solution to the scenario.
tnx in advance
I know I have seen problems going from simulator to live device. The simulator is not case sensitive, but the device is. Recheck all your actual files in bundle vs what you are requesting when you open the file. They need to match exactly for device, but not so much for simulator.
I would also try seting the apps-Info.plst to have "Application supports iTunes file sharing" on so you could see what is in the documents folder (this is if your moving files in that area).
One problem might be as RAZ suggested that iPhone is case sensitive, but there could be other problems.
For starters I would check the that ipa does contain everything you think should be there. Take the ipa, change the extension to zip and open it. You'll get a folder containing you're app. Right click the .app and choose show package. You'll now see all the files/resources included in your app. If the files that won't load in the app are there then you'll need to provide more information about the problem.
If they're not you need to make sure xCode knows to copy them to the app resources.
You might have resources that you haven't copied into the project, and you're only referencing the files on your hard disk. Then when you make the .ipa file it's not included. Try re-importing all your resources and select "copy to project".

iOS Question. Can I distribute the Xcode simulator versions of my app?

I would like to send someone the Xcode simulator version - not the device version - of my iPad app. I have located the .app file in the Finder. Do I just zip it up and send it off or is it more complicated than that?
Thanks,
Doug
UPDATE
Chrisbtoo got the answer on this one however he left of some critical bits for those of you trying this at home:
Path to Xcode simulator (the simulator can be run standalone.):
/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app
Path to app that appears in the home screen of the simulator:
/Users/turner/Library/Application Support/iPhone Simulator/3.2/Applications/{GUID}
It is instructive to watch what happens in the app simulator directory as you build for simulation, delete apps from the simulator desktop and generally use the simulator as an actual device.
Bottom line: This is a viable approach for sharing apps in a "simulated" ad hoc manner without the mind numbing, soul sucking process of true ad hoc app sharing.
Cheers,
Doug
Assuming the other person already has the simulator installed, you can just zip up the stuff under ~/Library/Application Support/iPhone Simulator/3.2/Applications/{GUID} (includes both the .app and any data directories needed) and send it to them - they'll need to unzip it under that same directory. What I've done in the past was to rename the {GUID} part to a more friendly name - the sim will still pick it up.
If they don't already have the simulator, they will need to sign up for a free iphone dev account and download Xcode, etc.
We just put up a little tool that will help you with this. It manages both what you need on the dev side and also the tester.
Here it is
http://blog.placeit.net/ios-app-packager/
It basically creates a little zip that you can pass to the tester and it'll install the app in the right directory and also open it up for the user with the right device selected.
I would think you want to send the entire project folder to the other person- presumably you are expecting them to open it in their XCode- and presumably they have the sdk for the app.
You have to distribute via AdHoc or App Store for beta testing.
Become a developer and then look into how to do this.
You need to have a provisioning profile, and then select the UDID's for the device you want to beta test to.
Go to the iPhone Provisioning Portal
and here is a document with more detail

Reading a file from a hard drive in iPhone simulator

Is it possible to read a file (from my normal file system) into a iPhone App running on the iPhone Simulator?
I understand that the iPhone itself has not got a (user accessible) file system but this is simply for testing and will only ever be run in the simulator.
The file will be a text file that can be edited while the application is running, it will be read every-time a method is called.
Yes, you can, and it doesn't matter where it is. Just give it an absolute path name when you load it (Xcode won't recognize a different working directory when running the simulator).
Yes, you can if your file is within your app folder
~/Library/Application Support/iPhone Simulator/User/Applications/ [your app folder] /Documents
No. Your app is running in its own sandbox on the phone. It's not allowed to read or write outside of it.
Edit: I think CiNN is correct. As long as your code stays on the simulator, you shouldn't have problems working with a file on your local drive.
I personally think that the easiest way would be to enter "file:///" in Safari within the simulator, if thats what your looking for.
It should also be noted that you can do this in reverse -- you can grab the files off your hard drive that your application created in the simulator. This is a good way to check out your results (data, images, whatever) without having to build a data "viewer" into the application.
FYI 'newer' sds versions will do this... Search for iPad and you will find it. (for obvious reasons I cannot give more details here) good luck.