Cfbundledocumenttype Is Not Working in Myproject-Info.Plist File

CFBundleDocumentType is not working in myproject-Info.plist file

Several things are missing/wrong :

  • CFBundTypeIconFiles : I'm quite suire you need to specify the icons for your app to appear
  • CFBundleTypeName : You put the name of your application here
  • CFBundleTypeRole : I think you want "Viewer" here
  • LSHandlerRank : I think you want "Alternate" here (not sure you can be something else for a contentype like "public.jpeg")

This is an example that works to register your application. It's tested and works for all types of data. Work your way down from there to target only public.jpeg :

<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>Icon-22x29.png</string>
<string>Icon-44x58.png</string>
<string>Icon-64x64.png</string>
<string>Icon-320x320.png</string>
</array>
<key>CFBundleTypeName</key>
<string>My App</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>

The value of the CFBundleDocumentTypes key in the Info.plist must be an array of dictionaries

After So many hours of research finally made a successful upload to app store.

It seems apple have some changes in the submission of app.

we have the below in the info.plist which was working normally for the past 10 submission

<key>UTExportedTypeDeclarations</key>
<array>
<string>public.url</string>
<string>public.plain-text</string>
<string>public.image</string>
</array>

After removing it and uploading to store everything worked normally
Dont know what is that related to CFBundleDocumentTypes but that was the reason

ios cordova, cannot add app in share menu

The bug is that the app won't appear in photos share list only.

Photos app seems in cause and not the Info.plist declaration.

I will document this answer if I find a workaround of thi problem.

Regards, Olivier

Submitting app to app store error

Your doesn't respect the format for the diferents keys.

<dict>
<key>CFBundleTypeName</key>
<string>My File Format</string>
<key>CFBundleTypeIconFiles</key>
<array>
<string>MySmallIcon.png</string>
<string>MyLargeIcon.png</string>
</array>
<key>LSItemContentTypes</key>
<array>
<string>com.example.myformat</string>
</array>
<key>LSHandlerRank</key>
<string>Owner</string>
</dict>

https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html

How do assign a type of file to my app on Mac

The following subclass of NSWindow should allow you to save a file with a unique ‘.jaf’ extension and then reopen the file into the app by double clicking on it. The info.plist is not as critical as I initially thought; I did not alter the one created by Xcode. Most important for this non-Document based app seems to be the calling of NSApplicationDelegate method -(BOOL) application: openFile. The NSApplicationDelegate was added to the NSWindow subclass instead of having a separate AppDelegate as is usually the case. When working correctly you should hear a beep when this method is called after a .jaf file is double-clicked; I couldn’t find the NSLog output. To run the demo in Xcode first create an objc project and delete everything in the ‘main.m’ file and copy/paste the following source code into it. Delete the pre-supplied AppDelegate class to avoid duplicate symbols. In the entitlements set the App Sandbox to NO and set read-only to zero. After the JAF app has been made, use it to save a file to your desktop with the ‘.jaf’ extension. Then make a copy of the app (shown in the Finder) and copy/paste it into the Applications folder. The next step is critical; right click on the file that you just made and use either Get Info or Open With to set the file to always open with your newly made app. At this point you should be able to double click on the xxxx.jaf file and have it open into your app with an audible beep.

#import <Cocoa/Cocoa.h>

@interface Window : NSWindow <NSApplicationDelegate> {
NSTextView *txtView;
}
- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag;
-(void) buildMenu;
-(void) openAction;
-(void) saveAction;
@end

@implementation Window

#define _wndW 700
#define _wndH 550

- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
NSLog(@"This comes from JAF : filename = %@.",filename);
NSBeep(); // Listen for this.

NSError *error;
NSURL *url = [NSURL fileURLWithPath:filename];
NSString *fileStr = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
if (!fileStr) {
NSLog(@"Unable to open file %@", error);
} else {
[txtView setString:fileStr];
}

return YES;
}

