Xcode Continuous Integration - "iOS Simulator failed to install the application" - ios

Running into an odd problem: integrations sometimes fail with this:
Test target [...] encountered an error (iOS Simulator failed to
install the application.)
We test with two simulators, 7.0 and 7.1.
I tried opening the simulators on the server and clearing their contents through the ui. I also tried to delete the ~/Library/Application Support/iPhone/Simulator/7.xx/Applications data with no result.
What is frustrating is the integration process works for a few hours, then breaks with the mentioned failure message, then works.
I've looked at the logs, but no smoking gun, but I might have missed something.
Where should I be looking to debug this?
If this is just a special case of all the other questions about iOS Simulator failed to install the application, then I'd imagine I'd need the ability to run a clean up script. How can I hook into the integration process?
Update: I'm manually running this command before every integration:
rm -rfv ~/Library/Application\ Support/iPhone\ Simulator/;
with the same results. I sometimes get "iOS Simulator failed to install..."
I have also tried clearing out the simulators manually through the ui. I still get the issue.

Try to solve the issue by assigning a non-empty value to Bundle versions string, short (CFBundleShortVersionString) in the -Info.plist file. iOS 7 doesn't like an empty value for the build number. You can have a script that auto increments the bundle number by 1 every time you build the project so this field was empty. You can also assign a dummy value there to get this working.

Try: "IOS Simulator->Reset Content and Setting".

Related

The request was denied by service delegate (SBMainWorkspace) on iOS 10.0+ simulator & FBSOpenApplicationErrorDomain error 1 on iOS 9.3 simulator. Why?

When trying to run any of the projects that I usually run I'm getting the following errors for different simulators:
The request was denied by service delegate (SBMainWorkspace) for reason: unspecified on iOS 10.0+ simulator
The operation could not be completed (FBSOpenApplicationErrorDomain error 1) on iOS 9.3 simulator.
This issue began when I tried installing a previous version of Xcode 8.2.1 from what I had been using (8.3). I couldn't build any projects in the 8.2.1, but I could still build in 8.3. I named the 8.2.1 a different name in order to be able to run them side by side. This was something I had done before. However, I needed 8.2.1 for a project and so I deleted both and then reinstalled just 8.2.1 according to this post: How to Completely Uninstall Xcode and Clear All Settings.
I've checked the scheme settings in Product > Scheme > Edit scheme > Run > Environment Variables and I've made sure there are no empty environment variables checked. I don't have any environment variables at all now.
I've reset content and settings on the simulators.
I've created a new simulator of a different iOS version. Originally I was just trying on 9.3 and 10.3. I then downloaded the 10.0 and 10.2 and still have the same issue occurring.
I consistently clean my project before running, both (shift + cmd + K) and (shift + alt/option + cmd + K).
I've rebooted my system. I've done everything I can think of. The issue still prevails. What am I missing?!
FBSOpenApplicationErrorDomain error 1, "unspecified" is a catch-all error code for something going wrong during launch that wasn't covered by another error code. There are a couple possible causes for this error code, and it is unfortunate that they do not get displayed in the UI.
I suggest you look in the simulated device's system log to uncover the real cause for the failure. Run this to see all the logs from CoreSimulatorBridge as that logs the full error when it gets it:
xcrun simctl spawn booted log show --info --debug --predicate 'processImagePath contains "CoreSimulatorBridge"'
If that isn't descriptive enough, you might want to also look at the logs for SpringBoard or assertiond, or just use --start and --end to see all the logs for the relevant time range.

Xcode 9: Could not attach to pid

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.

Calabash-ios: Run test physical device installed ipa without xcodeproj

