42

I've just updated to Xcode 9 and am getting App installation failed Could not write to the device error popup every other time. I see there are older questions on the subject, but this one is particular to iOS 11 and Xcode 9. I've never had the issue before.

Screenshot

How do I make sure Xcode 9 can install app to device every time?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
  • 2
    Deleting the DerivedData folder before every build works for me, but it's obviously very time consuming. – Steven Vandeweghe Sep 21 '17 at 07:20
  • 2
    Yes, deleting derived data solves the issue, but adds 3 minutes to the build time, and is not the solution I'm looking for. – Alex Stone Sep 22 '17 at 01:10
  • 2
    I only experience this issue when building on physical device, but not on simulator. Same for you? – David Seek Sep 29 '17 at 18:33
  • @DavidSeek Same here –  Oct 02 '17 at 09:06
  • 1
    I presume you have no solution yet? This has been happening to me since the betas. Makes you realise what a mess their source must be in that this sort of thing just gets swept under the carpet. – amergin Oct 04 '17 at 11:43
  • I get this error when trying to use a fat framework (using `lipo`). The `arm`-only version of the framework doesn't trigger this error. Solution for me was to use `odm`'s answer here: https://stackoverflow.com/questions/29634466/how-to-export-fat-cocoa-touch-framework-for-simulator-and-device – clozach Oct 05 '17 at 20:51
  • FWIW, it seems to happen a little less frequently if I stop the session before hitting Run again. – blwinters Dec 05 '17 at 16:55
  • answered down below. At the very bottom, but pay attention to everyone else comments about certs, profiles to make sure you understand the many different configurations. – Matthew Ferguson Sep 12 '18 at 04:53

19 Answers19

7

In my case this issue was caused by using App Store distribution certificate while iPad was connected wirelessly. Switching to development certificate fixed the issue.

Vlad Papko
  • 13,184
  • 4
  • 41
  • 57
  • The same story. Looks like mistakenly choosing Distribution profile instead of Dev one is the key here. In my case I was connected with wire when this happened. – Vitalii Oct 24 '17 at 11:41
  • An app signed with distribution certificate can only be distributed through test flight.It cant be installed directly. – Tibin Thomas Feb 07 '19 at 08:29
5

Xcode 9 seems to have many different manifestations of this problem. Some of the other answers address specific problems, but this definitely occurs when there is nothing wrong with your project. These steps always resolve for me (in order from least painful to most painful):

  • Try running it again. Sometimes it works on the 3rd or 4th time.
  • Unplug the device and plug it in again.
  • Restart Xcode.
  • Clean build folder (not a regular clean - this is cmd+option+shift+K or hold option in the product menu) and then rebuild.

If all else fails, once a full restart fixed it for me. But probable something else was the root cause.

Hopefully Xcode fixes these problems soon...but I'm not hopeful.

Ben Kane
  • 9,331
  • 6
  • 36
  • 58
plivesey
  • 2,337
  • 1
  • 16
  • 18
  • For me it was switching between "Could not write to device" and "no code signature found". I rebooted the phone, restarted Xcode, etc. Nothing worked. The app had been working just fine and no major changes were made. The "deep clean" (holding option when choosing clean) fixed it for me.+ – chadbag Oct 04 '18 at 19:28
2

In my case, I want to testing watchOS app and I set the debug provisioning profile to release one. I set to automatic and the issue is gone.

Bill Chan
  • 3,199
  • 36
  • 32
1

The solution that works for Could not write to the device is clicking the run button again after dismissing this error message.

In some cases I get the error App installation failed: unknown error. In this case I need to do a clean before building.

Deleting the app from device also helps.

Alex Stone
  • 46,408
  • 55
  • 231
  • 407
1

I had similar issue and got is solved using below steps :

  1. Delete app from device
  2. Disconnect device from system
  3. Restart iPhone device and Xcode
  4. Delete derived data content
  5. Clean your project (Shortcut key : cmd + shift + k)
  6. Rebuild your project
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
1

I am facing same issues on my iPad. It was working fine before. But after some time my development version stop working on iPad. I have tried and search on internet but not able to find solutions. I have tried all above cases but no Luck.

At last, I have found solutions. Some developer has changed DATE/TIME settings for my Ipad. Please check date/time because my Provisional profile for apps has expired for the manual date set on iPad.

VDPATEL
  • 416
  • 3
  • 18
1

Hope the following steps will be useful for others,

  1. Check your provisioning profile is valid.
  2. choose the debug profile for signing in target.
  3. Open you scheme under product in menu toolbar or using Cmd + < shortcut.
  4. Choose debug mode for Run in your product scheme.

Tadaa! now you can run the app in your device flawlessly.

Happy coding! :)

Maddy
  • 389
  • 3
  • 11
1

I tried all the method , they didn`t work for me .

And I fixed the problem by removing the soft link file made by ln -s

hook zou
  • 581
  • 5
  • 6
1

In my case, this issue appears when I added a folder as reference in the project which contains a symlink. Removing the symlink fixed the issue.

superm0
  • 963
  • 11
  • 19
0

Mine occurred when I had not signed in using my itunes developer portal credentials to sign into XCode. When I did it and cleared all derived data, it worked out.

amagain
  • 2,042
  • 2
  • 20
  • 36
0

Everyone is solving this problem in a different way. Mine was changing executable name, building the app (throwing the "You don't have permission etc." problem) and changing the executable name back to the original value. I don't know why but it worked.

0

I actually had to reboot the system on the Mac, this gets me rid of the problem for a good while, but it eventually comes back. None of the other solutions mentioned here worked for me.

T R Bremm
  • 161
  • 1
  • 6
0

In my case the problem appears while I use manual signing and try to debug the app in Release mode. Although the fastlane builds and uploads fine in this mode fine, direct XCode debugging fails with the error "Could not write to the device". Temp switching to automatic signing mode fixed this issue.

Igor Leonovich
  • 458
  • 4
  • 13
0

What worked for me:

  1. delete the app from iPhone

  2. clean the code in Xcode

  3. quit Xcode

  4. re-open Xcode, connect my iPhone, and run it again

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
user2066392
  • 341
  • 1
  • 2
  • 11
0

I got this issue App installation failed - Could not write to the device and I solved it by doing the below steps

  1. Uninstall the app from device.
  2. Clean the project.
  3. Run the project.

It worked for me.

Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
0

Xcode 9. iOS 11 SDK. Watch SDK 4.x.x - OPEN THE WATCH APP on the iPhone after failed. My Watch tab->(scroll down to the bottom)-> Install your app. Hope this helps. Just need permissions from the "Watch" app.

0

I had the same question that could be solved by deleting other debug App from my iPhone, then it worked.

冯剑龙
  • 569
  • 8
  • 22
-1

When I choose the Automatically manage signing, my problem fixed.Hope my answer can help you.

cz_Kim
  • 1
  • 1
-1

Sometimes the problem arises when you removing some pod file reference. The only way to solve this in also your pod-file

eg: use_frameworks!

pod 'KYDrawerController' pod 'GoogleMaps' pod 'GooglePlaces' pod 'Alamofire' pod 'Firebase' pod 'Firebase/Messaging'

remove the unwanted file in this place. And also reinstall the pod-file again and open your project it surely works for you.

  • In most of cases you have mentioned the application would not even build. The specific issue mentioned by asker happens when it builds successfully and failed to run on device. – Muhammad Nayab Jun 04 '18 at 06:39