Can a jailbreak survive installation of a new IPSW? - objective-c

I have a phenomenon here on an iPad 1. It was running 4.3.2 and a jailbreak was applied to it.
Later it has been updated to 4.3.5 which it is still running.
I wrote a little test app to see if I can detect a jailbroken device. The tests I use are:
Use [NSFileManager fileExists] to check if /private/var/lib/apt exists
Use [NSFileManager fileExists] to check if /Applications/Cydia.app exists
The idea is: on a device that is not jailbroken, access will fail in both cases as the app cannot reach out of its sandbox. If either test returns YES, I assume a jailbreak. I tested this on a couple of unbroken devices and neither can be accessed. I also tested on a jailbroken iPhone 3GS and both can be accessed.
The I tried the iPad 1 with 4.3.5 and there is no Cydia installed, so the 2nd check obviously failed but the first one passed! fileExists returns YES for "/private/var/lib/apt"! How is that possible? Can anybody explain?

I can't completely explain this but I've come across similar results.
I used to have a jailbroken iPod on iOS 3 and updated it to iOS 4, after jailbreaking again my settings in Cydia were still present.
When installing a new firmware iTunes still shows ~500Mb of other data, so I'm assuming not everything gets overwritten / deleted during the update.

Actually, let me explain why and how this works:
The iPhone/any iOS device has 2 separate partitions:
/dev/disk0s1 mounted at / (around 1GB), the root partition:
It contains the OS (/System, /Applications, /usr, /sbin, /dev, /Library) and is by default mounted read-only.
/dev/disk0s2 mounted at /private/var (rest of the space), the user partition:
It contains all user data (in /private/var/mobile/) like:
Applications, Preferences
Nowadays, all jailbreak tools move all Applications, etc. from the root partition into /private/var/stash to save space on the Root partition. These are then symlinked back from their original location.
When running an iOS update, the user partition is left mostly untouched, only the root filesystem is restored. Only if you run a full restore, everything is deleted. iOS will then recreate the /private/var filesystem on the fly.
But please refrain from using this kind of code, since not all of the people who have jailbroken their iOS devices are pirating apps, and you putting such code into your app will only tempt script kiddies to crack it again.

Related

Testing Mac App Store app on real device - How to export?

I have been developing Mac App Store and iOS apps for several years now. I don't event want to know how many hours, days or weeks (?) I spend by solving provisioning problems...
One of my Mac apps targets OS X 10.7+. While everything works fine in genereal, after the last update some users reported problems when using the app on 10.7. Other OS X version work fine.
In the past, I simply cloned the project from my developing computer (iMac) to my MacBook running the specific OS X version. I then opened the project in Xcode, ran it and check what the problem was. This is far to easy for Apple, since this not possible any more.
The project only compiles (due to several reasons) in Xcode 7+ only. Xcode 7 runs on 10.10+, thus testing on 10.7 is not possible.
I have been trying to build/export the app to test it on my MacBook the whole day without any success. The app simply does not start on 10.7 on my MacBook. Of course the MacBook is a registered devices, included in my provisioning profiles, etc.
This is my workflow:
Removed all App Store specific entitlements from the app in Xcode/Target/Capabilities
Created new wildcard certificates and provisioning profiles that does not include any App Store specific entitlements
Selected the new profiles in Xcode/Target/Build Settings/Code Signing
Run Product/Archive
In Organizer select the Archive and click on Export
Here I tried several different combination (signing, no signing, etc.). No matter if I choose Export a Developer-Signed Application or Export as a Mac Application the result is always the same.
When I copy the created App file to my MacBook und start it nothing happens. The icon flashes once and this is all. Only the Console gives I hint about the Problem:
killed com.mycompany.myapp because its use of the com.apple.developer.team-identifier entitlement is not allowed.
Great... As explained I removed all entitlement from the app and from the profiles. Where the hack does this entitlement come from and how do I get rid of it?
Is there no way to test the App with all its features (== all entitlement) on another device?
I should have answered my own question earlier. Back in January I was somehow able to get the app running on my other Mac. Now I had to solve the same problem and it took some time to dig out the correct solution again.
So, maybe this will help others to solve the same problem. At least it will help my future-me to remember what has to be done :-)
Archive the app just as you would prepare the app to be submitted to the App Store.
Switch to the Organizer and select the just created archive
Select Export... instead of Upload to App Store...
Select Export a Developer ID-signed Application(second option). DO NOT select Export a Development-signed Application (third option). Actually I have no idea what's the difference is, but only the first one works...)
Click Next and the Organzier will fetch provisioning information from your dev account. DO NOT select the fetched provisioning profile but select Use local signing assets from the dropdown box instead
Click Choose and Export in the next step.
Done
Good luck and happy app signing...

