Command /usr/sbin/chown failed with exit code 1

David Welsh picture David Welsh · Jun 11, 2013 · Viewed 9k times · Source

I know this has been covered quite a lot, but I've been googling and trying things for almost 2 days straight now with no luck from the current solutions.

I'm using XCode 4.6.2 to create a PhoneGap application, which currently builds to a device and simulator no problem. However, when I try to archive the file, I get the error message:

Command /usr/sbin/chown failed with exit code 1

It also lists every file in my www folder that I'm trying to compile as follows:

chown: /my/folder/path/appName.app/www/filename.abc: Operation not permitted

I've tried setting the "Build Active Architecture Only" to yes, for both the main project and the included PhoneGap project.

I've tried combinations of different architectures. Currently removed armv6 & armv7s. Only armv7 remains at the moment.

It seems like a permission problem, but I've gone in via the terminal and doubly made sure I have full rights to the folder. I'm using the main admin user account.

I did notice however, that when I go to the terminal and type:

sudo chown -R userName /path

I get the exact same error as xcode produces.

It's my first experience using a Mac in general, let alone xcode, so there might be something fundamental that I'm missing too.

I opened up a hello world app to try archiving it, and that worked without any problem.

I've tried the small things like cleaning and rebooting.

Thank you.

Answer

Jorre picture Jorre · May 10, 2014

This problem is caused because some of your files (the ones that throw the chmod in xcode) don't have the proper owner/group set. They probably are set with root permissions, which can be caused by installing e.g. PhoneGap modules with sudo.

Run a sudo chown -R username:staff YourAppFolder command on your original files and you will be able to archive your code again.