# This file contains the fastlane.tools configuration
# for the iOS half of the Skip app.
# You can find the documentation at https://docs.fastlane.tools

default_platform(:ios)

lane :assemble do |options|
  # only build the iOS side of the app
  ENV["SKIP_ZERO"] = "true"
  build_app(
    scheme: "PediFoods App",
    sdk: "iphoneos",
    export_method: ENV["BITRISE_DISTRIBUTION_METHOD"] || "app-store",
    xcconfig: "fastlane/AppStore.xcconfig",
    xcargs: "-skipPackagePluginValidation -skipMacroValidation",
    derived_data_path: "../.build/Darwin/DerivedData",
    output_directory: "../.build/fastlane/Darwin",
    skip_archive: ENV["FASTLANE_SKIP_ARCHIVE"] == "YES",
    skip_codesigning: ENV["FASTLANE_SKIP_CODESIGNING"] == "YES"
  )
end

# ─── Upload IPA to TestFlight (Bitrise's xcode-archive step already built it) ──
lane :beta do |options|
  upload_to_testflight(
    ipa: ENV["BITRISE_IPA_PATH"],
    skip_waiting_for_build_processing: true
  )
end

# ─── Push metadata + upload IPA to App Store (Bitrise already built it) ───────
lane :release do |options|
  deliver(
    ipa: ENV["BITRISE_IPA_PATH"],
    app_rating_config_path: "fastlane/metadata/rating.json",
    release_notes: { default: "Fixes and improvements." },
    skip_screenshots: false,
    skip_metadata: false,
    force: true,
    submit_for_review: false,
    automatic_release: false,
    run_precheck_before_submit: false
  )
end

