I am trying to create a share app extension and followed the tutorial from this source:
http://www.technetexperts.com/mobile/share-extension-in-ios-application-overview-with-example/
I am using XCode 8.0 (8A218a) On simulator it works as expected. On my iPhone 5s with iOS 9.3.3.
I install the container application first and then run Extension by choosing Photos app when XCode asks "Choose an app to run".
Now when I open a photo while extension is running, the following error appears:
MobileSlideShow[3500:589624] *** error reading settings archive file: <ISRootSettings:
/var/mobile/Documents/com.apple.mobileslideshow.settings/ISRootSettings_10.plist>
Now when I tap the Share button, my container app doesn't appear in the list of Apps capable of Sharing picture.
EDIT: I am sharing some code:
ShareViewController.m
@implementation ShareViewController
- (BOOL)isContentValid {
// Do validation of contentText and/or NSExtensionContext attachments here
return YES;
}
- (void)didSelectPost {
for (NSItemProvider* itemProvider in ((NSExtensionItem*)self.extensionContext.inputItems[0]).attachments ) {
if([itemProvider hasItemConformingToTypeIdentifier:@"public.jpeg"]) {
NSLog(@"itemprovider = %@", itemProvider);
[itemProvider loadItemForTypeIdentifier:@"public.jpeg" options:nil completionHandler: ^(id<NSSecureCoding> item, NSError *error) {
NSData *imgData;
if([(NSObject*)item isKindOfClass:[NSURL class]]) {
imgData = [NSData dataWithContentsOfURL:(NSURL*)item];
}
if([(NSObject*)item isKindOfClass:[UIImage class]]) {
imgData = UIImagePNGRepresentation((UIImage*)item);
}
NSDictionary *dict = @{
@"imgData" : imgData,
@"name" : self.contentText
};
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.iosApp.testSharing"];
[defaults setObject:dict forKey:@"img"];
[defaults synchronize];
}];
}
}
}
@end
ViewController.m
@implementation ViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.iosApp.testSharing"];
NSDictionary *dict = [defaults valueForKey:@"img"];
if (dict) {
NSData *imgData = [dict valueForKey:@"imgData"];
UIImage *image = [UIImage imageWithData:imgData];
[_shareImageView setImage:image];
_shareImageNameLabel.text = [dict valueForKey:@"name"];
[defaults removeObjectForKey:@"img"];
}
}
@end
You have to change the deployment target of share extension form target of your project then it starts working.
Your testing iPhone version is lower than your Deployment Info
setting:
For me unchecking the Copy only when installing option worked. This option can be found under Build Phases > Embed App Extensions.
You have to make sure what kind extension identifier you need com.apple.ui-services
or com.apple.share-services
that's my configuration example:
This is where it appears using ui-services:
And here using the com.apple.share-services
:
and then:
And for everything works fine, don't forget to make sure that your project has the same deployment info target version that your target (General/Deployment Info/Deployment Target)
see ya, hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With