Xcode 9: Could not attach to pid - ios

I've been facing an issue (frequently) with the recent major release of the iOS application development tool - Xcode 9-beta.
It's showing me the following error frequently while running/debugging app in Simulator (iOS 11).
Could not attach to pid : “2370”
Ensure <project title> is not already running, and <system username> has permission to debug it.
Here is a snapshot for the same issue:
What would be permanent solution of this issue, as it's disturbing frequently?

If issue is on OS Mojave and you are trying, like me to run tests on older Xcode version (lower than 10.0), make sure that in your scheme, when you select Test, Debug executable is disabled
You won't be able to debug tests from this point

Still not a permanent solution, but I had to quit and restart Xcode as the other solutions did not work for me.

This worked for me:
Edit Scheme -> Info -> Executable -> Ask on launch
Credits to #nastya-gorban's answer here
Update
After spending a considerable time with examples on Apple bug report, they basically disregarded the issue as using manual certificates is not "expected".
Long story short, if you don't have a business account and hence multiple developers on the same account, you should be fine with using the automatic signing and should not see the issue.
If you do have a business account with multiple users (which I found it breaks automatic signing), this is their suggestion:
We suggest that you use automatic signing for your debug builds and
manual signing for your distribution builds.

Killing my simulator and then running it again from Xcode.

I had this issue too. There seems to be an issue with having two Xcode version installed at the same time. (9.4.1 and 10.0 Beta)
It works with the beta, but not with the stable version. Everything is set to the tools of the Xcode 9.4.1 stable version. I can only run my unit tests with the beta.
After removing the beta, it worked with the stable version.

delete derived data and clean the project, wait until processing is complete, this may take some time. The idea is to give some processing time. Works fine after that

I have been dealing with this issue for days. I have been able to build but not launch on Simulator, and I get the same "pid:.." error message.
I am using:
- Xcode v9.2
- Swift 3.2
- Building for iOS
The things that I tried that DID NOT WORK were:
restarting the computer; deleting content and settings (of Simulator, I do not have "reset"); uninstalling and reinstalling Xcode; changing "Deployment Target"; changing the device in the simulator's Hardware->Manage Device; deleting Derived Data, Cleaning and Building, or just waiting...forever.
What WORKED was as #Rajasekhar mentioned:
checked out the Keychain certificates.
deleted the exiting ones by right clicking (they'd passed expiration)
and unchecked "automatically manage signing" in Targets->General
After that it successfully launched in Simulator. I don't know if the issue will come back but hopefully this works.

Even on Xcode 11.1/2/3
It is an Authorization issue with Simulator,
When Simulator does not have the necessary access. It raises the issue.
Try following in Terminal
sudo DevToolsSecurity -enable
or
sudo /usr/sbin/DevToolsSecurity -enable
Details can be found here

I hate to add more noise to this, but for me, the answer is to, nonsensically, use sudo.
Run normally, Xcode 9.4.1 (9F2000) and Xcode 10.0 beta 4 (10L213o) both failed to attach to my app after multiple tries, giving the error quoted in the original post.
What worked was to run Xcode (9.4) with sudo,
sudo /Applications/Xcode.app/Contents/MacOS/Xcode
I don't see why sudo is necessary. The Cocoa app to which I am attaching is a Debug build that I just built in Xcode 9.4.1 and dragged into /Applications. It is not codesigned. Posix permissions on the .app, its Contents, its MacOS, and the executable are all octal 755. Owner is me. It works fine if I leave it in the Build folder, build and debug in the normal way.
The problem is apparently with lldb. I also tried using lldb (lldb-902.0.79.7) from the command line. I got the same result. It works only with sudo. Without sudo,
error: attach failed: unable to attach

I had same issue. Check screenshot.
Below are few solutions that should work:
Rerun project
Clean (Shortcut: cmd + shift + K) and Rerun project
Quit Xcode and Simulator. Open project and run again
Reset content of Simulator (Select Simulator -> Goto Hardware tab -> Erase All Content and Settings…) and rerun project.
Solution 4 worked for me.

This seems to be a temporary issue when you are trying to build too fast after a build has started. Try stopping and running the project again.

(most likely solution) 1. Simulator-> Hardware-> Erase all contents and Settings
(less likely solution) 2. keychain-> upper right lock-> unlock and lock again (or the other way around)

I was seeing this in Xcode 10.2 and the cause for me was that lldb-rpc-server was crashing. I worked around it by ensuring either Address Sanitizer or Thread Sanitizer is enabled in the debug options. I also filed a bug report viewable on Open Radar.

I tried all the answers above. The only thing worked to me is changing the build number.

In my case (Xcode 10.1), this was the error in the console:
kernel macOSTaskPolicy: (com.apple.debugserver) may not get the taskport of (bin) (pid: 10132): (bin) is hardened, (bin) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger
So the solution was to disable the Hardened Runtime, clean the build folder and run again.

This is the issue with the untrusted certificates in key-chain access, please remove such a type of certificates and re-build again.

This happens on my machine, when I set the 'new build system'
Go to menu file=>workspace settings and set Build System to "Standard".

I realise this is not a problem with a single solution, from all the other answers. So, here's what worked for me:
1) Reboot the machine
2) The first run always works for me. The only thing that helps me avoid this error after this first run, is to stop the application from XCode, instead of just clicking the Run button to re-run the application.
Another thing, when I lock my computer the issue re-appears sometimes (probably when I forget to stop the application). So I have to reboot my machine again.

