APN & TestFlight : Xcode chooses a wrong (XC*) provisioning profile to submit archive - ios

I am using Parse.com to send client push notifications, from one iDevice to another.
It works well with the 'development' setup, i.e. with
- the Push Notification Setting of the appID set on 'Development'
- a development SSL certificate
- a development provisioning profile
With this setup, I managed to send a push notification to myself (sender = receiver = my device).
Now I want to test the communication between 2 different devices. To do so, I use TestFlight (because this is the way I usually send updates to my client).
I followed all the recommended steps to move from Development to Ad Hoc :
updated AppID settings to 'Production' Push Notifications
created a production SSL certificate, uploaded it to Parse Server
generated a new Provisioning Profile set for Ad Hoc Development, and installed it on the iPhone (checked on Organizer Library). This Ad Hoc Provisioning Profile is named : 'PushMyMoving_Push_Production_Profile'
updated the Project/Target build settings under 'Code Signing' to tell Xcode that it should use PushMyMoving_Push_Production_Profile (and the corresponding iPhone Distribution Certificate) for now on.
The issue : the build is successfully submitted, but as soon as it is, Apple sends me this e-mail :
And, naturally, I can no longer receive/send push notifications. Here's what I tried so far :
I opened the PushMyMoving_Push_Production_Profile to see if the Push Notification Entitlement was missing. It isn't. So my guess is that Xcode doesn't submit/archive the build with the right Provisioning Profile, although I'm telling it to do so in the Build Settings!
Actually, I noticed that whenever I submit the build, Xcode automatically selects a wildcard provisioning profile :
I tried to delete all the wildcard provisioning profile from Member Center & my Mac, but (annoyingly!) Xcode automatically re-creates them whenever I refresh the Provisioning Profiles Panel under Xcode>Preferences>Accounts. Is there a way to completely erase wildcard profiles ?
This thread : XCode 6 and Ad-Hoc distribution without XC: provisioning suggests that it can be that the "ad-hoc profile doesn't contain all of the devices on your team" but I carefully checked ALL the devices I have when I generated the Ad Hoc profile.
I've also tried to edit & re-generate, re-install the provisioning profile (a common advice apparently) but Xcode still does it its way.
Any help would be much appreciated! I have been struggling for days, it is really frustrating when the problem does not come from the code !
Thanks

Thanks Rhythmic Fistman for the help. I found the answer today : I was submitting my build to TestFlight with an Ad-Hoc provisioning profile, instead of an AppStore Distribution Provisioning Profile. I had read somewhere that Xcode was creating a Ad-Hoc provisioning profile behind the scenes while submitting to TestFlight, so I thought that the Ad-Hoc profile was appropriate. But since TestFlight runs like the AppStore, not having registered the subscribed devices UDID in advance (as with Ad-Hoc distribution) it makes sense to use a "broader" profile such as an AppStore Distribution Provisioning Profile.
So for anyone using Push Notifications with Testflight, you do need an AppStore Distribution Provisioning Profile. Then Xcode will automatically picks it for the submission phase.

Expunging wildcard provisioning profiles from Xcode and the developer portal can be done, but you can probably fix your problems by explicitly setting your Release Provisioning Profile to the correct Ad Hoc profile in your build settings:
This should stop Xcode getting too creative when Archiving.

Related

iOS: Is a Distribution build supposed to work on my Developer device?

I am confused with profiles and certificates for the build I am trying to put on the Appstore.
In developer.apple.com/ I have properly created both a developer and distribution certificate. they are both linked to the single app I have created.
I have registered my device (iphone)
I also have properly created 1 development provisioning profile and 1 distribution provisioning profile.
When I build with dev certificate + dev provisioning profile: app works fine on my device
But I know the build needs a distribution certif and provisioning profile in order to get approved on the appstore.
However when I build with distribution certificate + distribution provisioning profile, the build is succesful, but I can't launch the app on my iphone, other iphone (with http://www.diawi.com/ or iTunes). It immediately crashes with the infamous error popup: "unable to download. "XXX" could not be installed at this time".
When I look at the device's log from Xcode, it clearly states the crash comes from a profile issue.
Is the distribution build supposed to work on my iPhone?
You can check you Beta release build to your developer device using 'Apple Ad Hoc Distribution profile/certificat'. Here are Apple Dev link Beta Testing Your iOS App
No. A distribution build will not just be installable on your device. You are meant to submit it to iTunes Connect from Xcode, where you build it from an archive, or from Application Launcher where you would submit it as an IPA.
you should have created adhoc distributed provisioning profile and add your device to that profile.
But you need iTunes Connect to submit the app to App Store. This time you can create provisioning profile for app store.
Advantages of iTunesConnect.
1. You need not to add new device to the provisioning profile every
time you want to test the app in new device.
2. You can add as many as new test users to the app and can mark them as internal and external users.
3. You can upload as many builds as you want and test those builds.

