Resource files in OS X bundle: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=How to add resource files to an OS X application bundle=
[[Category:HowTo]]


On OS X, applications are delivered as so called “bundles”. That’s just a directory with a predefined structure and the suffix .app. You can learn more about the structure in the [http://doc.qt.nokia.com/4.7/deployment-mac.html OS X specific deployment instructions] ''[doc.qt.nokia.com]'' of the Qt documentation and in [http://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW13 Apple’s own docs about application bundles] ''[developer.apple.com]''.
= How to add resource files to an OS X application bundle =


If you have additional files that need to be distributed along your application that cannot be put into the [http://doc.qt.nokia.com/4.7/resources.html qrc resources] ''[doc.qt.nokia.com]'' (eg. <span class="caps">QML</span> files), they have to be installed in the right place. For resource files this is YourFancyApplication.app/Contents/Resources.
On OS X, applications are delivered as so called &quot;bundles&amp;quot;. That's just a directory with a predefined structure and the suffix .app. You can learn more about the structure in the &quot;OS X specific deployment instructions&amp;quot;:http://doc.qt.nokia.com/4.7/deployment-mac.html of the Qt documentation and in &quot;Apple's own docs about application bundles&amp;quot;:http://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW13.
 
If you have additional files that need to be distributed along your application that cannot be put into the &quot;qrc resources&amp;quot;:http://doc.qt.nokia.com/4.7/resources.html (eg. QML files), they have to be installed in the right place. For resource files this is YourFancyApplication.app/Contents/Resources.


You can let qmake do all the copy work for you. Just add a snippet like this to your .pro file:
You can let qmake do all the copy work for you. Just add a snippet like this to your .pro file:


You can create more snippets like this, for example to group the resources by type.
<code><br />APP_QML_FILES.files = path/to/file1.qml path/to/file2.qml<br />APP_QML_FILES.path = Contents/Resources<br />QMAKE_BUNDLE_DATA += APP_QML_FILES<br /></code>
 
===Categories:===
 
* [[:Category:HowTo|HowTo]]

Revision as of 09:25, 24 February 2015


How to add resource files to an OS X application bundle

On OS X, applications are delivered as so called "bundles&quot;. That's just a directory with a predefined structure and the suffix .app. You can learn more about the structure in the "OS X specific deployment instructions&quot;:http://doc.qt.nokia.com/4.7/deployment-mac.html of the Qt documentation and in "Apple's own docs about application bundles&quot;:http://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW13.

If you have additional files that need to be distributed along your application that cannot be put into the "qrc resources&quot;:http://doc.qt.nokia.com/4.7/resources.html (eg. QML files), they have to be installed in the right place. For resource files this is YourFancyApplication.app/Contents/Resources.

You can let qmake do all the copy work for you. Just add a snippet like this to your .pro file:

<br />APP_QML_FILES.files = path/to/file1.qml path/to/file2.qml<br />APP_QML_FILES.path = Contents/Resources<br />QMAKE_BUNDLE_DATA += APP_QML_FILES<br />