name: Clawdbot
options:
  bundleIdPrefix: com.clawdbot
  deploymentTarget:
    iOS: "17.0"
  xcodeVersion: "16.0"

packages:
  ClawdbotKit:
    path: ../shared/ClawdbotKit
  Swabble:
    path: ../../Swabble

schemes:
  Clawdbot:
    shared: true
    build:
      targets:
        Clawdbot: all
    test:
      targets:
        - ClawdbotTests

targets:
  Clawdbot:
    type: application
    platform: iOS
    sources:
      - path: Sources
    dependencies:
      - package: ClawdbotKit
      - package: ClawdbotKit
        product: ClawdbotChatUI
      - package: Swabble
        product: SwabbleKit
      - sdk: AppIntents.framework
    preBuildScripts:
      - name: SwiftFormat (lint)
        basedOnDependencyAnalysis: false
        inputFileLists:
          - $(SRCROOT)/SwiftSources.input.xcfilelist
        script: |
          set -euo pipefail
          export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
          if ! command -v swiftformat >/dev/null 2>&1; then
            echo "error: swiftformat not found (brew install swiftformat)" >&2
            exit 1
          fi
          swiftformat --lint --config "$SRCROOT/../../.swiftformat" \
            --filelist "$SRCROOT/SwiftSources.input.xcfilelist"
      - name: SwiftLint
        basedOnDependencyAnalysis: false
        inputFileLists:
          - $(SRCROOT)/SwiftSources.input.xcfilelist
        script: |
          set -euo pipefail
          export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
          if ! command -v swiftlint >/dev/null 2>&1; then
            echo "error: swiftlint not found (brew install swiftlint)" >&2
            exit 1
          fi
          swiftlint lint --config "$SRCROOT/.swiftlint.yml" --use-script-input-file-lists
    settings:
      base:
        CODE_SIGN_IDENTITY: "Apple Development"
        CODE_SIGN_STYLE: Manual
        DEVELOPMENT_TEAM: Y5PE65HELJ
        PRODUCT_BUNDLE_IDENTIFIER: com.clawdbot.ios
        PROVISIONING_PROFILE_SPECIFIER: "com.clawdbot.ios Development"
        SWIFT_VERSION: "6.0"
    info:
      path: Sources/Info.plist
      properties:
        CFBundleDisplayName: Clawdbot
        CFBundleIconName: AppIcon
        UILaunchScreen: {}
        UIApplicationSceneManifest:
          UIApplicationSupportsMultipleScenes: false
        UIBackgroundModes:
          - audio
        NSLocalNetworkUsageDescription: Clawdbot discovers and connects to your Clawdbot bridge on the local network.
        NSAppTransportSecurity:
          NSAllowsArbitraryLoadsInWebContent: true
        NSBonjourServices:
          - _clawdbot-bridge._tcp
        NSCameraUsageDescription: Clawdbot can capture photos or short video clips when requested via the bridge.
        NSMicrophoneUsageDescription: Clawdbot needs microphone access for voice wake.
        NSSpeechRecognitionUsageDescription: Clawdbot uses on-device speech recognition for voice wake.

  ClawdbotTests:
    type: bundle.unit-test
    platform: iOS
    sources:
      - path: Tests
    dependencies:
      - target: Clawdbot
      - package: Swabble
        product: SwabbleKit
    settings:
      base:
        PRODUCT_BUNDLE_IDENTIFIER: com.clawdbot.ios.tests
        SWIFT_VERSION: "6.0"
        TEST_HOST: "$(BUILT_PRODUCTS_DIR)/Clawdbot.app/Clawdbot"
        BUNDLE_LOADER: "$(TEST_HOST)"
    info:
      path: Tests/Info.plist
      properties:
        CFBundleDisplayName: ClawdbotTests