Xcode 6 error when building app for release

I am having issues trying to achieve or even build a release build of an app I am working on. Whenever I try to build the app for release I get an error saying:
No provisioning profiles with a valid signing identity (i.e. certificate and private key pair) were found.
I have the cert for this profile on my computer but in the Developer Portal I only have a certificate for development. Is this causing this error to occur? Do I need to have a Distribution cert to be able to build for release? Any help would be appreciated.
Note: I am a developer(team member) for a company so I do not have direct access to the Apple Developer Portal.
I know provisioning profiles are a pain :) This is what I do to stay organize and develop/distribute my projects:
The developer portal (not xcode) contains the most accurate source of profiles. For example, imagine you created a merchant certificate, turned on apple pay, and then generated a provisioning profile. Then let's say you decide you no longer want to use apple pay - the act of turning it off actually invalidates the provisioning profile. You will see a yellow "invalid" warning in the developer portal, but the provisioning profile may still be available in xcode! Really annoying. So I would always make sure that your provisioning profile is valid in the developer profile before distributing an app.
In the developer portal, always make sure you have two distribution profiles -- one ad hoc to use with testflight, and one to distribute to the apple store. You should also have one developer profile to build and debug your code.
Once you have your profiles set up, go into xcode and refresh the provisioning profiles as described here: https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingProfiles/MaintainingProfiles.html#//apple_ref/doc/uid/TP40012582-CH30-SW26. I.e. go to preferences, accounts, view details..., and click the refresh button on the bottom left hand corner.
Now that xcode's provisioning profiles are updated, you need to now code sign with the right profiles. To do so, go into your project settings, and go into build settings for both the project and the target. Under debug, select your iOS development certificate. Under release, select your iOS distribution certificate. Under provisioning profile, you will want to select your development profile just to build on your device and debug, your ad hoc distribution profile if you want to archive the project and send it via testflight, or your apple store distribution profile if you want to archive the project and submit it to the apple store.
A few things to note, is that when you are creating the provisioning profiles, you need to specify the certificate you are dealing with. So if you are creating one of the two distribution profiles, you will need to select your iOS distribution certificate. And when you select ad hoc distribution, will need to select the devices that you want to be able to distribute too. Testflight will help you register the devices that you want to distribute to, and once registered, you will be able to select those devices to add them to the provisioning profile. If the certificate you select in xcode was not used to generate the provisioning profile you selected in xcode, then you will probably get the error you mentioned. Think of the provisioning profile as the link from you as a developer (i.e. your certificate) and/or your devices to your app id (i.e. your project).

Initializing my new AD-HOC profile for testing Push Notifications on Production

I want to test Push Notifications in iOS production version before I publish it. I understand I cant sign it with distribution profile ,only AD-HOC profiles.
So I created an AD-HOC profile, selected the right bundle, selected my device that I work with and created a new profile. I downloaded it and after that I select it in:
Provisioning Profile -> Release - AD-HOC-NEW
Provisioning Profile -> Debug (Any SDK, Any iOS SDK) are with Automatic.
It compiles and installed on my device through Xcode but notification don't come.
When I try to change Debug settings also to my new profile I'm getting an error :
"No provisioning profiles with a valid signing identify(i.e certificate and private key pair) were found.
No codesigning identities (i.e certificate and private key pairs) that much the provision profile specified in your build settings ("AD-HOC-New") were found. Xcode can resolve this issue by downloading a new provisioning profile from the member center."
I press "Fix Issue" but It dont fix it...
What could be the problem?
I think you should install your binary not straight xCode but as a real over-the-air/ ad hoc deployement.
The consequence is that your application will request at launch not a token from the sandbox environment but from the production one, and this will match your certificate (which is a production one too).
You do a real ad-hoc deployement both by installing your .ipa through iTunes, or by using a solution such as Testfligt.

Xcode 5 crashing when trying to validate archives

