Provisioning: Install a Mac app with iCloud for testing - xcode

I am working on a Mac app which works with iCloud KVS & CloudKit container of my iOS app which is already in production. All works fine when I run the app from Xcode directly. However, I need to Archive > Export and move it to the /Applications folder because that's how the system picks up Safari Extension Companion.
But when I try to run the exported app, it immediately crashes and the following error is printed in Console:
When exporting the app, I tried to choose between Development-signed Application (as required here in the CloudKit docs) and Developer ID (as required in SO answer linked above), also between iCloud Development / Production modes. I tried to recreate Certificates and provisioning profiles, making sure that I have iCloud enabled for my App ID (and iOS container is selected).
When I do export, there are a few folders titled "A" and I don't remember having them before enabling iCloud for my project:
What am I missing here? Thanks!

Related

How to list provisioning profiles and installed iOS signing identities?

Environment:
Visual Studio 2015 on PC
Visual Studio (Xamarin) on Mac
iPad is connected to Mac
My setup used to work fine. From PC, I would be able to debug iOS apps running on the iPad.
Yesterday, I updated the Mac OS as well as my iPad iOS. I may have updated a few other things too. However, now I am running into problems deploying Xamarin iOS apps on the iPad.
I can create an iOS app in xcode and deploy it successfully. However, when I try to build my Xamarin app, I get the error "No installed profiles match the installed iOS signing identities."
There are a few posts on the forum that talk about a similar problem. I have gone through all these posts. I have also downloaded (once again) my iOS certificate from Apple developer portal and added it to my keychain store.
I still don't understand why I get the error. Would appreciate if someone can tell me how I can get the list of installed iOS signing identities and compare them against the list of provisioning profiles.
Also, when I look at my plist.info file, I see that, for key CfBundleIdentifier, the value is replace_bundle_id. I am wondering how I can tie this bundle id back to my provisioning profile. On Apple's portal, I see a bunch of provisioning profiles (I am part of an enterprise team). There is no field called bundle-id on these profiles. All each of them have is an app-id. Where do I related the bundle-id to the provisioning profile? Regards.
Provisioning profiles are all inside the directory: /Users/m.piccotti/Library/MobileDevice/Provisioning Profiles
Usually when I have these kind of problems and no time to understand what's wrong, I simply delete everything inside that directory and I download again all the profiles from Xcode. Naturally you can try this only if you are sure that you'll be able again to download all the provisioning profiles you need.
Or it could be that you have to set the right provisioning profile for the project:
This info is saved into iOS.csproj, the element CodesignProvision.
When you go to Apple Developer portal and check App IDs, you see the Name and ID of your app. The ID is your bundle ID. That you need to enter in your plist.
Based on that Xamarin will find your profiles.
Here is what I did to make it work. This is based on the feedback I received from the other two replies.
From the Apple developer portal, I looked at the ID of my app. This was in the form com.mycompany.myproduct. In my Xamarin iOS app's plist.info, the id was replace_bundle_id. I changed it to match the one from the portal.
Next, I cleaned the "Provisioning Profiles" directory on Mac and used xcode to create a test project and change the bundle id (from project options) to match the one on the portal. xcode automatically created a new profile.
This made the whole thing work. Now I am able to deploy and debug from my PC to iPad via Mac.
Our project was generated by Xamarin wizard a long time ago and used to work just fine until recently. I still do not know why replace_bundle_id worked in the past and stopped working all of a sudden. The only change I had made was that I upgraded the OSes on the Mac as well as my iPad.

Run Mac App with CloudKit connected to the Production environment

Has anyone succeeded to run a Developer ID signed Mac App with CloudKit and with access to the Production environment, using Xcode 8 beta 3? According to this diagram of Apple it should be possible, but all my attempts lead to crashes. What are the exact steps to follow?
My attempts until now includes the use of a "Mac DirectDistribution" Provisioning Profile that points to an App ID with CloudKit enabled and with access to an iCloud Container.
My CloudKit enabled-app works perfectly with a standard App Store configuration, but I want to test it with a Production environment.
Just add the following entry to your entitlement plist and do a clean build (shift+command k). No other action is needed: (string to copy: com.apple.developer.icloud-container-environment)
After countless experiments I found the following working solution to test CloudKit on the Mac with Production data, using Xcode 7.3:
In your App project, choose Developer ID in Targets > Identity > Signing
In the Entitlements file add a new line with key "com.apple.developer.icloud-container-environment" with value "Production"
Run the App (debug modus)
Export the app to an Archive, choose Export and select "Export as a Mac Application" to produce a Developer ID-based release version.
The steps are more or less the same if you use Xcode 8, but you have the extra option to disable the App Sandbox.
For Mac the easiest way is to just after Archive click Distribute App then choose Development and click next then choose your iCloud Environment (Production/Test) and save the app wherever you want. This version will access your production iCloud.
enter image description here
enter image description here

