Technical Q&A QA1748

Specifying required OpenGL capabilities for the Mac App Store

Q:  How can I prevent customers who do not have the required OpenGL capabilities from purchasing my application from the Mac App Store?

A: When building an application on Mac OS X Lion 10.7 or later, you can specify OpenGL requirements when packaging it for the Mac App Store. This will insure that only customers who have the appropriate graphics hardware will be able to purchase your application.

It is achieved by specifying additional archiving requirements in a plist file. Select File > New > New File... from the Xcode menu, then choose the "Property List" template under the "Resource" category in the "Mac OS X" section, and follow the ensuing instructions to create a plist file. Add the gl-renderer key and an appropriate string value in the resulting plist to specify your application's OpenGL requirements.

The gl-renderer key specifies a predicate, against which each of the OpenGL hardware renderers will be checked. To successfully purchase and install the application, at least one of the renderers on the customer's machine must match the requirements of the predicate. Otherwise, the transaction will not go through, and the customer will be notified that he/she doesn't have the required graphics hardware to run the application. The following key paths are available for you to form the definition string:

If you want to check two or more conditions, you can use logical operators, AND and/or OR, as shown in the following listing:

Listing 1  Checking more than one condition

( version >= 2.0
    OR ( ( 'GL_ARB_texture_float' IN extensions OR 'GL_ATI_texture_float' IN extensions )
           AND 'GL_ARB_vertex_blend' IN extensions ) )
AND ( limits.GL_MAX_TEXTURE_SIZE >= 1024 AND limits.GL_MAX_TEXTURE_STACK_DEPTH > 8 )

Below are a couple simple real-world examples of the plist for your reference:

Listing 2  Plist with the gl-renderer key. The application will not allow purchasing on Macs that do not support GL_APPLE_float_pixels (e.g., the Intel GMA 950 and GMA X3100).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>gl-renderer</key>
    <string>( 'GL_APPLE_float_pixels' IN extensions )</string>
</dict>
</plist>

Listing 3  Plist with the gl-renderer key. The application will not allow purchasing on Macs that do not support GL_ARB_texture_rg (e.g., the Intel GMA 950, GMA X3100, and NVidia GeForce 7 series).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>gl-renderer</key>
    <string>( 'GL_ARB_texture_rg' IN extensions )</string>
</dict>
</plist>

When you have the plist file ready, in Xcode 4, you can provide it using the "Pre-install Requirements Property List" build setting. See Figure 1 for an example.

Figure 1  The Pre-install Requirements Property List build setting in Xcode 4

Xcode 4 will automatically supply the plist to productbuild when you create the package from the Organizer and submit it to the Mac App Store.

Xcode 3 does not support using a production definition plist. If you choose to build your application with Xcode 3, you need to run the productbuild command directly for archiving your application and supply the plist via the --product option. See Listing 4 for an example.

Listing 4  The Xcode 3 way for supplying a production definition plist

productbuild \
    --component build/Release/Sample.app /Applications \
    --product product_definition.plist \
    Sample.pkg

See OpenGL Capabilities Tables for a complete listing of supported features by GPU class.

See man page of the productbuild command on Mac OS X Lion 10.7 or later for full details of the command.

See Submitting to the Mac App Store for more information on how to submit your application using Application Loader or within Xcode.



Document Revision History


DateNotes
2012-02-22

Added how to provide a production definition plist using the Pre-install Requirements Property List build setting in Xcode 4.

2011-08-10

New document that discusses how to specify required OpenGL capabilities for the Mac App Store so that only customers who have the appropriate graphics hardware will be able to purchase your application.