I had a couple questions when trying to put an app on the app store.
1) With Xcode 5 when trying to validate the archived project, Xcode 5 keeps crashing when trying to download the provisioning profile from the net. I have refreshed the provisioning profiles using the Preferences >> Accounts >> View Details and have clicked the refresh button but it still crashes when I try to validate.
2) Is it best practice to have a separate distribution certificates and provisioning profiles for each app you put on the app store? right now I have a separate provision profile for my apps but they are under one certificate. Can you guys tell me what the best practice is?
3) And can you try to explain what the certificates and the provision profiles are doing? Also, what would the difference between distribution provision profiles and development provisioning profiles.
1) - Check what version of Xcode you're running. I had a similar issue where I was running a developer preview - you can't submit an app from a DP version of Xcode, and mine was crashing at the exact same point as yours.
2) - Having 2 certificates - 1 for dev, 1 for distribution seems to be the norm. I would suggest that you use explicit app ids and not the wildcard ID when you go to create your App ID though.
3) The way I see it, Provisioning profiles are your wrappers for your different things that make it up - mainly the signing certificate, the app id and the device id(s) - You select either a distribution or a dev signing certificate to determine if the app is being developed or submitted to the app store. You select the App ID to tell the app what functions it will have (iCloud, Data protection, etc) and what teams can work on the app. The Devices are what UDIDs are authorised to run this app that has this associated provisioning profile. The provisioning profile is how it's all packaged up.
As another way to look at it, You have your .ipa file (your app) and your provisioning profile. The device looks at the profile, checks if the devices UDID is present in the provisioning profile, checks the App ID to see what features it's allowed to run, and the certificate is used to sign it all off.
Hope this helps.

Push notifications don't work if app is installed via iTunes but they do if installed by XCode

I have an app that uses push notifications and I am trying to distribute it to testers for testing.
If I create an ad-hoc distribution which gets installed via iTunes then everything works except for the push notifications, which never arrive.
But if the app is installed using XCode then the push notifications do arrive.
When I build for installation using XCode I set the code signing identity within XCode to my development profile. When I build for ad-hoc distribution I set the code signing identity within XCode to be the ad-hoc distribution profile when building the archive, then sign the archive for distribution again with the ad-hoc profile (I found this was the only combination that would allow installation via iTunes without an error message).
All the devices have been added to the ad-hoc distribution profile and to the apple push profile (and also to the team provisioning profile), the profiles have been renewed and refreshed within XCode.
Even with my own iPhone I can get push notifications to work if I install with XCode but not with iTunes.
Am I signing the ad-hoc distribution with the incorrect profiles, if so what is the correct combination of profiles?
Is there another reason why the push notifications don't work for the ad-hoc distribution but do when the app is installed via XCode?
These are the profiles used:
1) Apple push profile which has an App id of abcdef.com.company.mno
2) Project Development profile which has an App id of abcdef.com.company.mno
3) iOS Team provisioning profile which has an app id of abcdef.*
4) AdHoc Distribution profile which has an app id of abcdef.com.company.mno
5) My developer profile which has an app id of abcdef.com.company.mno
** since first posting this I tried creating a new iOS Team provisioning profile using the abcdef.com.company.mno app id but it made no difference **
The abcdef.com.company.mno App Id is showing Push Notifications for Development as being enabled (which is correct, we are not yet using Production pushes). Also its Development Push SSL Certificate is showing as enabled.
The code signing identities are: first pic what I use for installing/running using XCode, 2nd picture when building an archive for ad hoc distribution.
The description for the iPhone Distribution profile in XCode says: "Ad Hoc distribution profile (for bundle identifiers com.company.mno)".
This morning I had a similar issue trying to compile an In House app (I think it's the same issue). I had the iPhone plugged to the computer and I saw in console one warning like: entitlement 'aps-environment' has value not permitted by a provisioning profile
I tried this solution, but I had no success:
'aps-environment' has value not permitted by a provisioning profile
So, my app was working correctly in release mode running from Xcode, but when I tried to export with Ad Hoc certificate my iPhone shown that message on console.
Finally I went to profiles in iPhone and deleted all. I went to profiles in Organizer and deleted all too. I edited the provisioning profile via Provisioning portal and downloaded them again.
I changed code signing to Don't code sign. Changed again to In House provisioning profile, exported to a file and everything worked fine!
You're probably signing the adhoc version with a wildcard app id provisioning profile. Make sure the Code Signing Identity in the build settings is explicitly using your explicit-app-id provisioning profile.

Resources