How do I sign and export IPA via CI?

To sign and export an IPA file via Continuous Integration (CI), you can use tools like Fastlane or Xcode command line tools. Here's a simple example of how to accomplish this using Fastlane, which simplifies the process of building and signing iOS apps in a CI environment.


# Fastfile configuration for building and exporting IPA
default_platform(:ios)

platform :ios do
  desc "Build and sign the iOS app"
  lane :build_and_export do
    # Specify necessary environment variables
    ENV["MATCH_GIT_URL"] = "https://github.com/your/repo.git"
    ENV["MATCH_PASSWORD"] = "your_match_password"

    # Sync certificates and provisioning profiles
    match(type: "appstore")  # or "development", "adhoc", etc.
    
    # Build the app
    gym(scheme: "YourAppScheme")
    
    # Export the IPA
    export_options = {
      method: "app-store"
    }
    
    # Use `export_ipa` method to export IPA with specified options
    export_ipa(
      ipa: "./path/to/YourApp.ipa",
      export_options: export_options
    )
  end
end
    

Continuous Integration CI iOS build automation Fastlane export IPA code signing Xcode