Create a bundle from your app

I’m trying to make my app create a bundle as it’s saved file. This bundle will contain an SQLite database.
Can’t find much info on it so I tried to make my app create a folder from a SaveAsDialog and assign a filetype to that folder.

dlg.InitialDirectory=SpecialFolder.Desktop
  dlg.promptText="xxxxx"
  dlg.SuggestedFileName="xxxxxx"
  dlg.Title="xxxxxx"
  dlg.ActionButtonCaption = "Create"
  dlg.Filter = FileTypes.xxxxx
  dbBundle=dlg.ShowModal()
dbBundle.CreateAsFolder

Using App Wrapper Mini to have it set the document to LSTypeIsPackage=1.
On my dev machine (10.8.4) this is actually working like it should. A bundle is created with my custom file extension.

But when I try the app on 10.7, a regular FOLDER is created instead and it’s acting like…surprise…a folder!

Does anyone know how to properly have your app create a bundle? :slight_smile:

Ok. A restart of the machine with 10.7 made things work.
Any ideas why?

Launch Services cache update.

Sounds like that could be it :slight_smile:
Any idea if there’s anything that can be done to fix that? It’s not so good if my apps files shows up as folders on a computer after the first install w/o a restart :confused:
Wonder if this will be an issue when the app is installed from MAS?

Apparently this Terminal command will flush the cache…

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

Thanks, but I don’t think a sandboxed app can run that :confused:

Stupid me. The package needed a PkgInfo file in it :wink:
All fixed!

I am trying to understand how to create a document bundle, if I wanted to create one from my app.

From what I can see of the iPhoto Library one in Pictures, it contains indeed a ‘Content’ folder and a pkginfo file which if I understand right makes it able to show characteristics of an iPhoto document.

From what I could glean on Internet, the content of pkginfo is composed of twice 4 characters. But information is hard to come by. Does it has any relationship with Mac Type and Mac creator ? In my apps, it is APPL???, and in the iPhoto Library iPlbiPho.
Looking at the iPhoto info.plist, I found

<key>UTTypeTagSpecification</key> <dict> <key>com.apple.ostype</key> <array> <string>iPlb</string> </array>

and

<key>CFBundleSignature</key> <string>iPho</string>

Are they the two informations necessary to build the pkginfo string ?

I also noted there is no info.plist in the iPhoto Library, contrary to an app bundle.

The other question is : how does one create a folder with the attributes of a bundle, so it opens with right click “Show package content” instead of double click, or if double clicked, is opened by the corresponding application ? Is it possible through Xojo or is there a command line way ?

Just when I thought I was starting to understand…

The latest Pages app saves bundles with the extension .pages

Inside, no pkginfo file at all :frowning:

[quote=130545:@Michel Bujardet]Just when I thought I was starting to understand…

The latest Pages app saves bundles with the extension .pages

Inside, no pkginfo file at all :([/quote]

Document Packages, perhaps?

https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/DocumentPackages/DocumentPackages.html#//apple_ref/doc/uid/10000123i-CH106-SW1

[quote=130546:@Eduardo Gutierrez de Oliveira]Document Packages, perhaps?

https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/DocumentPackages/DocumentPackages.html#//apple_ref/doc/uid/10000123i-CH106-SW1[/quote]

Great. Thank you Eduardo :slight_smile: