#  XCodeGen configuration file
name: tutanota # Also known as tutanooota (while testing xcodegen)
options:
  useBaseInternationalization: true
  schemePathPrefix: "../" # Recommended for workspace based projects by XCodeGen devs
settings:
  base:
    PRODUCT_NAME: "tutanota"
    DEVELOPMENT_TEAM: "JKCH89Z3M9" # Tutao GmbH
    ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon"
    bundleIdPrefix: "de.tutao.tutanota"
# Include MUST come after settings because it depends on bundleIdPrefix
include:
  - path: "../xcodegen_common.yml"
  - path: "./common.yml"
targets:
  tutanota:
    templates: ["formatAndLint"]
    type: "application"
    sources:
      - path: "translations"
      - path: "tutanota"
        excludes:
          [
            "tutanota-web",
            "Sources/sdktest.swift",
          ]
        # XCode will not resolve symbolic links when adding a folder reference, so we will just use a relative path
      - path: "../build"
        name: "build"
        type: "folder"
        buildPhase: "resources"
      - path: "Plans.storekit"
    settings:
      base:
        PRODUCT_MODULE_NAME: "tutanota"
        ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: "YES"
        LD_RUNPATH_SEARCH_PATHS: "@executable_path/Frameworks"
        INFOPLIST_FILE: "tutanota/Info.plist"
        SWIFT_OBJC_BRIDGING_HEADER: "tutanota/Sources/tutanota-Bridging-Header.h"
        HEADER_SEARCH_PATHS:
          [
            "${PROJECT_DIR}/tutanota/include",
          ]
        CLANG_CXX_LANGUAGE_STANDARD: "gnu++14"
        GCC_PREPROCESSOR_DEFINITIONS:
          ["SQLITE_HAS_CODEC=1", "SQLITE_ENABLE_FTS5=1", "$(inherited)"]
        OTHER_CFLAGS[arch=*]:
          [
            "-DSQLITE_HAS_CODEC",
            "-DSQLITE_TEMP_STORE=2",
            "-DSQLITE_THREADSAFE=1",
            "-DSQLITE_EXTRA_INIT=sqlcipher_extra_init",
            "-DSQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown",
            "-DNDEBUG",
          ]
        SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD: "NO"
        SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: "NO"
        IPHONEOS_DEPLOYMENT_TARGET: "16.0"
      configs:
        Debug Development:
          PRODUCT_NAME: "Tuta D"
        Debug Staging:
          PRODUCT_NAME: "Tuta Test"
        Debug Production:
          PRODUCT_NAME: "Tuta Mail"
        Release Development:
          PRODUCT_NAME: "Tuta D"
        Release Staging:
          PRODUCT_NAME: "Tuta Test"
        Release Production:
          PRODUCT_NAME: "Tuta Mail"
      groups:
        - "codeSigning"
    dependencies:
      - package: Atomics
      - sdk: CryptoTokenKit.framework
        embed: false
      - package: DictionaryCoding
      - sdk: Foundation.framework
        embed: false
      - sdk: Security.framework
        embed: false
      - target: TutanotaNotificationExtension
        codeSign: false
      - target: TutanotaSharedFramework
      - target: TutanotaShareExtension
        codeSign: false
      - framework: tutasdk.framework
        embed: false
      - framework: StoreKit.framework
        embed: false
  tutanotaTests:
    templates: ["formatAndLint"]
    type: "bundle.unit-test"
    sources:
      - path: "tutanotaTests"
    settings:
      ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: "YES"
      CODE_SIGN_STYLE: "Automatic"
      LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
      BUNDLE_LOADER: "$(TEST_HOST)"
      INFOPLIST_FILE: "tutanotaTests/Info.plist"
      PRODUCT_BUNDLE_IDENTIFIER: "de.tutao.tutanotaTests"
      PRODUCT_NAME: "$(TARGET_NAME)"
      HEADER_SEARCH_PATHS:
        [
          "${PROJECT_DIR}/tutanota/include",
        ]
      TEST_HOST: "$(BUILT_PRODUCTS_DIR)/Tuta D.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Tuta D"
      SWIFT_OBJC_BRIDGING_HEADER: "tutanotaTests/tutanotaTests-Bridging-Header.h"
      SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD: "NO"
      SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: "NO"
      CLANG_CXX_LANGUAGE_STANDARD: "gnu++14"
      IPHONEOS_DEPLOYMENT_TARGET: "16.0"
    dependencies:
      - target: "tutanota"
      - target: "TutanotaSharedFramework"
  TutanotaSharedTests:
    type: "bundle.unit-test"
    platform: "iOS"
    sources:
      - path: "TutanotaSharedTests"
      - path: "MockingbirdMocks/TutanotaSharedTests-TutanotaSharedFrameworkMocks.generated.swift"
        optional: true # The file will be generated in the "Generate Mockingbird Mocks" stage
    settings:
      GCC_NO_COMMON_BLOCKS: "YES"
      CLANG_CXX_LANGUAGE_STANDARD: "gnu++20"
      ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS: "YES"
      IPHONEOS_DEPLOYMENT_TARGET: "16.0"
      LOCALIZATION_PREFERS_STRING_CATALOGS: "YES"
      SWIFT_EMIT_LOC_STRINGS: "YES"
      GENERATE_INFOPLIST_FILE: "YES"
      PRODUCT_NAME: "$(TARGET_NAME)"
      CODE_SIGN_STYLE: "Automatic"
      TEST_HOST: "$(BUILT_PRODUCTS_DIR)/Tuta D.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Tuta D"
      CURRENT_PROJECT_VERSION: "1"
      MARKETING_VERSION: "1.0"
    dependencies:
      - target: "tutanota"
      - target: "TutanotaSharedFramework"
        embed: false
      - package: "Mockingbird"
      - framework: tutasdk.framework
        embed: false
    preBuildScripts:
      - path: "buildScripts/generate-mockingbird.sh"
        name: "Generate Mockingbird Mocks"
        shell: "/bin/sh"
        showEnvVars: true
        basedOnDependencyAnalysis: false
        outputFiles:
          [
            "$(SRCROOT)/MockingbirdMocks/TutanotaSharedTests-TutanotaSharedFrameworkMocks.generated.swift",
          ]
schemes:
  tuta debug:
    build:
      targets:
        tutanota: ["analyze", "test", "run", "profile"]
        tutanotaTests: ["test"]
    run:
      config: "Debug Development"
      storeKitConfiguration: "Plans.storekit"
    test:
      config: "Debug Development"
      targets: ["tutanotaTests"]
    archive:
      config: "Release Development"
  tuta staging:
    build:
      targets:
        tutanota: "all"
        tutanotaTests: ["test"]
    run:
      config: "Debug Staging"
      storeKitConfiguration: "Plans.storekit"
    test:
      config: "Debug Staging"
      targets: ["tutanotaTests"]
    archive:
      config: "Release Staging"
  tuta prod:
    build:
      targets:
        tutanota: "all"
        tutanotaTests: ["test"]
    run:
      config: "Debug Production"
      storeKitConfiguration: "Plans.storekit"
    test:
      config: "Debug Production"
      targets: ["tutanotaTests"]
    archive:
      config: "Release Production"