After doing some digging, this worked for me on Xcode 10.3.
sudo /usr/sbin/DevToolsSecurity -enable

In my case the only thing that worked was switching back from the "New Build System" to the "Legacy Build System" in the Workspace Settings. Bummer.

It's an issue with authorization. Try this in the Terminal:
sudo DevToolsSecurity -enable

First, close app completely via sim (not sleep - close app totally)
If not working yet: reboot whole PC, ensure only 1 simulator is active upon reboot.
More than 1 sim can confuse it if it's bugging.

Related

Xcode 9 - Could not attach to pid for Frameworks unit tests

I am getting the following error after migrating from one mac to another using time machine.
Could not attach to pid
Ensure "project title" is not already running,
and "system username" has permission to debug it.
The error occurs only when running the unit tests for (any) Framework project. Running an application on simulator and device works fine.
Running unit tests for an application works, but running it for any framework can't be launched due to this error. I am getting this error even with Alamofire or PromiseKit unit tests.
I tested the solutions suggested on similar questions on Stackoverflow (I deleted derived data, cleaned everything, reinstalled Xcode, restarted the mac ..) nothing solved the issue till now.
I am using Xcode 9.3 and tested this with Xcode 9.4-beta also.
I am running on Mac OS High Sierra - 10.13.4 (17E199)
Any help / suggestion is welcome!
After opening a bug report to Apple, they suggested me to:
Check if my user is an Admin user. It was the case.
Check if I have "_developer" group, in the output of groups command. it was the case. Use this command: dscacheutil -q group
Check developer mode rights using the command sudo /usr/sbin/DevToolsSecurity -status. The status was unknown for me.
Enable developer mode rights if needed, using the command sudo /usr/sbin/DevToolsSecurity -enable. This solved finally my issue!
If you have Mojave OS then:
1) Open your target scheme
2) Uncheck this one
3) Select this scheme while testing this target (ex. Testing "TestApiTarget" - select "TestApiTarget" in schemes on tests).
Its temporary solution from bug report
I was able to resolve this issue by:
adding Single View App target (I named it HostApp)
setting HostApp target as a host application for test target
You can try some following steps -
Open the keyChain and check the Keychain certificates and delete the existing ones which are expired.
Uncheck the - automatically manage sign in from Xcode project settings.
Delete any derived data
Clean the project by cmd+k
Then Close and Restart the project and Run...
I hope it will work.
You can do this following steps -
Kill your simulator and then run it again from Xcode.
If you are trying to build too fast after a build has started. Try
stopping and running the project again.
This can be a issue with the untrusted certificates in key-chain access, please remove such a type of certificates and re-build again.
Finally, you can do is recheck the Keychain certificates. Delete the exiting ones by right clicking (they'd passed expiration)
and unchecked "automatically manage signing" in Targets->General
Hope above steps will solve your problem.
Haven't seen this exact error, but I've found removing the derived data helps fix some transient errors that pop up after updates etc.
You can find the location of your derived data folder in Xcode.
Open preferences/locations and click the arrow.
Once in derived data you can remove all the folders.
FYI after deleting the derived data folder all your projects will need to be rebuilt.
Hope this helps!

Simulator not working and showing the error message "Unable to boot the iOS Simulator" [duplicate]

I recently installed the beta of Xcode Version 6 in OS X Mavericks, with which comes the iOS simulator for iOS 8. I've managed to successfully run from Xcode 6 beta on a device with iOS 8 Beta, but opening the simulator always get the same error I have tried to change the hardware version of iPhone 4s, iPhone 5, ... in the simulator and still gives the same error: "Unable to boot the iOS Simulator".
I'm working with Xcode 5.1 at the same time in Mavericks, any suggestion to solve this? Is a possible problem for run this simulator in Mavericks because is only for OS X 10.10? Thanks.
After I found some solutions on the web, a combination of procedures worked for me:
Close Xcode and iOS Simulator (and all related applications)
Install (or reinstall) Xcode6-Beta to Applications folder (direct from the .dmg file)
Open Xcode6-Beta and go to Xcode -> Preferences -> Locations -> Command Line Tools and select "Xcode 6.0" (be sure that you've selected the one in Applications folder)
Launch the iOS Simulator and go to iOS Simulator -> Reset Content and Settings...
Close all the applications and restart your mac (I unchecked "Reopen windows...")
Open Xcode6-beta and test the iOS Simulator
Good luck
I also had this problem and found the solution by doing following steps:
Initially i downloaded Xcode 6 library in Documentation section under the path Xcode --> Preferences --> Downloads and restart my xcode but didn't solve my problem.
Downloaded and installed the iOS 7.1 Simulator under the path Xcode --> Preferences --> Downloads.
Restart xcode again and the problem solved.
I am facing same issue again next morning.
Unsetting the DYLD_INSERT_LIBRARIES variable solves my problem:-
Open terminal and type "sudo vi /etc/launchd.conf" command and press Enter
Press I "Insert" mode and change this
"setenv DYLD_INSERT_LIBRARIES /usr/lib/libimckit.dylib"
to this
"unsetenv DYLD_INSERT_LIBRARIES /usr/lib/libimckit.dylib"
and press esc to exit from insert mode.
Save changes by typing ":wq" Press Enter
Reboot your system and problem soloved.
Prior to that I didn't find any iOS version in front of each listed devices
but after installation or by unsetting DYLD_INSERT_LIBRARIES variable I found the same in front of each device.
I solved by removing and re-adding the simulators see screenshots here.
https://stackoverflow.com/a/25387715/1565615
I don't believe your issue is related to running Xcode 6 in Mavericks, as I encountered the same error on OS X 10.10.
After a bit of toying around with XCode and the iOS Simulator, the only fix I found was simply restarting the computer, and the error hasn't appeared since.
Try a reboot and then see if you can get things up and running.
(On a side note, after restarting just XCode (not the OS), I lost the option to run on the simulator at all—the reboot also fixed this problem, if anyone here encounters anything similar).
In Xcode go to the Xcode menu->Open Developer Tool - IOS Simulators. Choose simulator and then go hardware->device->manage device.
If the troubled device shows in the left column, delete it. Then add the device back from the '+' button. If it wasn't there in the first place, simply add it using the '+' button.
I had previously deleted ~/Library/Developer/CoreSimulator/ directory and the only command that worked for me is xcrun simctl erase all. Perhaps you might want to give this a try.
No need to download a new ios version. All you need is to go to About this Mac > Storage > Manage > Delete XCode Cache. And, it works for me
In latest OS version
About this Mac > Storage > Manage > Developer > select Xcode cache > Click delete button
I've faced same issue and solved by below steps:
1) Move xcode6-beta into application folder
2) Restart mac and open xcode6-beta from application folder.
i too had the same issue, but solved by installing the required simulators (Xcode > Preferences> downloads > install simulators)
This happened to me running the simulator on both Xcode 7 and 8 on El Capitan. The only thing that worked was disabling System Integrity Protection (https://apple.stackexchange.com/a/208481/86757).
I tested an awful quantity of solutions and the only one which worked for me was disabling root protection through Recovery Mode. I tested it with XCode 7.3, it's possible that this approach may work for XCode 8.
Reboot and hold the keys cmd + R prior to show the loading view with Apple Logo
When you are on Recovery Mode, go to Menu and choose Terminal
Type csrutil disable
Reboot the machine and run the simulator again.
I am adding this answer as it seems to be slightly different from the others.
Due to working on an older project I needed to download and run Xcode 7.3 and load the project in simulator - this yielded the "Unable to boot the iOS Simulator" error.
I completed all the above suggestions and none of them worked (reset simulator setting, restarted, deleted and reinstalled Xcode, reset the simulator location, restarted again etc)
In the end the issue was that I was trying to load the iPhone 5 (10.0) simulator on Xcode 7.3.
You can see here the Apple release notes for Xcode 7.3
Xcode 7.3 requires a Mac running OS X 10.11 or later.
Xcode 7.3 includes SDKs for iOS 9.3, watchOS 2.2, OS X version 10.11.4, and tvOS
9.2.
As you can see Xcode 7.3 doesn't include an SDK for iOS 10.0
This meant as soon as I loaded the simulator with iPhone 5 (9.3) it worked immediately.
I would therefore recommend when approaching this issue not to get railroaded (as I did) in thinking that something is wrong with the system before checking the basic things.
Note: It is also worth noting that the simulator must be configured to the Xcode version being used. This can be set in
Xcode -> Preferences -> Locations -> Command Line Tools
and also using the command line:
sudo xcode-select --switch /Applications/Xcode_7.3.app/Contents/Developer
*change the Xcode version to the new one you want to use
one of the reasons could be you might deleted /private folder.
you can try with following commands
sudo mkdir /private/tmp
sudo chmod 1777 /private/tmp
Following are the steps for solved above issue:
Search launchd.conf file in your mac
If not found then create from Terminal with help of command
~ user$ sudo touch /etc/launchd.conf
Terminal will ask you machine password
Then Open created file with help of command for EDIT, if terminal give you error as permission failed
~ user$ sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/launchd.conf
Open file manually from /etc/launchd.conf (Shift+cmd+g) and enter /etc/ (TextEdit software)
In file "DYLD_INSERT_LIBRARIES" flag replace with "ZZ" and save it.
Restart your machine.
Xcode will defiantly works.
This error indicates an error starting up launchd_sim when booting the simulated device. In and of itself, it does not indicate the actual cause. You can look in ~/Library/Logs/CoreSimulator/CoreSimulator.log for more information about the error (including the error reason).
Possible causes:
On OSX 10.9 and earlier, DYLD_INSERT_LIBRARIES could be set by 3rd party applications. On later versions, invalid DYLD_INSERT_LIBRARIES are ignored instead of resulting in an error.
Usage of older simulator runtime DLC with Xcode 7 betas. Newer versions of Xcode ignore these older DLC.
If you need additional help, please provide that additional datum.
Just check your simulator's iOS version. I fought with this error for 2 days and tried everything. Once I run the project on the simulator with iOS version that my Xcode supports, it worked sadly... :/
I quit everything and restarted the Mac. That's all. Its worked like charm!!
I don't know why, but this happened to me when I had Charles Proxy's throttling turned on.
I didn't have to run Xcode again or clean anything. Just disabling the throttling allowed the simulator to work again.
I also clicked on details, but this was all that I got:
Details
Unable to boot the Simulator. Domain: NSPOSIXErrorDomain
Code 60
Failure Reason: launchd failed to respond.
This might be related a known Xcode 11.2 issue:
Third party “endpoint security” software may cause slow simulators, system freezes, or prevent debug processes from running in simulators reliably. This sometimes manifests as debugserver disconnections or simulator applications receiving a SIGKILL signal. (55853555)
Workaround: Uninstall the third party software.
Though I was seeing this error on 11.1. Yet Apple may have just not realized this was an issue on 11.1 as well ¯_(ツ)_/¯
I have solved this issue using following steps:
Xcode -> Preferences -> Location -> Derived Data -> Delete your project folder.
I got this error on OS Catalina, Xcode 11.
I solved this by simply quiting simulator and Xcode, and then start Xcode and run your application.
1. Quit Xcode and Simulator if running.
2. Remove customised settings setup
defaults delete com.apple.Xcode
3. remove configuration folders
rm -rf ~/Library/Application\ Support/Xcode
4. Quit the terminal and run Xcode again.
Resetting the simulators fixed the issue for me. Run the below
Fastlane command to reset all simulators,
fastlane snapshot reset_simulators
Please ensure you have closed Xcode & simulator before running the command.
Fastlane is an Android & iOS deployment automation tool.
I just simply follow the below steps and the issue is resolved...
Go to About This Mac > Storage > Manage > Developer >
Select Xcode cache > Delete the cache
Now try to open the simulator again and it will work... In case if above steps did not work just try to do the same with s
Late answer, but it maybe helpful to someone. I tried all the solutions provided in this and related posts and neither of them worked.
I am using OSX(version 10.10.3) and Xcode 6.2. To fix this issue I followed the following steps :
Delete all xcode and simulator related files using AppCleaner.
Restart Mac.
Open Disk Utility app from applications.
In Disk Utility app; click on button Verify Disk Permission for your Macintosh HD (there will be some warnings displayed; I think /private/tmp is cause of this issue).
In Disk Utility app; click on button Repair Disk Permission for your Macintosh HD.
Re-install Xcode; now it should work.
More info : How to fix Xcode error ‘Unable to boot iOS Simulator’.
This may helpful
Open simulator with 4s
Click on menu- iOS simulator
Click on Reset content and settings...
Force close the simulator and run app.

Playground execution terminated because the playground process exited unexpectedly

I want to use a playground in Xcode 6.0.1.
So File -> New -> Playground
I get immediately the error.
Playground execution terminated because the playground process exited unexpectedly.
See image. Restart Xcode didn't helped.
Whats wrong with Xcode?
New Answer:
As #Woomin points out in the comments, first try restarting Xcode and rebooting your Mac, and if that fails try the following:
Try deleting the .simruntime files:
I found them located here in my root directory:
Old Answer:
If the above doesn't work try removing everything in the Developer folder located at /Library/Developer/. If this still doesn't work try removing everything in ~/Library/Developer/. If this still doesn't solve it remove xcode with AppCleaner and reinstall it using the MAS version. I found that doing this last thing solved the issue but it came back when I installed the simulators from xcode's download tab. Removing the .simruntime files finally solved it for me. BTW, I'm using version 7.2.
A restart of the mac solves the problem. What causes the issue is still unknown.
Thanks smileBot's answer. I am able to make it work with 7.2 too. I did try differently.
I installed Xcode 7.2 release version via downloading. However it had problem mentioned above. I first deleted the Xcode 7.2 via AppCleaner completely. Empty the trash. Also cleaned the derived data using WatchDog for Xcode And then restart the machine. Try again, it did not work.
So I went ahead deleted the folder ~/Library/Developer/ and then restart, try again, I can use Playground again in Xcode 7.2 again.
Xcode 7.2 and Mac os x 10.11.2
Restart Xcode or mac does not worked for me.
I solve this problem is that delete the Simulator Profiles. The Path is ~/Library/Developer/CoreSimulator/Profiles/Runtimes. Delete all Runtimes. Than Restart the Xcode, problem has been solved.
Install Command line tools using command
xcode-select --install
then u will get an update in Appstore install that app Problem will be solved.
OSX 10.11.2 and Xcode 7.2
I had gotten a reply to his from a member on the Apple Developer Forum and wanted to provide some additional information on my fix for this. First I deleted the ~/Library/Developer folder as indicated. Looking into it it had the some Simulator Profiles. I didn't know what that had to do with the Playground issue so I did NOT empty the Trash. I rebooted and the playground worked.
I put back the folder and the playground had the issues again. I one by one removed the simulator profiles in the sub directory ultimately removing ALL of the profiles without deleting the ~/Library/Developer folder structure and the Playground works.
With Xcode 7.2 (7C68) i had the same problem. I'd solve it by changing the entry of the runtime value from com.apple.CoreSimulator.SimRuntime.iOS-9-1 to com.apple.CoreSimulator.SimRuntime.iOS-9-2. I'd changed it in the device.plist. In ~/Library/Developer/CoreSimulator/XCPGDevices/ is one or more folder with a UUID as name. In one of this folders is the current device.plist.
It's not necessary to delete manually Developer's folder. Just follow this steps in Command Line (CL).
Quit Xcode.app, Simulator.app and all Xcode related and then in CL:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator
A restart of Xcode solves the problem , most of the times . (Do remember to quit from the dock too)
If that doesn't work a restart of Mac is all that is required
This happened to me and I found that the platform setting wasn't set for my playground. Probably because the playground was created in a previous version of XCode which didn't require it.
Solution:
Double click on your playground to open it in XCode and wait for the fail message.
Dismiss the message (it may appear more than once) and do the following
1.Select to show the project navigator pane.
2.Select the workspace in the navigator.
3.Select to show the Utilities pane.
4.In the playground settings area of the Identity inspector. Select OSX (or iOS)
It is ok when Change the platform to "OS X" from inspector, but problem when back to "iOS". I don't know why...in Xcode7 Beta.
Plus, it is ok in my Xcode 6.4 for both platform when playground.
And there is one more option for iOS platform "Run in Full Simulator",besides "Render Documentation"option. in My Xcode 6.4 inspector
and I have check the "IDEPlaygroundSettings.inspector" in
/Applications/Xcode.app/Contents//PlugIns/IDELanguageSupportUI.ideplugin/Contents/Resources/IDEPlaygroundSettings.inspector
and
/Applications/Xcode-Beta.app/Contents//PlugIns/IDELanguageSupportUI.ideplugin/Contents/Resources/IDEPlaygroundSettings.inspector
they are quite different.

XCode stuck with "Copying symbol files"

After updating to the latest version (6.1 b2) Xcode does not compile and run projects on the device anymore and shows "Copying symbol files" for hours. Any ideas or possible workarounds for this problems?
Try to use another cable or USB port - Other usb port fixed it for me and got the idea while finding this twitter post: [Tweet Gone]
Try this:
Clean Project
Option + Product -> Clean Build Folder
Remove this folder Library/Developer/Xcode/DerivedData/ModuleCache
Find your project folder in Library/Developer/Xcode/DerivedData/ and remove
Restart Xcode
I encountered the same problem.
"Rebooting my iPhone" worked for me.
I just spent the last several hours troubleshooting this issue on my device. I am running a virtual version of Mavericks on VBox. For me, the problem was resolved by installing Oracle VM Virtualbox Extension Pack. There was a problem with VBox fully recognizing the USB. It would recognize in iTunes, but not in XCode. This may be helpful for anyone running XCode on a virtual machine
Also you can try just to reboot your device - helps for me.
In my case, "Rebooting Xcode" & ensuring my iPhone was unlocked did the trick.
It appears that my Symbols file download began previously (as the Symbols directory for iOS 7.1.2 was in the expected location in ~/Library/Developer/Xcode/iOS DeviceSupport/), but did not complete, & thus sometimes was "sticking" and other times completing but showing my iPhone as unavailable.
When I restarted Xcode, I ensured that I already had the iPhone unlocked & then instead of just getting the "Copying symbol files" message, I also got a "Processing symbol files" message, after which my iPhone was available to run the app.
There are random solutions for this :
Please make sure that your device is unlocked when you run app.
Reboot your device.
Clean project using cmd+shift+k. You can also try Clean Build folder using alt+shift+cmd+k.
Delete the content of derived data and rebuild you app.
Quit Xcode and re-run your app.
Solution 1 and 2 worked in my case.
Delete the folder:
~/Library/Developer/Xcode/iOS DeviceSupport/<device's iOS version>
Then restart the device and restart xcode.
Apparently when the import symbol got stuck half way through it will never finish anymore, deleting the folder above should ensure the process restarts.
By restarting my iPad(iOS device) resolve the issue.
To cop with exc_bad_access error, I have enabled zombie objects in Xcode from menu -> product -> scheme -> edit scheme -> run -> diagnostics . And after that such issue started. I have disabled it and restart my iPad and eventually it will work.
I hope restarting iOS device will resolve your issue too.
This might happen also because of some usb hubs. Please try to connect your device without a usb hub.
reinstalling Xcode 7.2 seems to have helped
it has progressed past the "copying symbol files" and
showed a blue progress bar next to expanded "exporting symbol files"
(restarting Xcode and devices did not, replugging power to usb hub did not,
plugging to the mac directly bypassing usb hub did not : it was stuck for good
)

"Command /usr/sbin/chown failed with exit code 1" when Archiving

I am trying to archive my first iOS 4.3 Application for iPhone and I always encounter this error:
Command /usr/sbin/chown failed with exit code 1
I have searched through various forums, trying solutions such as changing the Alternate Install Group (which I don't know what to change to), and turning on 'Skip Install'.
As dumb as it sounds, in XCode 5.1.1, all I had to do was quit out and restart XCode just now. I know it's not much of an "answer" but it just worked for me.
Edit: this is still working as of July 2018 for folks.
Edit: this is still working as of January 2019 xcode 9.4.1
Edit: this is still working as of February 2023 xcode 14.2
I was having difficulty with the SetOwnerAndGroup part of Archiving - I was getting /usr/sbin/chown failed, and it was getting 'operation not permitted' on each file it tried to 'chown'.
This was easily tested in the terminal - 'chown' doesn't work, but 'sudo chown' does. Since I had no need to be changing file permissions, the simplest solution was to not do the chown.
The screenshot above shows - I just blanked out Install Owner/Group, and that did it.
When I got this error, rebooting my computer fixed it.
I have tried all the other solutions but none of them worked for me. So I have run this on a terminal to change the owner to me on every file in my project:
sudo chown -R my_username:my_group ./my_project_folder
where "my_username" is you username, "my_group" is your group (this is usually staff) and "my_project_folder" your project's folder.
None of the other solutions worked for me on Xcode 4.5. What I had to do was the following:
The fix is by removing the armv6 architecture from both your project and the CordovaLib project, clean
both projects, and rebuild.
Source
To it works in my environment I cleaned all information about permission, as +adalle said, complemented by Tom and Phil
I emptied the fields Install Group, Install Owner, Install Permission including the Cordova SubProject
I had the same issue with Xcode . It started working after restarting Xcode.
In the screenshot , Xcode ->build settings , installed group was empty after restarting Xcode .the group id it has showed as some number.
Not sure if this is the same problem you are having, but this fixed it for me:
When I created my XCode project, my app name had a space in it, so trying to deploy my app always failed. I was able to fix this by using a Custom Archive Name.
In XCode 4...
Edit the Deployment Scheme
Click on the Archive tab
Then specify an Archive Name that doesn't have spaces in it.
I tried all possible variants and they didn't help me. So I downloaded old XCode 4.4.1 and voila - application archived successfully :)
Select the target that's giving you the error
Change Build Active Architecture Only from Yes to No
That worked for me.
For me reboot my mac fixed it. OS High Sierra, xCode 9.2
When this happens to me on Xcode 8, I do "Clean build folder" 2 times (the first time it throws an error, but the second time succeeds) and then archive again.
Note: The "Clean build folder" option is under "Product" Menu, hold the alt button and you will see the "Clean" option changing to "Clean build folder".
Clean your project.
Clean your build Folder. (Product > ⌥ > Clean Build Folder)
Set the target device to Generic iOS Device .

Resources