Distributing Apps Outside the Mac App Store crash with Code Signature Invalid error

I have a Mac App for OS X 10.10 that I am trying to create a working release build.
Not for the Mac App store "Distributing Apps Outside the Mac App
Store"
Uses "Developer ID Application" for the release code signing. Things look good in my App dev account
Created an OSX APP ID com.blah.app
Can create and verify an Archive successfully
sudo spctl --assess --verbose=4 Name.App, looks good "Name.App : accepted
source=Developer ID"
Read thru Apple "Distributing Apps Outside the Mac App Store"
Needs to be OS X 10.10 due to customer requirements
Read through everything I can find on stack overflow regarding this
matter
Can build and release iOS without a second thought, but this is my
first Mac App
I run the App and in the console I see "EXC_CRASH (Code Signature Invalid)"
Stumped ...
Gatekeeper
Macs have a "gatekeeper" feature that can be set in 3 modes in System Preferences > Security & Privacy > General > "Allow apps downloaded from:".
Which is your test system set to ?
Since you're signing using a Developer ID, it needs to be set to the 2nd or 3rd option (not just allowing the App store). [2nd option is the default on freshly installed machines]
Build for distribution outside of the app store
Builds that you create for submission to the App store cannot be run by everybody. One needs to build it specifically for that.
To quote https://developer.apple.com/library/mac/qa/qa1884/_index.html :
[...] use Xcode Organizer > Export > Export a Developer ID-signed Application. Developer ID-signed apps can be run by anyone. However, code that uses technologies only available to Mac App Store apps, such as receipt validation, iCloud, and push notifications, will not work if your app is Developer ID-signed. You might need to temporarily disable those parts of your app if you opt for the Developer ID testing approach
There was an error in the selected capabilities (red) that wasn't stopping the build, "Key chain sharing" in this case. Turned off as I didn't need it and everything works as expected

iCloud set up and provisioning

