Skip to main content

Use xcodebuild to package iOS apps

To package your iOS applications the quickest way, you can use xcodebuild in your terminal.

Before you begin:

  • You have installed the Command Line Tools for Xcode.

  • You have installed or updated gen-ir.

To complete this task:

  1. Open your terminal, and then change directory to your project.

  2. Run the following command:

    xcodebuild clean
  3. If you have an Xcode Workspace, run the following command:

    note

    You must change the invocation of xcodebuild to match your project. You should at least replace MyApp and MyScheme.

    xcodebuild archive \
    -workspace MyApp.xcworkspace \
    -scheme MyScheme \
    -destination generic/platform=iOS \
    -configuration Debug \
    -archivePath MyApp.xcarchive \
    DEBUG_INFORMATION_FORMAT=dwarf-with-dsym \
    ENABLE_BITCODE=NO \
    > MyApp.log.txt

    Or, if you have an Xcode project, run the following command:

    xcodebuild archive \
    -project MyApp.xcodeproj \
    -scheme MyScheme \
    -destination generic/platform=iOS \
    -configuration Debug \
    -archivePath MyApp.xcarchive \
    DEBUG_INFORMATION_FORMAT=dwarf-with-dsym \
    ENABLE_BITCODE=NO \
    > MyApp.log.txt

    Optionally, you can use -archivePath to set a different output location for the archive, and you can use > MyApp.log.txt to set a different output location for the build log of the archive.

  4. Run gen-ir with your build log and the archive path in the following command. Ensure MyApp.log.txt points to the exported build log, and that MyApp.xcarchive/ is the newly-created xcarchive.

    Xcode workspace:

    gen-ir MyApp.log.txt MyApp.xcarchive/ --project-path MyApp.xcworkspace

    Xcode project:

    gen-ir MyApp.log.txt MyApp.xcarchive/ --project-path MyApp.xcodeproj
  5. Create a new archive. For example, run the following zip command. Ensure you place the xcarchive at the root of this ZIP file and do not zip subfolders or add additional paths.

    zip -r MyApp.zip MyApp.xcarchive
  6. Upload your iOS application to the Veracode Platform for analysis. See how to submit an application for analysis.

  7. Optionally, to upload your archives with Veracode Software Composition Analysis, add the Podfile.lock file to the root of another zipped archive. Keep this new zipped archive separate from the one that contains the .xcarchive folder, as shown in the following command:

    zip MyApp-Podfile.zip Podfile.lock

    Upload MyApp-Podfile.zip to the same scan as the MyApp.zip that you previously uploaded.