8

I'm busy working on a Jenkins build that will be building iOS applications. I have managed to create an archive successfully with this command:

xcodebuild archive -archivePath build/app.xcarchive 

Now I'm trying to export that archive with specifying the output file name, but can't get this to work.In the example below I want an output file called app.ipa, but all I get is a folder called app.ipa with an ipa file inside name .ipa

xcrun xcodebuild -exportArchive -exportPath build/app.ipa -archivePath build/app.xcarchive/ -exportOptionsPlist exportOptions.plist

Outputs a file /build/app.ipa/<projectname>.ipa

Apples documentation for XCodeBuild says that you can specify the output path including file name:

-exportPath destinationpath Specifies the destination for the exported product, including the name of the exported file.

https://web.archive.org/web/20170620204608/https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

The reason for this is that I would like to keep the build generic so that any project I send through it will result in an app.ipa without me needing to keep track of project names and different output files etc.

Denis Murphy
  • 1,137
  • 1
  • 11
  • 21
Craigt
  • 3,418
  • 6
  • 40
  • 56
  • What is `xcrun xcodebuild`. I never saw something like that before. – midori Oct 03 '16 at 17:44
  • "xcrun provides a means to locate or invoke developer tools from the command-line, without requiring users to modify Makefiles or otherwise take inconvenient measures to support multiple Xcode tool chains." https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html – Craigt Oct 04 '16 at 05:39
  • 2
    Yes, earlier without -exportOptionsPlist, the same command create the specified file, now after 8.3, its making a folder and inside that folder the .ipa is. Is there any workaround except using mv? – karim Apr 25 '17 at 07:50

4 Answers4

6

This is filed as a bug in open radar: "xcodebuild exportArchive -exportPath" does not write what it's documented to write

mbi
  • 581
  • 5
  • 13
4

For XCode 11 and earlier:

ArchiveAction tag in .xcscheme file can have attribute customArchiveName which can be set to anything you like.

   <ArchiveAction
      buildConfiguration = "AdHoc_Example"
      customArchiveName = "app"
      revealArchiveInOrganizer = "YES">
   </ArchiveAction>
</Scheme>

This will give you app.ipa always when you export the archive through -exportOptionsPlist.

O'Rooney
  • 2,878
  • 2
  • 27
  • 41
RAM237
  • 903
  • 11
  • 17
  • 2
    In XCode 12 it doesn't seem to work anymore. Wander if this is a bug or a feature :) – Sasho Oct 01 '20 at 10:40
  • @Sasho `The “.ipa” file name is now sourced from the targets Info.plist file under the CFBundleName` https://www.wundermanthompson.com/insight/xcodebuild-exportarchive-changes-in-xcode12 – Copy Run Start Nov 19 '20 at 18:09
3

If you do a xcodebuild --help it says:

-exportPath PATH specifies the destination for the product exported from an archive

hmmm.

To do a workaround you can rename your file afterwards.

mv "oldname" "newname"
midori
  • 450
  • 6
  • 19
  • Hi, I would have liked to accomplish this without knowing what the "oldname" is. I want to repurpose this same build script for multiple projects and wont know what the output file name is. – Craigt Oct 04 '16 at 05:41
  • So did apple get rid of the ability to specify a filename for the .ipa file? Seems weird they let you specify it for the .xcarchive but not the resulting .ipa. – Bungles Dec 28 '16 at 18:59
1

You can also edit your Info.plist:

<key>CFBundleName</key>
<string>app</string>

Will give ipa.app

If you omit it, it will have the name of your .xcarchive file (Scheme name by default)

cf: https://stackoverflow.com/a/7908397

Jo.
  • 64
  • 1
  • 3