4

I have a "Run Script" phase on my target that renders a PDF manual. I want to include this manual in my Xcode archive of the product.

How do I tell Xcode from a script what files to add to its archive during the Archive phase?

Currently, the script places the PDF in BUILT_PRODUCTS_DIR, but this appears not to suffice.

xsltproc -o >(fop -fo - -pdf "$BUILT_PRODUCTS_DIR/doc/$TARGET_NAME.pdf") \                                                                                                                                                       
    --stringparam use.extensions 0 \ 
    --stringparam fop1.extensions 1 \ 
    --stringparam draft.mode no \
    --stringparam admon.graphics 1 \ 
    --stringparam admon.graphics.extension .svg \
    /opt/local/share/xsl/docbook-xsl/fo/docbook.xsl \
    "$TARGET_NAME/manual.xml"
lhunath
  • 120,288
  • 16
  • 68
  • 77

2 Answers2

7

You can add a post build script to the Archive action, using the ARCHIVE_PRODUCTS_PATH environment variable.

  1. Select the Product menu > Edit Scheme
  2. Expand the Archive action
  3. Add a post action run script:

    cp "/path/to/some/file" "${ARCHIVE_PRODUCTS_PATH}/somefile"
    

Your file will be included in the archive, you can see it by showing the package contents of the archive, or sharing the built products of the archive.

You can see all the environment variables available by adding a run script that runs printenv then checking the output in the Console application in system.log.

Cristy
  • 236
  • 1
  • 4
  • 8
0

I assume that you mean that you want to include the PDF in the application's bundle. Do the following:

  1. Open your Xcode project and create an empty file with your PDF's name in the project's Resources group.
  2. Click the project icon and look at the project's Build Phases. Check the Copy Bundle Resources phase to make sure that your new file is among the resources to be copied.
  3. Set up the script that builds your PDF file such that it replaces the empty file. It simply needs to delete the existing file and add a new file with the same name in the same location.

Now, when you build your project, the PDF file should be added to your app's bundle along with the other resources.

If you mean instead that you want the PDF to be included in the archive, but separate from the application's bundle, I'm not sure that there's a way to do that. The Xcode archive is basically just the zipped application and the symbol file.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • Indeed not; I want it installed alongside the bundle in the archive. Just like dependent libraries and header files can be. – lhunath Sep 02 '11 at 05:10