Unable to run app in Simulator : An error was encountered while running (Domain = LaunchServicesError, Code = 0)

我们两清 提交于 2019-12-17 07:23:28

问题


I am unable to run my app in simulator after having trouble with the provisioning profile. I'm doing swift coding in Xcode 6 - beta 4. This was fine before the trouble in the certificate's profile.

I have tried cleaning the build. Checked the command line to xCode6-beta4 for running. Checked the build deployment, set to 7.0 so swift won't complain for compatibility Fixed the error in provisioning.


回答1:


This happens if your extension's bundle ID isn't prefixed with your app's bundle ID. For example if you app is com.mycompany.appname, your extension should be something like com.mycompany.appname.today.

Something else to note, if you're using Swift and are setting a principal class with NSExtensionPrincipalClass, you'll want to make sure your extension target sets "Defines Module" to "Yes" and make the value of NSExtensionPrincipalClass equal to "YourModuleName.YourClassName".




回答2:


I fixed it by resetting the simulator:

iOS Simulator > Reset Contents and Settings...




回答3:


It seems that there are multiple reasons for "domain = LaunchServicesError code = 0" error. I also encountered it, while I try to reinstall app on iOS8 simulator. I cannot reinstall but have to delete the old app first.

The problem was solved by:

  1. In Xcode, fill empty Version or Build field with appropriate value in your Target->General->Identity

  2. In Simulator, reset Content and settings...

After that, everything works fine.




回答4:


This also happens when you remove the default StoryBoard from template created project of a Today widget. To fix this, I added the NSExtensionPrincipalClass under NSExtension and pointed it to the class containing the Today Widget View Controller, which is by template default TodayViewController.

This looks like this in the Info.plist of the extension:

NSExtension NSExtensionPointIdentifier String com.apple.widget-extension NSExtensionPrincipalClass String TodayViewController




回答5:


  1. Product -> Clean

  2. iOS Simulator > Reset Contents and Settings

  3. Restart XCode




回答6:


None of the above worked for me, however deleting the Derived Data fixed the issue.

To delete the Derived Data, go to Window > Projects, select the current project, and press the appropriate delete button.




回答7:


"Reset Content and Settings" from iOS Simutalor menu options and launching simulator after Quitting solved my issue.




回答8:


The solution for me was not to embed a framework that hadn't been built as an embeddable framework.




回答9:


Found the cause of the problem for me.

I am using ShareKit via pods. This issue is related to the GooglePlus SDK which ShareKit uses and this has to be updated due to a policy change by Apple. http://googledevelopers.blogspot.com.br/2014/09/an-important-announcement-for-ios.html

So i replaced my pod "ShareKit" with:

pod "ShareKit/Twitter"

pod "ShareKit/Facebook"

pod "ShareKit/Pocket"

pod "ShareKit/Evernote"

Leaving out the GooglePlus sub project and the application has deployed and runs fine under 8.0 simulators now.

Hope this helps somebody else.




回答10:


I have resolve this issue. thanks for the advices. :)

This issue always happens when you build your keyboard extension app with same identifier as your main bundle. like this.

If you have this "com.codemagnus.ExAppMain" in your main bundle, your extension should also have this identifier "com.codemagnus.ExAppMain" .. This will result in launch service error if you are going to run in simulator. But you can create a build. However, the issue I have found was annoying. This app can't be install in your device. :/

If you want to run in simulator. You should have this "com.codemagnus.ExAppMain.ExApp" in your extension keyboard where ExApp was you extension name. And your main bundle should be "com.codemagnus.ExAppMain".. This will run perfectly with the simulator. However will result in "Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier."

Embedded Binary Bundle Identifier: com.codemagnus.ExAppMain.ExApp Parent App Bundle Identifier: com.codemagnus.ExAppMain

I'm still thinking and looking for a solution to solve this issue for ipa build.




回答11:


This drove me crazy. I checked everything suggested here, reinstalled Xcode, restarted my computer and nothing worked. After checking some previous commits, I found out the issue.

For context, I am working on a custom keyboard extension in Objective C. Adding a new custom keyboard extension target gives you a KeyboardViewController stub class with the "next keyboard" button. I changed the NSExtensionPrincipalClass value in the Info.plist of the extension to be a class name different from KeyboardViewController and started work on it. Eventually I decided to get rid of the the stub KeyboardViewController since it was dead code.

Deleting the KeyboardViewController files and removing them from Xcode caused this problem to happen. Putting them back made the app work again.




回答12:


In my case, this has resolved the issue.

Bundle Identifier should not be empty. You can find the field with the below reference:




回答13:


I got this error because I mistakenly changed the value of NSExtensionPointIdentifier. I thought it was supposed to be an ID for my extension, but it has to be one of these values indicating the kind of extension it is.




回答14:


I started getting this error when I changed my Deployment Target from 6.0 to 7.0. I found that resetting the simulator did solve the issue, and I needed to do this for ALL the simulators that were relevant to the app. But if I went back to 6.0 and recompiled for any particular simulator, then it worked immediately, but going again to 7.0 broke the simulator and I had to clear the settings again.

Obviously the Deployment Target affects the coding in the simulator, and the coding is downward compatible, but not upward. Plus, the log message isn't extremely helpful, saying the app couldn't be hardlinked to a cache file using a manifest (giving the pathnames to the app, cache, and manifest, of course).




回答15:


Make sure you check build settings; scroll down to the very bottom and make sure your User-Defined Bundle prefix is correct. Usually com.whatever.

Just setting it at the top doesn't always change this bottom setting. This finally worked for me after resetting simulator, frying the derived folder, etc.

I'm under IOS 9.3, xCode 7.3




回答16:


Xcode 7.3

This could simply happened because your target name is too long. Try change your target name to something shorter ( remember to change your bundleIdentifier to match ).




回答17:


If you are using apple watch besides the bundle identifier you also have to make sure that in info.plist the key WKAppBundleIdentifier contains the right watch app bundle identifier.




回答18:


I was getting the similar error while launching the app, thru xCode, "The parent bundle has the same identifier as sub-bundle..."

I shortened the Bundle Identifier in the "Project -> General" for xCode8. Initially, my bundle id was com.companyname..

The application name was more than 20 characters. Once I shortened it 12 characters, it worked for me.




回答19:


To understand what is causing this error you need to go look at the simulator log files first. These are typically located in ~/Library/Logs/CoreSimulator/CoreSimulator.log or a similar location. So I'd strongly recommend you first look at the log to idenify the root cause and then research that further. (You can take a look at this thread to see where logs are located.)

For example if you get an error such as ErrorDescription=Failed to chmod /Users/username/Library/Developer/CoreSimulator/Devices/then it's probably easiest to reset your simulator. For errors such as ErrorDescription=WatchKit 2 app's bundle ID com.mydomain.AppName.watchapp is not prefixed by the parent app's bundle then there is probably an error with how you have set up the main bundle ID of your project.



来源:https://stackoverflow.com/questions/25130558/unable-to-run-app-in-simulator-an-error-was-encountered-while-running-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!