Mac app store productbuild

2019-04-06 11:38发布

问题:

Apple's document on submitting an app to the Mac App store contains this example use of the command productbuild, from in /Developer/usr/bin/.

productbuild \
--component build/Release/Sample.app /Applications \
--sign "3rd Party Mac Developer Installer: Name1 Name2" \
--product product_definition.plist Sample.pkg

When I run this command on my Sample app, I get the error:

productbuild: error: No product definition plist found at "product_definition.plist".

What is this product_definition.plist, where should it come from, what should be inside it, and what tool should be used to create this plist?

回答1:

From the Apple document you linked: "You should specify a single component, a signature, and (optionally) a product definition file."

Unless you have a specific requirement, you don't need a product definition file. If you need it, the man page of productbuild has a lot of information. It is just a plist dictionary, like this example:

<?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>

I've verified that Xcode doesn't use a product definition file when you share an archived application as package. This is the actual command line:

/usr/bin/productbuild --component <path-to-xcarchive>/Cool.app 
                      /Applications 
                      <tmp-path>/package.pkg 
                      --sign 3rd Party Mac Developer Installer


回答2:

If you run man productbuild and look for the section PRODUCT DEFINITION PROPERTY LIST which starts with

PRODUCT DEFINITION PROPERTY LIST
 When you use productbuild to synthesize a distribution (e.g. with the --component option), you can specify additional parameters and
 requirements in a separate property list file, specified with the --product option. At the top level, this property list is a dictio-
 nary, with the following keys:

 Key                       Description
 os                        Minimum allowable OS versions (array of strings)
 arch                      Supported architectures (array of strings)
 ram                       Minimum required RAM in gigabytes (real)
 bundle                    Specific bundles that must exist on the system (array of dictionaries)
 all-bundles               Are all of the bundles specified required? (Boolean)
 gl-renderer               Required OpenGL capabilities (string)
 cl-device                 Required OpenCL capabilities (string)
 single-graphics-device    Must OpenGL and OpenCL requirements be met by a single device? (Boolean)
 home                      Should installation be allowed in user home directory? (Boolean)

Lots more information is given, which you should be able to generate with XCode or a text editor. Within XCode just create a new plist and add the key/value pairs according to your requirements and the possible values listed in the man file.