I am trying to set up iCloud within my iOS application, I have done the following:
Removed all old certs on mac.
Added iCloud to the App in Dev Console - created new container and added to app
Redone the dev provision and downloaded
Installed the provision
Added the iCloud Entitlement to the app
And this is where is all goes wrong...
I can't get the app running again, the app is building but I am getting an error saying:
The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.
(0xE8008016).
Any ideas??
UPDATE: I have managed to be able to run the application to get everything programmed and put in place, everything is set up iTunes Connect end, all provisions are valid and sync'd.
Now I am getting errors during validation...
There are 4: Invalid Code Signing Entitlements. Your application bundle's signature contains code signing entitlements that are not supported by iOS. Specifically, key 'com.apple.developer.icloud-container-identifiers' in Payload ------- not supported
Other 3 are similar for other containers!
Maybe it's a late comment, but I post it here in case that somebody is struggling for the same reason.
I encountered this issue on Xcode8 recently when I was trying to archive. Generally, I enabled iCloud with Xcode in following steps:
Enable iCloud inCapabilities panel in my target by setting the toggle to ON.
Check iCloud under my App Identifier in Member Center turns green automatically, and a iCloud container is created automatically with my App Identifier. (Apple's system does this for us.)
Regenerate my certificate with my App Identifier.
Create a new provisioning profile.
Download and install the new certificate and provisioning profile
Select the new provisioning profile in Signing(Release) section in General panel in my target.
Then I got errors like:
Provisioning profile "iCloud Test" doesn't include the com.apple.developer.ubiquity-container-identifiers,
com.apple.developer.icloud-container-identifiers,
and com.apple.developer.icloud-services entitlements.
Code signing is required for product type 'Application' in SDK 'iOS 10.1'
Code signing is required for product type 'Application' in SDK 'iOS 10.1'
At last I found that there were two options in iCloud section under my App Identifier in Member Center. By default, the Compatible with Xcode 5 was selected, but I succeeded by selecting the other option.
If you're just adding iCloud to an app for the first time or want to upgrade to use CloudKit after using an older iCloud container:
Go to the Apple Development Center.
Choose Certificates, IDs & Profiles.
Use the dropdown on the top left to switch between iOS/tvOS/watchOS or macOS
Choose App IDs under the Identifiers section.
Choose your app from the list.
Scroll down to iCloud and make sure it is enabled with a green dot.
If it's not enabled or has a yellow dot, click the button at the bottom of the page to Edit and make sure you've checked iCloud service.
You may also need to create a container under the iCloud Containers section then associate it with this app.
After submitting a report to Apple, it turns out that Apple systems are useless AGAIN!
Ok, so if you are creating a NEW application or you are only just adding iCloud to your application - you will need to make sure the system doesn't pick up or create a iOS8 cloud container!
If it does you need to remove it from your app entitlements file, remove the selected containers in the Apple Developer Console and re-download certs again!
Thanks Apple again!
I got blamed for using pre-released software! I haven't touch Xcode 6 yet!!!
What I did:
- leave only com.apple.developer.icloud-services in entitlements file
- in Capabilities under iCloud marked key value storage and iCloud Documents (cloud kit EMPTY)
- Containers set to specify custom but do not select any of your containers
- This will probably give you RED warning sign under steps but leave it as it is DO NOT FIX
- Regarding provisioning profile Development and Distribution profiles have to have App ID which has iCloud enabled but NOT linked to any container
- In those provisioning profiles set under iCloud OLD version for Xcode 5 etc. not a new one related to iCloud containers
I had an error of "Add iCloud Containers to your App ID".
Automatic signing was unable to resolve an issue with target's entitlements.
I don't even use iCloud Containers, only Key-value storage(keychain).
I also switched in iCloud section under my App Identifier in Member Center from "Compatible with Xcode 5" to "Include CloudKit support (requires Xcode 6)" problem still remains.
So I fixed it like this:
Enable iCloud Capabilities panel in my target by setting the
toggle to ON.
Turn on "Include CloudKit support (requires Xcode 6)" in Member
Center (still got same error).
in Xcode in iCloud Capabilities TURN ON CloudKit (even if you don't
need it) and then turn OFF.
And then problem solved for me!

Could not launch 'app' with iCloud container

I have an OS X app targeting 10.7 (Lion) platform. I use XCode 4.4 on a development machine where iCloud is enabled. The OS X version on this machine is 10.8 (Mountain Lion).
I have an APP ID that I enabled iCloud using the Developer Certificate Utility: com.company.appname. The utility shows a green tick next to iCloud label under description of the App ID.
From XCode Target/Summary tab I enabled Entitlements and added iCloud Container com.company.appname. Of course internally it is preceded by the team id in the Entitlements file: teamid.com.company.appname.
I also have a valid (green ticked) provisioning profile on my Mac with the same id:teamid.com.company.appname.
Derived Data locations is set to Relative from XCode/Preferences.
The app builds OK. But when I run it I get "Could not launch "appname". Permission denied." error.
If I remove the iCloud container id com.company.appname from iCloud Containers list box under Entitlements and build the app, it runs OK. But of course I cannot access iCloud container enabled for the app.
I have been working on this problem for the past 24 hours. I have read the guides; Developing for the App Store, App Sandbox Design Guide, and Entitlement Key Reference inside out. Yet I am stuck. What went wrong?
I am desperate and I will be grateful if you can help me.
I think the most likely problem is that the AppID, the Entitlement and your provisioning profile do not match each other.
This can happen easily if you experiment a lot with those settings. It should work right out of the box if you create a fresh new project with valid settings, but it might get corrupted if you convert, change or edit existing projects.
Do not forget about the 10-digit prefix of your app bundle id. This is required, esp. for iCloud Key-Value-Storage!
Log into developer.apple.com, check the AppIDs tab
Create an AppID if necessary
Check the iCloud settings for this app
Note down the exact app identifier in the form ABCDE01234.com.domain.app
Switch back to Xcode, update your Provisioning Profiles and Entitlements in the "Teams" section of the "Devices" Tab in the Organizer
Go to the project settings, select the app target and search for "Code Sign"
Make sure the correct code signing identity is selected (see the application identifier above)
Go to the summary tab and put in your app ID
Open the Entitlements file and check if the right ID is in there as well.
Then it should work.
Hopefully.
Edit: thought it would be nice to add the link to the app id center:
https://developer.apple.com/certificates/index.action#bundlelist

Resources