Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run app in simulator

Today, when I try to run my app in simulator, it simply tells me

Unable to run app in Simulator
An error was encountered while running
(Domain = NSPOSIXErrorDomain, Code = 22)

And the error dialog looks like this:

Unable to run app in Simulator

I've tried many things:

  • Restart Xcode
  • Restart Simulator
  • Reboot
  • Reset content and settings of simulator

None of above works. And I looked into log, I found these are those records has something to do with this issue

2014/10/15 9:09:40.964 com.apple.CoreSimulator.CoreSimulatorService[979]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f96c861d000 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}

2014/10/15 9:09:40.964 Xcode[1983]: [MT] iPhoneSimulator: Unable to connect to "com.apple.instruments.deviceservice.lockdown" (Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7fcf6fc24190 {NSLocalizedDescription=Unable to lookup in current state: Shutdown})

2014/10/15 9:09:40.980 com.apple.CoreSimulator.CoreSimulatorService[979]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f96c861d000 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}

2014/10/15 9:09:42.351 launchd_sim[2047]: assertion failed: 13F34: libxpc.dylib + 29453 [75E30F22-514B-3A20-B82C-EDA43AF5C35C]: 0x8d

2014/10/15 9:09:42.362 com.apple.CoreSimulator.CoreSimulatorService[979]: Could not register service com.apple.coreservices.lsuseractivity.simulatorsupport: Failed to lookup com.apple.coreservices.lsuseractivity.simulatorsupport: 0x44e

I also found some other people had the same issue here : https://gist.github.com/bdeshong/2dd90add09b7287a9a85

No luck to find solution after Googling around.

Here is my environment information

  • OSX 10.9.5
  • Xcode 6.0.1
  • iOS Simulator 8.0 (550.1)

Any ideas?

like image 990
Fang-Pen Lin Avatar asked Oct 16 '14 04:10

Fang-Pen Lin


People also ask

How do you run your app in iOS simulator?

To run your app in Simulator, choose an iOS simulator—for example, iPhone 6 Plus, iPad Air, or iPhone 6 + Apple Watch - 38mm—from the Xcode scheme pop-up menu and click Run. Xcode builds your project and then launches the most recent version of your app running in Simulator on your Mac screen, as shown in Figure 1-1.

Can I test IAP in simulator?

It is impossible to make a purchase on a simulator (it is only possible to request a list of available purchases). To test purchases, you first need to set up products on App Store Connect and then use the user's sandbox environment and a real device. In this case, purchases for the developer are free.

Can you install app on iOS simulator?

Install Apps on SimulatorsTo install an app on a connected simulator, follow these steps. Go to Apps > Install Application. Find and open the app you want to install from your Mac. The app appears in the list of installed apps on the right side of the iOS Gateway window.


2 Answers

I found the root causes, and I also found the solution. First thing I've done is to ensure this has something to do with Xcode rather than a problem relative to the project itself. I tried to create a new project, and it works perfectly fine. So I assume that is caused by something in my project.

I actually added a resources reference folder to my project. So I think the problem has something to do with it. However, even I removed the folder from project, the problem is still there. In the end, it turns out, the resources folder could live in

  • Built App folder
  • App folder in simulator

Since Xcode may simply copy and overwrite target App bundle folder, so the resources folder may still there in the App bundle folder. So after removing the resources folder, you need to

  • Ensure the build is cleaned
  • Ensure the app in simulator is deleted

And for the reason the App cannot be launched correctly, that's because it appears resources is actually a reserved folder name in the bundle structure. By adding a folder named resources into the bundle, somehow ruined the normal structure. To solve the problem, I changed the name from resources to app_data, or whatever it is, that all work.

like image 139
Fang-Pen Lin Avatar answered Sep 26 '22 02:09

Fang-Pen Lin


I got the same. I just did force quit xcode and simulator then worked for me.

like image 30
user3616535 Avatar answered Sep 23 '22 02:09

user3616535