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

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.

I fixed it by resetting the simulator:
iOS Simulator > Reset Contents and Settings...

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".

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:
In Xcode, fill empty Version or Build field with appropriate value in your Target->General->Identity
In Simulator, reset Content and settings...
After that, everything works fine.

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

Product -> Clean
iOS Simulator > Reset Contents and Settings
Restart XCode

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.

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

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

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.

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.

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.

In my case, this has resolved the issue.
Bundle Identifier should not be empty. You can find the field with the below reference:

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.

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).

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

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 ).

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.

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.

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.

Related

Can't Upload .ipa from Xcode 8, "The info.plist indicates a iOS app, but submitting a pkg or mpkg."

I am trying to submit my app. It is written in swift 3 and has an iOS 10 deployment target. So, I need to use Xcode 8. When I create an archive everything goes fine. I have even looked into the .ipa and everything seems fine.
But, every time I get this error:
The info.plist indicates a iOS app, but submitting a pkg or mpkg.
No idea what's going on. I'm not using any frameworks. No cocoapods. Very simple app.
Edit: Still no information on this. I have made a support request with Apple so we will see if that provides any new info. I can't be the only person experiencing this bug.
Update: See Peter's answer. According to him, the LSMinimumSystemVersion key ("Minimum system version") is obsolete and should be removed. If that works for you, upvote his answer instead as that would be a better solution than this if it works.
Original Answer:
I was encountering this issue when updating a very old app. I was able to fix it by changing my Info.plist.
I had to change the LSMinimumSystemVersion key ("Minimum system version") to MinimumOSVersion ("MinimumOSVersion").
Before
After
In Xcode 8.3, you should delete the Minimum system version (LSMinimumSystemVersion) entry from your info.plist. You do not need to rename it. If your app is that old, you may find other superfluous or conflicting keys as well. Another common one is the main nib file key, which conflicts with a main storyboard key.
fix!
i had the same problem and i fix it.
you can export your app (no click on "upload to app store" but "export" in the archive menu) and then use "application loader" to send your app
even if you never imported any frameworks, something might be produced automatically.
So please make sure your project has never any frameworks in it.
If you are not sure, when you export your archive file to .ipa, Xcode will code sign your bundle.
In that list, if you see any framework besides your main app bundle, it occurs.
So let me know the status of your project in the aspect I mentioned above.
Thanks

Finished running <App> on iPhone 6.1 Simulator

