Is there a way that I could put my iPhone lock code into Xcode, so I wouldn't need to unlock my iPhone for every build?

It gets really frustrating that I need to physically unlock my iPhone before every build.

I know for developing on android they allow you to put the device in dev mode, which restricts the device from sleeping.

6 Answers 6


Could everyone please report this as a bug?

As it stands, you either put up with it, or much worse, turn off locking. Neither option is good.

If the iOS device is in developer mode, and connected to an active Xcode instance, Xcode should be able to keep the phone unlocked.

That way you not only can leave locking on, but it will re-lock the instant you disconnect.

  • 1
    Why would this be a bug? It's simply designed by intention. You would want someone to be able to download any app they want on your phone the chance it's stolen & "returned" as is. Clearly a security feature. Your making it sound as if turning the phone to never auto locking is such an arduous task. There are multiple options to circumvent this 'problem' however Apple can't plan for user end laziness. & yes I am a developer and very active on SO
    – soulshined
    Commented Apr 19, 2016 at 12:57
  • 1
    You first state that autolock is a good feature, and then say how easy it is to turn off. Those statements disagree with each other. Turning off autolock is generally a bad idea, but necessary during development. A feature that does this automatically while plugged into Xcode is a very good idea, preventing people from accidentally disabling the feature you say is good. Commented Apr 19, 2016 at 13:34
  • Your misinterpreting my words to suit your arguments. I never said good feature. Said security feature. And I never said easy to turn off. Stated u were exaggerating procedures to do so. Regardless, Im not a 5 year old, and dont want to treat u as one either. Im just stating my opinion & perspective. Its all about your development preferences. If u make it a habit to turn off auto lock and then make it a habit to turn it on once done it will become second nature. I just feel u over exaggerated the situation & solutions. I wouldnt call it a bug, my main argument, just a feature request. Cheers
    – soulshined
    Commented Apr 19, 2016 at 13:50
  • @soulshined, an auto-unlock feature would require the iOS device to trust the computer first (the usual trust approval that happens once), so no one can download any app onto it without your computer. Considering your computer should be password protected in the first place, I don't see how there would be any security issue. If someone has a hold of your computer and your password to it, you have much bigger issues. Further, turning off the auto-lock feature is a much bigger security issue than a trusted computer automatically unlocking a device.
    – Arda
    Commented Jan 15, 2020 at 23:54

You can prevent the device from sleeping in Settings → General → Auto-Lock → Never. This means the device will stay unlocked and you won't need to unlock it. As I'm jailbroken, I have this set automatically when my device is connected to a computer with Xcode running, but changing this setting manually will also work fine.

Alternatively, you can set Settings → Passcode → Require Passcode to a longer interval so that your passcode isn't required if you need to unlock it. Don't forget to reset this setting back to its original setting after you finish developing.

  • It seems auto-lock -> never is no longer an option in ios 9.
    – puzzl
    Commented Oct 1, 2015 at 18:36

This is a workaround trick.

In AppDelegate.swift add this code

class AppDelegate: UIApplicationDelegate {

let isDebug: Bool = {
        var isDebug = false
        func setDebug() -> Bool {
            isDebug = true
            return true
        return isDebug

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // for development only
    // to make iPhone screen always on when developing app. 
    // should be removed when app is released

    if isDebug {
        print("DEBUG MODE")
        UIApplication.shared.isIdleTimerDisabled = true

    return true

  • That only affects the phone while the app is running. If you kill the app and work on it for a while, the screen will may lock before the next time you run it. Commented Jan 6, 2020 at 18:39

As far as I know this is not possible. The only possible solution, obviously, would be to disable the iPhone's passcode during your programming sessions.


The real answer is you currently need to jailbreak to do this as @grgarside alluded to.

Use Activator (install from Cydia if you don't already have it), and set the action for Anywhere -> Connected (Power) to the action that disables the Auto-Lock. Do the opposite (enable Auto-Lock) for Disconnected (Power).

  • 1
    We shouldn't have to jailbreak to do this. Please, go to the Apple Bug Reporter and report it. If enough of us do so, they'll fix this. Commented Apr 28, 2015 at 16:49

In Xcode 7.3 it seems that you only have to unlock your device on the first build. After that, your device stays unlocked until you unplug it or exit the app you're testing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .