应用程序安装失败: 无法写入设备

在 Xcode 6.3中,当我试图在真正的设备上运行用 Swift 编写的 iOS 项目时,出现了这个错误。

应用程序安装失败

无法写入设备。

我尝试清理项目并再次运行,但是同样的错误发生了。

我如何修复这个错误?

59166 次浏览

OK, few things you should consider that could guide us to the problem, please check and post the answers:

  1. is your project using capabilities? are they set correctly (should be all green)
  2. did you try with a different project (something really simple)?
  3. are you able to install apps from the App Store?
  4. did you check the amount of free space left in the device?

if not, another suggestion will be using exception breakpoint, there is someone that posted an explanation how to setup it, do it and post the logs

App installation failed

I hope it helps you

I turned off the device and turned it on again after which I did not get such error.

I was having the same error, i just deleted the project and fixed!

Go to Window -> Project and right click, and remove from projects!

I did a Clean and installed my app successfully.

Product->Clean(Shift-Cmd-K)

I had a symlink in my project to a file outside of the project. When I deleted this symlink the install worked fine.

in my project this problem happened because there was a folder with symbolic link. I removed that folder and it worked properly.

Got this problem twice in one week on complete different devices.

One device had no more storage left, after deleting some apps the project installed perfectly.

The other device was fixed after rebooting the device

Deleting the app on the device and running the project again works for me.

Get rid of embedded libraries, dont' just throw it in there make sure it is embedded indeed.

If you use your iPhone for debug, maybe, because your iPhone's storage space is less than your debug App.
Clean your iPhone --- Real machine
Clean your Mac --- Simulator

Also this the error shown if your machine running Xcode is low on space.

In the case of your device have an app with the same bundle identifier, Xcode will throw this error. Try to delete potential app with the same bundle identifier.

For me the following did not work on iOS 11 beta 10, XCode 9 beta 6:

  • Restart the device
  • Deleting the app from the device
  • No symlinks were in the project
  • There was plenty of storage available

Deleted Derived Data and voilá, it worked again

This looks like another time waster courtesy of Apple's amazingly high class development team. On iOS11 Xcode9 (pick your beta, any one works) this will happen randomly. Appears to be more frequent if you dare to switch apps while compiling. Just build again and stare at xcode - it'll work the second time without fail in my experience.

Once I had to load an App Container for debugging purposes into an iPad, said operation failed because the container was too big (18 GB) for this device (16 GB minus the OS), so that I desisted the task and completly forgot about it, leaving the failed installation in the device. Later, when trying to install a different application this error appeared, once I got rid of the failed app installation, everything got back to normal. Basically, your Ipad might be low in storage.

My issue was an embedded framework.

Go to "Build Phases" -> "Embed Frameworks" -> Check "Copy only when installing", and it got rid of the issue for me.

enter image description here

If you got a message while you Running iOS Application in Xcode 9 as "Could not receive a message from the device."

Using 3 Steps you can resolved this problem:

1.Select the Project

2.Clean the Project

3.Run the Project

Check your provision profile, maybe you are using the app store provision profile like me. I had to change the app store provision profile to development, now it's working.

If you are using a free developer account you may need to uninstall some other apps you have signed.

Apparently this message can also appear if the system clock of device where the app is being installed is too far away from the current time.

I was doing some tests with date formatters by changing my iPhone's system clock and eventually forgot to reset it to the current time. Afterwards it always displayed the same message ("could not write to the device.") whenever I attempted to run the app. Simply resetting the clock in Settings fixed the issue.

For me it was the provisioning profile - I used distribution instead of development

One reason this can happen is if your app bundle contains broken symlinks.

Tried all of the above answers: Deleting the app, clearing storage space, cleaning the project...

What finally worked was bumping the build number in info.plist (General > Build)

remove all certificates from keychain tickon automatic xcode manage profile,

Restart Device

Delete derived data

clean

Run

This error has many potential root causes, as can be seen by the large variety of suggested answers. The best approach to troubleshooting app installation issues like this one is usually to inspect the console of the iOS device itself, as that'll often provide much more specific error messages. In Xcode open the 'Devices and Simulators' window and take a peek at the logs of the device where your app is being installed.

In my case, the "Could not write to the device" error was being caused by this:

Feb 27 10:54:58 iPhone-7-110 installd(MobileSystemServices)[46] : 0x16f92f000 -[MIBundle _validateWithError:]: 38: Failed to load Info.plist from bundle at path /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.ebmR6U/extracted/SampleApp.app/Frameworks/SomeFramework.framework

Which clearly hints at what's actually going on. I had forgotten to set an Info.plist file for my dynamic framework target (used by the app).

Nothing helped me. I followed the below steps,

  1. Clean derived data folder
  2. Quit Xcode and disconnect device
  3. Restart Macbook
  4. Restart Device
  5. Open Xcode
  6. Clean and run the project

Finally I got it working!!

I am facing same issue then solved out follow this step and now its working.

  1. Deleting the app from the device
  2. Try to install another application
  3. Remove derived data in X-code.
  4. Restart X-Code then clean and build the project then run.

It's still not working then

  1. Remove un-used application
  2. Restart the device and check the Available and capacity in settings
  3. Again app run in device

I hope its worked, enjoy it.

My problem was I had initially installed the app using a different set of developer credentials on the device. Deleting the app from the device fixed it.

Check the device date, my device time was set to a future date so I was facing this issue.

Maybe it can be due to the following error App installation failed. No code signature found. In my case after a project clean the description of the error switched to "No code signature found".

For anyone still facing this Issue:

There are so many reasons and this is one of them as it happened to me.

I've faced the same problem and I was connected wirelessly and If you are trying to install the application in wireless connecting mode (connected through same network), this might probably because of poor internet connection. Check your internet connection and try again, it works fine...

In my case I created two frameworks but they had the same bundle identifier.

This caused the installation to fail, so double check the frameworks bundle identifiers and make sure that each of them have a unique bundle identifier.

Environment: Xcode 10

sometime this error occurs due to wrong certificate.Please make sure your certificate.