# \[OS X\] How do I create a bundle "file" ?

**URL:** <https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854>\
**Category:** macOS\
**Created:** [October 24, 2013, 12:14pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854 "2013-10-24T12:14:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 24, 2013, 12:14pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/1 "2013-10-24T12:14:40Z")

</div>

Hi,

As far as I understand, under OS X, a bundle file is a Folder with “special” extension.

I was thinking to use that feature, but I failed to find documentation on how to create such 'file’

All ideas are welcome.

---

<div class="post-metadata">

**Author:** ![Mark\_Walsh](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/c77e96/32.png) [@Mark\_Walsh](https://forum.xojo.com/u/Mark_Walsh)\
**Post date:** [October 24, 2013, 12:53pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/2 "2013-10-24T12:53:31Z")

</div>

I don’t know the exact specs, but a bundle isn’t simply a folder with a specific extension. It requires a specific hierarchy [quote]A package is any directory that the Finder presents to the user as if it were a single file.  
A bundle is a directory with a standardized hierarchical structure that holds executable code and the resources used by that code.[/quote]

I took that from the following link, which may be helpful:  
[https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/AboutBundles/AboutBundles.html](https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/AboutBundles/AboutBundles.html)

---

<div class="post-metadata">

**Author:** ![Albin\_Kiland](https://forum.xojo.com/user_avatar/forum.xojo.com/albin_kiland/32/1028_2.png) [@Albin\_Kiland](https://forum.xojo.com/u/Albin_Kiland)\
**Post date:** [October 24, 2013, 1:47pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/3 "2013-10-24T13:47:06Z")

</div>

More specifically, you should look at DocumentPackages 🙂  
[https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/DocumentPackages/DocumentPackages.html](https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/DocumentPackages/DocumentPackages.html)

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [October 24, 2013, 2:49pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/4 "2013-10-24T14:49:48Z")

</div>

Your app simply creates a folder.  
The bundle thing comes from entries in your app’s info.plist.

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [October 25, 2013, 12:56am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/5 "2013-10-25T00:56:43Z")

</div>

Document Packages are easier than you think and you can start by simply creating a folder, giving it an extension and stuffing your data into that folder.

Download the free trial of [Shine](http://www.ohanaware.com/shine/Shine.zip) , throw in a photo and save the document, then right click on it and select “Show Package” contents.

The complicated part comes from editing your plist to make the OS recognize the folder as a document. This requires that your app’s plist be edited outside of Xojo. Both App Wrapper and App Wrapper Mini have provision for this.

If you want to do it manually, you need to add “LSTypeIsPackage” (with the value of “YES”) to the document type in the “CFBundleDocumentTypes” section of the plist. Take at a look at Shine’s plist to see an example.

Once you’ve got it working, you can get into some cooler stuff.

# if you add a info.plist file to your document package, you can alter the properties in the get info window, again Shine does this (it also stores the document data in the plist file).

# You can use Marc’s trick of including a “QuickLook” folder within the package allowing people to QuickLook at your document.

# In Shine, when you save the document, we store the original image within the package, so if the user wants their original photo back, it’s there!

# You can provide your own incremental backup system within the bundle (again Shine does this).

# I choose to add an extra file, because if the package is on a computer without the app, it appears as a regular folder, I placed the extra file “Shine Document.txt” to help the user identify where this package came from (although I could have done a better job).

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [October 25, 2013, 12:59am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/6 "2013-10-25T00:59:05Z")

</div>

[quote=42240:@Mark Walsh]I don’t know the exact specs, but a bundle isn’t simply a folder with a specific extension. It requires a specific hierarchy

I took that from the following link, which may be helpful:  
[https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/AboutBundles/AboutBundles.html[/quote]](https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/AboutBundles/AboutBundles.html%5B/quote%5D)  
Ah… Yes I just re-read your message and there is a difference between a bundle and a document package. The key element I can think of is that a bundle contains some form of executable code and a bundle will always appear to the user as a single file.

A document package is much lighter and designed for purely data, if the app that created the docPac is not on the system, it will show up as a regular folder.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 25, 2013, 8:36am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/7 "2013-10-25T08:36:39Z")

</div>

Thank you all for the answers.

It seems to me that I was wrong (bundle), a document package looks like what I really need.

I want to put in a “container” a bunch of data my application will read. I actually use a folder to keep together data (tons of folders with 3 files each)…

---

<div class="post-metadata">

**Author:** ![Horst\_Jehle](https://forum.xojo.com/user_avatar/forum.xojo.com/horst_jehle/32/5432_2.png) [@Horst\_Jehle](https://forum.xojo.com/u/Horst_Jehle)\
**Post date:** [October 28, 2013, 10:30am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/8 "2013-10-28T10:30:16Z")

</div>

Simply create a folder with the extension “.bundle”, put your files in this folder - that’s all. You can access your files with a normal FolderItem (MyFolder.bundle).

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 28, 2013, 10:35am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/9 "2013-10-28T10:35:59Z")

</div>

Thanks Horst.

May works OK if I change the bundle icon (fine), but a double click in the bundle runs the Terminal.

You know how users can be And I may want to allow double-click to open the bundle with my application. Idea ?

Emile

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 28, 2013, 10:37am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/10 "2013-10-28T10:37:54Z")

</div>

And the bundle file have “.bundle” as ‘file’ extension.

---

<div class="post-metadata">

**Author:** ![Albin\_Kiland](https://forum.xojo.com/user_avatar/forum.xojo.com/albin_kiland/32/1028_2.png) [@Albin\_Kiland](https://forum.xojo.com/u/Albin_Kiland)\
**Post date:** [October 28, 2013, 11:37am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/11 "2013-10-28T11:37:26Z")

</div>

> [@42830:@Emile Schwarz](#):
>
> And the bundle file have “.bundle” as ‘file’ extension.

It does not need that. Use your own 🙂  
Find your extension in your apps info.plist file and add:

> [@](#):
>
> LSTypeIsPackage  
> 1

This way the system knows that the folder with your extension is to be treated as a document package.

---

<div class="post-metadata">

**Author:** ![Albin\_Kiland](https://forum.xojo.com/user_avatar/forum.xojo.com/albin_kiland/32/1028_2.png) [@Albin\_Kiland](https://forum.xojo.com/u/Albin_Kiland)\
**Post date:** [October 28, 2013, 11:59am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/13 "2013-10-28T11:59:49Z")

</div>

I’ll create a quick example for you 🙂

---

<div class="post-metadata">

**Author:** ![Albin\_Kiland](https://forum.xojo.com/user_avatar/forum.xojo.com/albin_kiland/32/1028_2.png) [@Albin\_Kiland](https://forum.xojo.com/u/Albin_Kiland)\
**Post date:** [October 28, 2013, 12:10pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/14 "2013-10-28T12:10:17Z")

</div>

Here’s an example I just created in about 5 minso treat it as an EXAMPLE(almost pseudo code ;)) but it should be working or at least give you some ideas 🙂  
[https://app.box.com/s/u3eu26t6fzyl5muijt8l](https://app.box.com/s/u3eu26t6fzyl5muijt8l)

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [October 29, 2013, 12:47am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/15 "2013-10-29T00:47:07Z")

</div>

> [@42828:@Horst Jehle](#):
>
> Simply create a folder with the extension “.bundle”, put your files in this folder - that’s all. You can access your files with a normal FolderItem (MyFolder.bundle).

I personally wouldn’t advise in doing so, as bundle is a generic term and trying to associate bundle with your application, may potentially cause system issues as the system uses .bundle. Instead use your own file extension so that the files can be associated (double clicked) with your application.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 29, 2013, 9:04am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/16 "2013-10-29T09:04:47Z")

</div>

Sam,

that is (I think) what I want to do: put my application data into a master container.  
[one master container for each subject: this is a multimedia project]

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [October 29, 2013, 2:28pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/17 "2013-10-29T14:28:34Z")

</div>

> [@42977:@Sam Rowlands](#):
>
> I personally wouldn’t advise in doing so, as bundle is a generic term and trying to associate bundle with your application, may potentially cause system issues as the system uses .bundle. Instead use your own file extension so that the files can be associated (double clicked) with your application.

Ditto. I’m pretty sure that on my system, double clicking a .bundle file in Finder just digs into its contents.

---

<div class="post-metadata">

**Author:** ![Simon\_Berridge](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@Simon\_Berridge](https://forum.xojo.com/u/Simon_Berridge)\
**Post date:** [October 29, 2013, 7:07pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/18 "2013-10-29T19:07:47Z")

</div>

I think your original question was “How do I create a package Folder on the Mac?”

If that is true and you are a holder of the MBS PlugIns then the following code will do that for you:

[code] const kHasBundle = &h2000  
f.CreateAsFolder  
dim fl as integer = f.GetFolderFlagsMBS

if fl \< 0 then // failed  
fl = kHasBundle  
else  
fl = BitwiseOr(fl, kHasBundle)  
end if

dim e as integer = f.SetFolderFlagsMBS(fl)

if e = 0 then  
Return True  
else  
Return False  
end if  
[/code]  
I use this to create my ‘folder’ that is a package folder and it shows as a ‘file’ in Finder. I can then add folders within and, of course, add the files that I need for my app to access. I create a special extension and associate that with my app.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 30, 2013, 9:18am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/19 "2013-10-30T09:18:51Z")

</div>

Joe:

create a new folder, change its name to “my folder.bundle” (that is all, nothing was put inside the folder) and double click on it :

a. Change the icon from Folder to some kind of white Lego form artwork,  
b. runs the terminal (and displays the bundle name

Mavericks / MacBook Pro

Of course, your milestone may vary (for unknown reasons).

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [October 30, 2013, 9:20am UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/20 "2013-10-30T09:20:17Z")

</div>

Thanks Simon,

All I want is a way to place multimedia data in a convenient place (I actually use a master folder).

And, no, I do not have Christians plugins.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:54pm UTC](https://forum.xojo.com/t/os-x-how-do-i-create-a-bundle-file/11854/21 "2020-10-29T16:54:34Z")

</div>