-(void) buildMenu {
// **** Menu Bar **** //
NSMenu *menubar = [NSMenu new];
[NSApp setMainMenu:menubar];
// **** App Menu **** //
NSMenuItem *appMenuItem = [NSMenuItem new];
NSMenu *appMenu = [NSMenu new];
[appMenu addItemWithTitle: @"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[appMenuItem setSubmenu:appMenu];
[menubar addItem:appMenuItem];
}

-(void) openAction {
NSOpenPanel *op = [NSOpenPanel openPanel];
[op setAllowedFileTypes:[NSArray arrayWithObjects: @"jaf", @"txt", nil]];
[op beginSheetModalForWindow: self completionHandler: ^(NSInteger returnCode) {
if (returnCode == NSModalResponseOK) {
NSURL *url = [op URL];
NSError *error;
NSString *fileStr = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
if (!fileStr) {
NSLog(@"Unable to open file %@", error);
} else {
[self->txtView setString:fileStr];
}
}
}];
}

-(void) saveAction {
NSSavePanel *sp = [NSSavePanel savePanel];
[sp setTitle:@"Save contents to file"];
[sp setAllowedFileTypes:[NSArray arrayWithObjects: @"jaf", nil]];
[sp setNameFieldStringValue: @".jaf"];
[sp beginSheetModalForWindow: self completionHandler: ^(NSInteger returnCode) {
if (returnCode == NSModalResponseOK) {
NSURL *url = [sp URL];
NSString *viewStr = [[self->txtView textStorage] string];
NSError *err;
BOOL fileSaved = [viewStr writeToURL:url atomically:YES encoding:NSUTF8StringEncoding error:&err];
if (!fileSaved) { NSLog(@"Unable to save file due to error: %@", err);}
}
}];
}

- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag {

self = [super initWithContentRect:NSMakeRect(0, 0, _wndW, _wndH) styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
[self setTitle: @"Test window"];
[self center];
[self makeKeyAndOrderFront: nil];

// ****** NSTextView with Scroll ****** //
NSScrollView *scrlView = [[NSScrollView alloc] initWithFrame:NSMakeRect( 10, 10, _wndW - 20, _wndH - 80 )];
[[self contentView] addSubview:scrlView];
[scrlView setHasVerticalScroller: YES];
[scrlView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
txtView = [[NSTextView alloc] initWithFrame:NSMakeRect( 0, 0, _wndW - 20, _wndH - 80 )];
[scrlView setDocumentView: txtView];

// **** Open Button **** //
NSButton *openBtn =[[NSButton alloc]initWithFrame:NSMakeRect( 30, _wndH - 50, 95, 30 )];
[openBtn setBezelStyle:NSBezelStyleRounded ];
[openBtn setTitle: @"Open"];
[openBtn setAutoresizingMask: NSViewMinYMargin];
[openBtn setAction: @selector (openAction)];
[[self contentView] addSubview: openBtn];

// **** Save Button **** //
NSButton *saveBtn =[[NSButton alloc]initWithFrame:NSMakeRect( 130, _wndH - 50, 95, 30 )];
[saveBtn setBezelStyle:NSBezelStyleRounded ];
[saveBtn setTitle: @"Save"];
[saveBtn setAutoresizingMask: NSViewMinYMargin];
[saveBtn setAction: @selector (saveAction)];
[[self contentView] addSubview: saveBtn];

return self;
}

- (BOOL)windowShouldClose:(id)sender {
[NSApp terminate:sender];
return YES;
}

@end

int main() {
NSApplication *application = [NSApplication sharedApplication];
Window *window = [[Window alloc]init];
[window buildMenu];
[application setDelegate:window];
[application activateIgnoringOtherApps:YES];
[NSApp run];
return 0;
}

My app inside iMessage UIActivityViewController

Instead of a URL scheme you need to add a document type to your app. Try adding the following fragment to your Info.plist:

<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>public.jpeg</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>public.jpeg</string>
</array>
</dict>
</array>

With this fragment (specifically with the LSItemContentTypes key) you declare that your app is an editor for documents that have the Uniform Type Identifier (UTI) public.jpeg. Because this UTI is declared by the system, I believe it is not necessary that you include the UTI declaration in your app's Info.plist.

You can find all system-declared UTI's in the Apple document titled System-Declared Uniform Type Identifiers. If you are new to UTI you should probably also read the Apple document Uniform Type Identifier Concepts.

Last but not least, don't forget to consult the Information Property List Key Reference to find out what you should specify for the Core Foundation keys CFBundleTypeRole and LSHandlerRank.

BTW: This excellent SO answer also has details about working with UTIs, especially if you ever need to declare your own app-specific UTI.

Registering an icon for my application's document type

Try putting the icon name in the CFBundleTypeIconFile key in the CFBundleDocumentTypes array, not in the UTExportedTypeDeclarations array.

And of course make sure that "My-file-icon.icns" is in your target's Copy Bundle Resources build phase and is being copied into Contents/Resources in your app's bundle.

CFBundleVersion in the Info.plist Upload Error

There's at least 1 known bug in Apple's upload server that they've not fixed for more than 12 months. Things to beware of:

  1. Apple deletes any leading zeroes inside the version number; i.e. the "whole string" is NOT treated as a number, instead the bits between dots are treated as SEPARATE numbers. e.g. "1.02" is treated by Apple as "1.2". So, for Apple, 1.02 is GREATER THAN 1.1
  2. Apple sometimes gets "confused" and seems to compare your uploaded-app to the version of a DIFFERENT app you've previously uploaded. It's happened to a lot of people, and I've seen it myself a few times
  3. Apple is supposed to be comparing the "CFBundleVersion" (i.e. "Bundle version" not the "Bundle versions string, short"); don't get mixed up.
  4. Frequently, the only viable solution is to bump the front number (e.g. the "2" in "2.4" -- increase it to "3")
  5. The version number you upload is unrelated to the version number that appears in iTunes - you can put anything you want there, and that's what your users will see
  6. ...except, if you also report the "actual" version number inside your app, the user will see the CFBundleVersion (usually, depends how you code it), rather than the iTunes version (which - I think - cannot be accessed from inside your app)

Share something to a phonegap app

To appear in this list you have to modify the AndroidManifest.xml file and add the following lines under your activity :

<intent-filter> 
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>

This will make your app appear in the list. Now I think you may probably also want to know how to handle this in your code. When another application is going to share some text with you, it's going to start your application with an Android "Intent". To be able to use Intents, you need a PhoneGap plugin. I think WebIntent might suit you. This would be the code :

// deviceready is PhoneGap's init event
document.addEventListener('deviceready', function () {
window.plugins.webintent.getExtra(WebIntent.EXTRA\_TEXT, function (url) {
// url is the value of EXTRA_TEXT
}, function() {
// There was no extra supplied.
});
});

More info on WebIntent here : http://smus.com/android-phonegap-plugins/

Note : I don't think you'll be able to do this with PhoneGap Build though ... you can only use supported plugins, and can't change the AndroidManifest.xml file that much. You'll probably have to go the Cordova route and build everything on your machine.


Edit : there are a few people asking how to do this on iOS. There are two steps to do this :

  1. Associate your app with the right file type associations by adding the relevant information in your info.plist. This SO answer explains how to do it : How do I associate file types with an iPhone application?. This will make your app appear in the list but your app won't receive the data yet.
  2. Your application will now be launched with new parameters. You now have to be able to read these parameters. Check this question/answer on SO, it does exactly that : How to pass arguments to app built on Phonegap

My app inside iMessage UIActivityViewController

Instead of a URL scheme you need to add a document type to your app. Try adding the following fragment to your Info.plist:

<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>public.jpeg</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>public.jpeg</string>
</array>
</dict>
</array>

With this fragment (specifically with the LSItemContentTypes key) you declare that your app is an editor for documents that have the Uniform Type Identifier (UTI) public.jpeg. Because this UTI is declared by the system, I believe it is not necessary that you include the UTI declaration in your app's Info.plist.

You can find all system-declared UTI's in the Apple document titled System-Declared Uniform Type Identifiers. If you are new to UTI you should probably also read the Apple document Uniform Type Identifier Concepts.

Last but not least, don't forget to consult the Information Property List Key Reference to find out what you should specify for the Core Foundation keys CFBundleTypeRole and LSHandlerRank.

BTW: This excellent SO answer also has details about working with UTIs, especially if you ever need to declare your own app-specific UTI.



Related Topics



Leave a reply



Submit