I'm developing a new application for Iphone, using Xcode (Version 4.6 (4H127)) and the iPhone 6.1 simulator (Versión 6.0 (369.2)).
At the beginning everything was great: every time I pressed the "run" button, the application was loaded into the simulator and I was able to test it. But sometimes it is not working: when I press the run button, I only get the message "Finished running on iPhone 6.1 Simulator". The code successfully compiles (only minor warnings).
The main problem is that when I get this message, the only way I can use the simulator again (in this project, the rest of the xcode projects seems to work properly) is by starting a new project and adding every file to it.
I've tried to delete de derived data, restart de simulator, restart de computer, etc. Even I made a snapshot when the simulator was working, but when I go back to the snapshot state, the simulator still don't work.
What can I do? Any idea?
1.Manually launch the iOS Simulator.
2.From the "iOS Simulator" menu, click "Reset content and settings",
3.Close and rebuild your app.
This problem may arise when you have problems with your project's plist's target membership. Select your info plist file from project navigator folder structure's Supporting Files, go to interface builder pane(Utilities Section under View in Top Bar), then look for Target Membership in File Inspector pane, if it is checked, uncheck it. Clean & Build, Hope it helps.
Library > Application Support > iPhone Simulator > 6.1 (or whichever you're using) > Applications > Your Application and delete it.
Rebuild your app and relaunch.
I had the same problem, with the same "failed to attach to process ID 0" (I actually didn't notice that error until I saw that you said you had that error). In one of my projects the 6.0 simulator didn't work, but works in my other projects. Also my 5.1 simulator worked.
What worked for me was based off this other answer for a similar question: https://stackoverflow.com/a/12423912/159758
Go to the Product menu and find the Edit Scheme menu there.
While in Edit Scheme window, select the "Run" option on the left hand side of the screen and then on the right hand side, change the debugger from LLDB to GDB.
Run the project, this worked in the simulator.
Then Go back to the Edit Scheme and set back to LLDB.
I noticed you've tried setting the debugger to GDB and not a debugger, but thought I'd mention what helped me, since you're question helped me get to the bottom of my problem (i.e. seeing the "failed to attach to process ID 0" message).
This problem may arise due to presence of more than one info.plist file.
I also faced a similar problem, and eventually found that while adding some resource file from another project I also added its info.plist file.
Once check your Build phases> Copy Bundle Resources, whether another info.plist file exist there or not. If exists then delete it, clean the project and rebuild it.
Hope it helps.....
I ran into the same issue and somehow was able to fix it and almost immediately it went back to being broken. I can tell what broke it though.
I added a couple of folders (folder references) with files in them to the copy bundle resources section. That broke it. If I recall right, I had removed both of those and was messing around with DeploymentTarget. I might have reset the simulator earlier. Regardless, it started working. So,
there is hope for a fix
this thing is caused by folder resources that need to be copied into the bundle
Updated:
I was able to get it working again. Here is what I did..
- Cleared out the derived data folder
- Shut down the simulator app
- Also cleared the deployment in the simulator folders (Users/XXXXXX/Library/Application Support/iPhone simulator/6.1/Applications)
Since last time adding the folders to the bundle caused it to lock up, I tried it step by step adding one folder to the bundle and trying. Turns out one of my folders was named Resources and it dawned on me that particular name could potentially be colliding with something else the app looks for. So I renamed that folder to Res and tried it. It works now.
So there you have it.. Follow the steps above to get out of the problem.
Avoid copying folders called Resources to your bundle.

XCode error "The application bundle does not contain a valid identifier."

Recently, after upgrading to Lion and Xcode 4.2.1 I am getting this error when trying to run my app on my iPhone 4S:
"The application bundle does not contain a valid identifier."
My identifier is indeed valid, and I have been able to run my app with this identifier earlier.
The problem might appear when I change computers.
I have two computers that I am using to code my app, and I am using Dropbox to keep track of my files.
Restarting XCode, my mac and my iPhone does not work.
Cleaning the target and rebuilding does not work.
The only thing I have been able to do to fix it is to create a completely new project and moving my files. This made things work until I swapped computer. Now I am in the same trouble again.
Any idea? Anyone?
Three suggestions:
Check that your developer key is in both computers
Did you try to update the project? There is a strangly-named key in the middle bottom under the project's properties. Try this.
I had similar issues. I found that some things weren't updated when I updated osx and xcode. To get out of the situation, I would suggest creating a new project and copy paste code, files and build settings. This might seem stupid, but you know apple is not good at creating IDE's. You might just get your self lost in the undocumented settings.

Argument invalid with every build in Xcode?

No matter what I try, I get an Argument is Invalid error in Xcode when I try to build to my iPhone. It works fine in the simulator. The problem is not specific to one project, it happens with any project, even when I create a new one. When I run the console it displays this
I tried deleting and re-adding the provisioning profiles, and I've gone through every setting to look for spaces because I heard these can cause this error. Can anyone help? I don't know what else to try.
If you have a symbolic link (ln -s) in your project directory, it will work on the simulator, but cause a “The argument is invalid” error if the target is a real iOS device. (Xcode 4.5.2)
You may check if you have a space somewhere in the settings, such as the product name or so. These cause these kind of errors in many cases....
Also sometimes a symlink in your bundle can be the reason - depending on how you set up your file structures in the app bundle...
Actually this looks like and xcode error because it cant find those .m files. So here is a post that responded to hopefully it helps. It looks like you are gonna have to do some installation and reinstallation. XCode Update - iOS Link Error
I am assuming you are working with Git. This often happens due to issues in your local build. Take the latest pull from the develop branch and check if this solves your issue. If this doesn't work, you might want to manually check the build settings for your app.

Why do I get "could not be added to your itunes library because it is not a valid app" error when trying to install Ad-Hoc build?

I've recently upgraded my Mac to Lion, and also Xcode 4.
In Build Settings, I've set "Code Signing" for "Release" to be "iPhone Distribution" which matches our Ad-Hoc provisioning file (which we've used in the past, on Snow Leopard/Xcode 3).
I have deleted the old Entitlements file (as it's apparently no longer used by Xcode 4).
In the Scheme section, I've set Archive to use the Release build.
I'm building with Product > Archive.
I'm saving the file by going into the Organiser and clicking Share, then making sure the same Ad-Hoc provisioning is selected.
I'm sending the resulting IPA file to my boss, who has previously installed this app. When he tries to install it, he gets the message "[appname] could not be added to your itunes library because it is not a valid app".
I've been trying every combination of settings I can think, but we just cannot get this to work. I can find this error only twice in Google - once from someone with a jailbroken phone and another posted in comments of an article, someone having the same issue, but there are no responses.
Any help would be really appreciated.
Edit: Same thing happens trying to drag the IPA into iTunes on the Mac that created it! :(
Edit2: Just taken another (almost identical) project and tried a build without "Modernizing" the project, or selected any of the new options in Xcode (icons, launch images, orientation etc.), and this build works. I'm going to work through each of the things I did with the original app with this one, testing at each step. Hopefully should be able to isolate which step is breaking the compiled app!
(also posted to Apple Dev Forums)
I believe I've tracked this down... It seemed to be happening really intermittently, so it's taken some time (I'd reproduce it, roll back the change, confirm it worked, then re-apply the change, for it to then work again!).
However, after much cleaning/restart/etc., I believe it's related to the "Build" version in the target settings (there are now two version fields, "Version" and "Build"). It seems that if "Build" is blank, then this error occurs.
Unfortunately, changing this value doesn't seem to rebuild properly, so sometimes if you change it, then Archive, you still get the previous value. Manually cleaning before Archiving seems to work around this.
The value gets written into the plist file as CFBundleVersion.
Recently I suffered a problem with an Ad-Hoc installation using TestFlight service, the message in the log didn't help too much:
Jul 25 12:52:39 MyiPad installd[477] <Error>: 0x10059c000 init_pack_state: Archive we've been requested to install is 0 bytes. That can't be a valid ipa.
After many tests, I found this question and the problem was the same, the Build field was empty (this answer save my day :-) )
So, if anyone else has this problem on TestFlight, I hope my answer allows to find this page easier ;-)
I also faced the same issue. After doing some research found below answers as:
App Version and Build version should not blank.
Don't put special characters in my app bundle name.
And also there was no issues with my provisioning profiles.
After debugging found that there was name mismatch in my scheme name and info.plist file name. In my project, I have 3 schemes like a,b,c and only one a-info.plist file. I was creating IPA for different scheme like 'b'.
In your scenario, if you have created multiple schemes then check your Info.plist name. That should have to be same as your scheme name (for which you are creating an IPA).
Example. The scheme name is 'myScheme' then your Info.plist file name as 'myScheme-Info.plist'.
Hope this will help you.
I got the same message ("not a valid app"). In my case, I was FTPing the built app to a web server then I would be able to OTA provision it. I was not swapping to binary mode before I was putting the file, so the .ipa file got corrupted on the way. Took me most of the evening to figure that stupid mistake out...
ok.. do one thing.. Open info.plist.. Go to bundle identifier and change bundle identifier name. It needs to be unique.. something like "com.yourcompany.projectname" and create and try to install the ipa.. It should work
I came across this question while researching a similar problem so I'll answer here even though the cases are not identical, because others will search for the same error message.
I had an ad-hoc app that everyone in the development team could install fine, except one person, who got the error from iTunes:
X is not a valid app
He had been able to install earlier versions of this app. Rebuilding the app, changing the version number and changing the build number had no effect, he still could not install but others could.
I fixed it by creating a brand new Xcode project, either copying the files or copying and pasting the content of the files from the old project to the new one, and rebuilding the app and signing it in exactly the same way as the old project. It worked.
I had a similar issue while trying to create an .ipa for adHoc distribution for one of the Old project (built a year ago by ex-developer). After a lot of research in google and following the above solutions it didn't worked out for me somereason.
Later after following this link - here. By replacing the .plist file with the existing working projects (obviously - the relevant icons/bundle display name/identifier) and renaming with the current .plist name. It worked for me.
I literally spent about 3-4 hours to fix this issue. Hope it helps some one.
environment was native - iOS app.
add......
"Application requires iPhone environment" in your info.plist or if added give it value "YES".
Check "Build" and "Version" in general are not empty....
hope this will work
Importing the project contents in to a new Project solved the issue for me.
For me, we were trying to do an enterprise build of a very old app, from iOS 5.
After confirming profiles and everything else was fine, debug builds work correctly, I noticed the general consensus was around issues with the info.plist file.
I compared the info.plist with another app and sure enough,
Application requires iPhone environment = NO
Basically this key needs to always be set to YES for iOS apps regardless whether its for iPhone, iTouch or iPad...
It may not be limited to that key for everyone but make sure the info.plist looks similar to working apps.
Bundle version
Bundle versions string, short
should always be present!
right.. but I guess it is clashing with earlier bundle identifier( this happens because you have upgraded the Xcode). Did you try and change the existing bundle identifier name and install ? I had identical problem and wasted 3-4 days.. I changed existing bundle identifier name and it worked.. Also you may want to check Bundle name and Bundle version are present in info.plist