Re: App refuses to launch after adding iCloud Drive support

2016-01-01 Thread Graham Cox
Hmmm, maybe I spoke too soon.

My app appears to be able to access iCloud Drive. Adding/removing the magic 
stuff to info.plist appears NOT to make any difference to this, though caching 
somewhere might be skewing the true picture, don’t know.

What I’d quite like to do is to follow the recommendation in the documentation 
and add a //Documents/ folder to the user’s iCloud drive. So I tried 
the following code, run from -[ appDidFinishLaunching]:


- (void)prepareICloudDrive
{
// creates subfolders in the iCloud drive if needed

NSDictionary* ubiquityContainers = [[NSBundle mainBundle] 
objectForInfoDictionaryKey:@"NSUbiquitousContainers"];

if( ubiquityContainers )
{
for( NSString* containerID in ubiquityContainers )
{
NSDictionary*   container = [ubiquityContainers 
objectForKey:containerID];

if( container )
{
// need to do this on a thread

NSOperationQueue* opq = [[NSOperationQueue 
alloc] init];

[opq addOperationWithBlock:^
{
NSFileManager* fm = [[NSFileManager 
alloc] init];
NSURL* iCloudURL = [fm 
URLForUbiquityContainerIdentifier:containerID];  //<—— always returns nil

if( iCloudURL )
{
// append //Documents/ 
to the URL

NSString* appContainerName = 
[[container objectForKey:@"NSUbiquitousContainerName"] 
stringByAppendingPathComponent:@"Documents"];
NSURL* iCloudDocFolderURL = 
[iCloudURL URLByAppendingPathComponent:appContainerName isDirectory:YES];
NSError* error = nil;

if( ![fm 
createDirectoryAtURL:iCloudDocFolderURL withIntermediateDirectories:YES 
attributes:nil error:])
{
NSLog(@"failed to 
create iCloud storage at %@, error = %@", iCloudDocFolderURL, error );
}
}

[fm release];
[opq release];
}];
}
}
}
}


The problem I have is that when the block runs, the result of 
-URLForUbiquityContainerIdentifier: is nil. The docs for this state that I have 
to pass a string in the form ., which doesn’t seem to be the 
case for the string the other documentation has (‘iCloud.com..'. It’s unclear how this is supposed to work without having 
entitlements, but the docs state that 10.11 apps don’t need the entitlements, 
just the magic.

It’s not essential that I do this - presumably the user can add folders as they 
wish, but since iApps and other Apple apps do this, it would be nice to follow 
suit.

Since 10.11 changed how this works, I’d expect to see an explanation at least 
in the release notes, but I don’t see anything there. Is there any other info 
about this? The docs as usual are ambiguous and self-contradictory.

—Graham





> On 1 Jan 2016, at 5:59 PM, Graham Cox  wrote:
> 
> Thank you Quincey!
> 
> I was thinking that if Apple want this stuff adopted, they really ought to 
> make it much easier. Turns out they did :)
> 
> 
> —Graham
> 
> 
> 
> 
>> On 1 Jan 2016, at 1:39 PM, Quincey Morris 
>>  wrote:
>> 
>> 
>>  
>> https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/DesigningForDocumentsIniCloud.html#//apple_ref/doc/uid/TP40012094-CH2-SW20
>> 
>> at the end of the page under the heading "Enabling Document Storage in 
>> iCloud Drive”.
>> 
>> In brief, for 10.11 non-Mac-App-Store access, do NOT set the entitlement, 
>> but DO add the magic thing to your info.plist.
>> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com
> 
> This email sent to graham@bigpond.com



Re: App refuses to launch after adding iCloud Drive support

2016-01-01 Thread Quincey Morris
On Jan 1, 2016, at 01:19 , Graham Cox  wrote:
> 
> It’s not essential that I do this - presumably the user can add folders as 
> they wish, but since iApps and other Apple apps do this, it would be nice to 
> follow suit.

According to this thread on the developer forums:

https://forums.developer.apple.com/message/57044#57044 


> “In order to set up an iCloud container (visible to the user as the special 
> folder marked with the app icon), you *do* still need need to have the 
> traditional iCloud entitlements and Mac App Store distribution signatures.”


So I think you can’t do like you want to do. OTOH, I’m relaying hearsay, so 
there might be a better answer if you ask in the right place (e.g. a TSI?).

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App refuses to launch after adding iCloud Drive support

2015-12-31 Thread Graham Cox

> On 1 Jan 2016, at 11:54 AM, Roland King  wrote:
> 
> Developer ID’ doesn’t sound right. Developer ID is for signing apps for 
> non-mac-store distribution,


That’s exactly what I want to do.


> If you want to distribute a test copy of the app you need to sign it with the 
> Mac developer certificate using a provisioning profile which contains the 
> device which is going to run it.


I have no idea what device is going to run it. The app is a private copy for 
testing, but by others, not by me. I usually handle this by simply signing it 
with a Developer ID. That stops the testers getting the Gatekeeper warning, but 
otherwise doesn’t put any special requirements on them. They can also verify 
that the app is signed by the expected developer.


> The Mac Distribution certificate is for signing apps to send to the App Store 
> where they get re-signed for distribution to the world. 


At the stage the app isn’t destined for the App Store.


> Didn’t know that the thing would crash however

Yes, I’ve never seen this behaviour before either. I don’t really get it - the 
iCloud signatures appear to match the Developer ID. Perhaps iCloud Drive is 
simply unavailable to non App Store apps? If so it’s not very friendly about 
saying so, and also makes it difficult to test the functionality. The app will 
go in the App Store eventually, but our testing procedures are far smoother at 
this stage (beta) without bringing that into it.

—Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App refuses to launch after adding iCloud Drive support

2015-12-31 Thread Quincey Morris
On Dec 31, 2015, at 17:05 , Graham Cox  wrote:
> 
> Perhaps iCloud Drive is simply unavailable to non App Store apps?

Yes, I believe that was the case up to 10.10. For 10.11+, see this:


https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/DesigningForDocumentsIniCloud.html#//apple_ref/doc/uid/TP40012094-CH2-SW20
 


at the end of the page under the heading "Enabling Document Storage in iCloud 
Drive”.

In brief, for 10.11 non-Mac-App-Store access, do NOT set the entitlement, but 
DO add the magic thing to your info.plist.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App refuses to launch after adding iCloud Drive support

2015-12-31 Thread Roland King
‘Developer ID’ doesn’t sound right. Developer ID is for signing apps for 
non-mac-store distribution, and I never worked out why there’s one for apps and 
one for installers. If you want to distribute a test copy of the app you need 
to sign it with the Mac developer certificate using a provisioning profile 
which contains the device which is going to run it. The Mac Distribution 
certificate is for signing apps to send to the App Store where they get 
re-signed for distribution to the world. 

iOS compilicates it more by having development and ad-hoc distribution profiles 
which appear to do mostly the same thing. 

Didn’t know that the thing would crash however, I would have just expected it 
to refuse access to iCloud drive. 


> On 1 Jan 2016, at 08:22, Graham Cox  wrote:
> 
> I’m working on adding iCloud Drive support to my app. When running from 
> Xcode, it all seemed to be working, but when I archived the app, Exported a 
> Developer ID signed copy, it refuses to launch:
> 
> Crashed Thread:0
> 
> Exception Type:EXC_CRASH (Code Signature Invalid)
> Exception Codes:   0x, 0x
> Exception Note:EXC_CORPSE_NOTIFY
> 
> Turning off the iCloud entitlment it launches normally.
> 
> When setting up the iCloud drive support I used the same Developer ID, so I 
> don’t know what the problem is.
> 
> Anyone know what’s going on here? Code signing issues are always a problem 
> when they arise because it’s such an opaque procedure which supposedly “just 
> works” in Xcode. Except when it doesn’t.
> 
> —Graham
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App refuses to launch after adding iCloud Drive support

2015-12-31 Thread Roland King

> On 1 Jan 2016, at 09:05, Graham Cox  wrote:
> 
> 
>> On 1 Jan 2016, at 11:54 AM, Roland King  wrote:
>> 
>> Developer ID’ doesn’t sound right. Developer ID is for signing apps for 
>> non-mac-store distribution,
> 
> 
> That’s exactly what I want to do.
> 
> 
>> If you want to distribute a test copy of the app you need to sign it with 
>> the Mac developer certificate using a provisioning profile which contains 
>> the device which is going to run it.
> 
> 
> I have no idea what device is going to run it. The app is a private copy for 
> testing, but by others, not by me. I usually handle this by simply signing it 
> with a Developer ID. That stops the testers getting the Gatekeeper warning, 
> but otherwise doesn’t put any special requirements on them. They can also 
> verify that the app is signed by the expected developer.
> 
> 
>> The Mac Distribution certificate is for signing apps to send to the App 
>> Store where they get re-signed for distribution to the world. 
> 
> 
> At the stage the app isn’t destined for the App Store.
> 
> 
>> Didn’t know that the thing would crash however
> 
> Yes, I’ve never seen this behaviour before either. I don’t really get it - 
> the iCloud signatures appear to match the Developer ID. Perhaps iCloud Drive 
> is simply unavailable to non App Store apps? If so it’s not very friendly 
> about saying so, and also makes it difficult to test the functionality. The 
> app will go in the App Store eventually, but our testing procedures are far 
> smoother at this stage (beta) without bringing that into it.
> 
> —Graham
> 
> 

See if you can make head or tail of this table

https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/AppDistributionGuide/SupportedCapabilities/SupportedCapabilities.html#//apple_ref/doc/uid/TP40012582-CH38-SW1
 


That tells you what you can and can’t do with different types of ID. However I 
don’t understand the difference between the filled an unfilled circles. eg take 
iCloud Documents row under the ‘Mac Developer ID’ certificate, which is 
probably what you want. It’s there, so it should be available. The circle is 
filled however and the note at the bottom says

Requires an Apple ID associated with an Apple Developer Program membership. For 
Mac apps, the signing identity must be set to Mac App Store.

But hold on, if the signing identity is set to Mac App Store, why is it in a 
column where the signing identity is Mac Developer ID? 

I’ve read it several times now and I’m still confused. Possible that you select 
Mac App Store in one place and Mac Developer ID in a different place and 
somehow that combination works to do what you want. 

I also thought that the non developer program support IDs which were introduced 
in Xcode 7, meaning you didn’t have to buy the membership every year, didn’t 
have access to iCloud however looking at the lefthand column of that table, the 
icons are unfilled which to me would mean I can use iCloud using a ‘free’ 
account, for my own purposes. 

And finally see the note at the very bottom telling you how to use iCloud Drive 
in 10.11 without needing an iCloud entitlement at all. 

I think this is now officially more complicated than it needed to be.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App refuses to launch after adding iCloud Drive support

2015-12-31 Thread Graham Cox
Thank you Quincey!

I was thinking that if Apple want this stuff adopted, they really ought to make 
it much easier. Turns out they did :)


—Graham




> On 1 Jan 2016, at 1:39 PM, Quincey Morris 
>  wrote:
> 
> 
>   
> https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/DesigningForDocumentsIniCloud.html#//apple_ref/doc/uid/TP40012094-CH2-SW20
> 
> at the end of the page under the heading "Enabling Document Storage in iCloud 
> Drive”.
> 
> In brief, for 10.11 non-Mac-App-Store access, do NOT set the entitlement, but 
> DO add the magic thing to your info.plist.
> 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com