I am new with calabash-ios and have a dummy question is:
How possibly could I run a calabash test with real device which have installed ipa file (included calabash framework) and without xcodeproj?
Problem is I am doing QA and Dev only gives me ipa file to test without source code.
UPDATE:
I am able to run the ipa file in console and cucumber by adding BUNDLE_ID. And make sure the CFNetwork.framework is including in app framework to establish the connection.
But I got another problem to run the scenario:
1. When I run the command below:
DEVICE_ENDPOINT=http://192.168.1.9:37265 NO_LAUNCH=1 BUNDLE_ID=com.example.appname DEVICE_TARGET=UDID cucumber
Then I got this error:
A JSON text must at least contain two octets! (JSON::ParserError)
features/my_first.feature:8:in `Then I touch "LOG-IN/ CREATE ACCOUNT"'
all other steps was skipped
Then I run the console code
DEVICE_ENDPOINT=http://192.168.1.9:37265 NO_LAUNCH=1 BUNDLE_ID=com.example.appname DEVICE_TARGET=UDID calabash-ios console
Then I run server_version
I got reply back that said connection SUCCEED
But when I run start_test_server_in_background
It took me too long to wait and I see the app my physical device kept crashed and launch again and again until it stop as:
Unable to start. Make sure you've set APP_BUNDLE_PATH to a build supported by this simulator version
Calabash::Cucumber::Launcher::StartError: Calabash::Cucumber::Launcher::StartError:
"Timed out waiting for UIAutomation run-loop Error while writing to fifo. RunLoop::Fifo::NoReaderConfiguredError.
2015-10-01 10:49:41.634 instruments[15640:10558880] WebKit Threading Violation - initial use of WebKit from a secondary thread.
2015-10-01 10:49:42.574 instruments[15640:10558978] Attempting to change event horizon while disengage
2015-10-01 10:49:42.577 instruments[15640:10558877] Attempting to change event horizon while disengage
Instruments Trace Error : Target failed to run: Permission to debug app
Anyone can help please! I tried to search some solution but they almost issue on simulator and they contain xcodeproj. As a QA, I dont have the source code, only .ipa file. :(
Thanks
You should set 3 variables:
$ DEVICE_TARGET=<UDID> \
DEVICE_ENDPOINT=http://<ip>:37265 \
BUNDLE_ID=com.example.YourApp cucumber
The device and the host computer should be on the same network.
The .ipa must be installed on your device.
You can do this in Xcode by dragging-and-dropping in the Device Manager window or with a third-party tool like ideviceinstaller (available with homebrew).
You should never set NO_LAUNCH.
http://calabashapi.xamarin.com/ios/file.ENVIRONMENT_VARIABLES.html#label-NO_LAUNCH
You also need to enable you device for develop and turn on UIAutomation in the Settings.app > Developer.
Enabling device for development
RunLoop::Fifo::NoReaderConfiguredError
UPDATE In response to this question, I rewrote the Testing on Physical Devices Calabash iOS wiki page. Wow, that content was ancient!
As long as the file is build with calabash then that is not a problem. You just call cucumber with APP_BUNDLE_PATH to where ever your .ipa file is and should be all set.
But you should be aware that .ipa needs to be build to match the target you run the tests on.

iPhone simulator reporting error when re-installing an app from Xcode

I'm using Xcode 6 with the iOS Simulator version 8.1 (build 550.3).
When I choose the "Build and Run" in Xcode everything works good, if the app isn't already installed in the simulator. If it is, however, I get the following error in Xcode:
Unable to run app in Simulator
An error was encountered while running (Domain = LaunchServicesError, Code = 0)
And the logs for the simulator show the following:
less ~/Library/Logs/CoreSimulator/CoreSimulator.log
Nov 6 11:53:47 Yggdrasil.local com.apple.dt.Xcode[4389] <Error>:
Error Domain=LaunchServicesError Code=0 "The operation couldn’t be completed.
(LaunchServicesError error 0.)" UserInfo=0x7fa697742360
{Error=PackagePatchFailed, ErrorDescription=Could not hardlink copy
/Volumes/UsersData/Users/kender/Library/Developer/CoreSimulator/Devices/AAD57C40-E208-4964-B63A-46B968B3EB36/data/Containers/Bundle/Application/FEE2DEB4-AEE3-48B7-BE71-5B027259C6FD/Baby Feeding.app
to /Volumes/UsersData/Users/kender/Library/Developer/CoreSimulator/Devices/AAD57C40-E208-4964-B63A-46B968B3EB36/data/Library/Caches/com.apple.mobile.installd.staging/temp.P8QJEE/extracted/Payload/Baby Feeding.app
with manifest /Volumes/UsersData/Users/kender/Library/Developer/CoreSimulator/Devices/AAD57C40-E208-4964-B63A-46B968B3EB36/data/Library/Caches/com.apple.mobile.installd.staging/temp.P8QJEE/extracted/com.apple.deltainstallcommands.com.owlcoding.babyfeeding}
(/Volumes/UsersData/Users/kender is my $HOME).
I tried to remove all simulators (from the Devices window in Xcode and re-add them - no luck.
I removed the entire ~/Library/Developer directory and allowed Xcode to recreate it - same issue after that.
So right now I'm stuck with Build and Run -> Make changes -> Remove app -> Build and Run flow, which kind of sucks... Anyone encountered a problem like this and found a solution, or maybe you guys have some pointers for me...
I had the same problem and it was due to localisation of the Info.plist.
My app is localised into several languages and each localisation has an InfoPlist.strings file with the CFBundleShortVersionString key. I had changed the Version string on the Target information, but not in the InfoPlist.strings files.
So I deleted the app in the Simulator, updated CFBundleShortVersionString in all the localised Info.plist files to match the version on the Target, and that resolved the issue for me.
The error indicates that installation failed because of hard linking. I suspect the filesystem for your $HOME does not support hard links. Please update your question to specify what type of filesystem /Volumes/UsersData is.
If it's not possible to support hard links on /Volumes/UsersData, then I suggest you make a local directory for your simulator data and create a symlink from ~/Library/Developer/CoreSimulator/Devices to it.
Also on a side note, deleting all of ~/Library/Developer can wreck havoc on the running simulator service. If you do that, make sure Xcode, iOS Simulator, Instruments, etc are quit, but ALSO make sure the service is killed as well by running killall -9 com.apple.CoreSimulator.CoreSimulatorService

"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