Unlock iPhone for different carrier
Solution 1:
The only way to do this in a supported way without jailbreaking the phone is to have O2 do it. There's simply no other way. They have to send a carrier update to the phone which unlocks it.
If you want it done faster, I would recommend returning the phone if you can and purchase an unlocked one straight from Apple.
I don't know how UK law works, but in the US, carriers are required to unlock your phone if you have no financial obligation to them for the device. Any phone you buy directly from Apple won't have any kind of carrier lock on it.
Solution 2:
This depends heavily on which version of iOS it's running, and what the lowest version it's capable of running is. Back in older versions of iOS (I believe up to iOS7) there was a program called "UltraSn0w" that would do exactly what you need. I have not jailbroken a device newer than iOS7, so I cannot say with certainty, but I believe most available jailbreaks on newer iOS versions are rootless, meaning the user is no longer granted superuser privileges by jailbreaking, thus you wont be able to modify the system to perform an unlock with a rootless jailbreak. With that said it is entirely possible that there are still normal rooted jailbreaking programmes available, I simply don't have experience with them.
If you do choose to jailbreak your iPhone I highly recommend a rooted jailbreak if possible. Contrary to popular belief rooted jailreaking your device is not actually dangerous (at least, not any more dangerous than knowing the administrator account's password on a Mac.). All jailbreaking a device actually does is install the program su
, or "SuperUser", as well as install the package manager dpkg
.
su
is preinstalled on all standard copies of Unix, from macOS, to Ubuntu, to good old System III, and is basically just a program for performing administrative tasks like changing the system clock's date, setting the machine to run a program during startup, installing new software, etc. On iPhones, iPods, iPads, and Apple TVs the user can't run the su
program, and is thus unable to do any of the above things without using an Apple app to do it (i.e. the App Store for installing new software, the Setting.app for changing the date, etc.).
When you jailbreak an iDevice, half of the whole process is your jailbreaking program of choice installing a second copy of the su
program in a part of the device's storage that the user can access with normal apps, allowing them to administrate their device manually. While this could potentially be dangerous on it's own, all the access to the su
program is handled through Cydia.app
, which brings me to the second half of a jailbreak.
dpkg
and Cydia.app
are both installed during a jailbreak as well, dpkg
is the package manager used by many different versions of Unix, including Debian, and can also be installed on macOS, iOS, tvOS, FreeBSD, and most versions of Linux. dpkg
is essentially just for installing and removing software, and gets installed so that the user can install apps from downloaded .deb
, .dpkg
, and .pkg
files, along with the normal .ipa
files used by the App Store, the same way a user can install .pkg
and .app
files manually on macOS.
Cydia.app
is basically an alternate version of the App Store that lets you install Linux, command-line, and system software, rather than just Apps. Such software includes, but is not limited to, extra panels in Settings.app
, software that changes the way the SpringBoard (home screen & multitasker) look and work, and Apps that can do things like browse, move, and edit the files on the device how one would with Finder on macOS.
As a result of this process the user can install (or uninstall) most any system software they want, including software that restricts the device to a specific carrier. In order to do this you would either need to find a piece of software for jailbroken iDevices that removes the carrier restriction, or find a way to manually uninstall the software that locks you to its current carrier.
TL;DR It's definitely possible to unlock your iDevice with a jailbreak, but you have to make sure it's a rooted jailbreak (rootless jailbreak wont work), and you'll have to find a program that can be downloaded from Cydia that removes the carrier restriction for you. I believe there is a newer version of the aforementioned UltraSn0w that can do this on newer versions of iOS, but you should definitely look around and make sure such a program exists before jailbreaking the phone, assuming a carrier unlock is your only reason for jailbreaking.