Could not launch iOS app

I don't know what has happened to my Xcode, but since I deleted my app from the device, and tried to rerun it on my iPhone, I get this message coming from the top of the screen:
No such file or directory (/Users/spazm/Library/Developer/Xcode/DerivedData/newProject-cfjhjgezzcapwoadaivpptyywptu/Build/Products/Debug-iphoneos/proj.app/proj)
In addition, where you can select the "active scheme" (iPhone / iPhone Simulator / iPad Simulator), I used to have "iOS device", and right after plugging my device in, I would get my phone's name and everything would go sweet.
Now, I only see "iOS device" (after plugging in), and I need to select my phone manually, which seems like something went wrong here. I am not sure what.
In the xcode organizer delete "derived data"
Alternatively you can open "~/Library/Developer/Xcode/DerivedData" folder and delete derived data folders associated with your application. You also should make a clean/build.
For the second problem, again in the organizer window under devices find your device and click "use for development"
Edit: Today I have experienced again, deleting derived data did not solved the error this time. After deleting data, making a clean build, deleting the app from my device, I needed to close & reopen xcode, which finally fixed the error.
The problem was in the project file itself. Used my backup to load the old project, then manually added all the files from the bad-new-project.
Must have been some setting.
Try checking the Deployment Target for the app. I was getting this same error when trying to deploy an app that required iOS 6.0 to a device that had 5.1 installed.

Testing iOS app archive and keeping existing sqlite database already in use during development

following this link
Testing Workflow with Xcode's Archive feature
I am trying to build and test an iOS app archive.
The application, previously built and developed on iOS devices by means of Xcode, has a Core Data DB that has been filled during development and put in iCloud few months ago.
I would like to develop the archive by keeping the existing DB, however as it is stated in the instruction this seems not possible:
3) Delete any builds of the app from your device
and if I am not wrong, deleting the app by device means also delete sqlite file.
I know there's iCloud, but I am not sure the whole sqlite transaction log files are still available.
Do you have any solution or workaround for that ?
It is possible to preserve the data of an app separately from the app itself by using Xcode Organizer.
On the devices tab on the left under your device there are several categories. Among Screenshots and Device Logs there is also Applications. The on the main window you can select your application and below Upload and Download actions for application data are available.
So you can save your data any time and later restore it for testing purposes.

Am I using Core Location correctly? It doesn't seem to be working

I just started doing some research into Core Location and it seems that the tutorials that I am following are not working for me. Even when I download the source code and run it, nothing happens. At present I have attempted this tutorial. When I run it, I get a popup asking if I want iPhone to use my current location. I press ok, and then nothing happens. Am I supposed to do anything else?
I am also using VMWare, and currently am unsure if this is the cause (although my internet connection works perfectly on it). I'm using base sdk ios 4.3 - running simulator.
In order for location to work, you need to be running the code on an actual device. The latest public iOS SDKs don't yet support location changes in the simulator. The simulator will always return 1 Infinite Loop, Cupertino, CA (Apple's headquarters) as the location.
See the Core Location documentation for more information on using location in your apps. (Although I can't find a citation for the limitation of the simulator at the moment.)
CoreLocation within the simulator is always going to return 1, Infinite Loop, Cupertino, CA, although Xcode 4.1 and iOS 5 have improved support for testing CoreLocation capabilities in the simulator.
iOS5 iPhone simulator supports location simulation.
If you are using 4.3, it does support location in some conditions. I notice that when I am tethering using my iPhone, my iPhone simulator is able to get location from my phone. I can see location update in my simulator when I'm working while commuting in a train. But this update is only through core location. Map gives u Cupertino unless u use iOS5

iPhone simulator: Is it possible to restore a real iPhone backup to it?

as the question says, I have a backup of an actual iPhone. Now I want a "copy" of the content in my simulator. The reason is that my real iPhone contains third party application data that I want to have in my simulator too.
Is that possible?
Thanks,
Norbert
Definitely not possible, because apps have to be compiled specifically to run on the simulator and iPhone, and such builds are not compatible with each other as they are built to run on different processors.
Edit to add: you can copy data/content (and you can, for Apple-supplied apps like the Address Book that are provided by Apple for the simulator) but unless you have a version of the app compiled for the simulator that can run, the content is obviously no use.
You can try to trick the Simulator by putting files there:
~/Library/Application Support/iOS Simulator
You can also put the files you need in your application project or have a look at Apple Documentation about Application Data1