# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.29.0"

#default_platform :ios

##### iOS platform
##############################################
platform :ios do
  before_all do
  end

  lane :install do
    bundle_install
    cocoapods(use_bundle_exec: true, try_repo_update_on_error: true)
  end

  lane :build do
    install

    swiftlint(
      mode: :lint, 
      config_file: ".swiftlint.yml",
      executable: "Pods/SwiftLint/swiftlint"
    )

    xcodebuild(
      project: "PinLayout.xcodeproj",
      scheme: "PinLayout-iOS",
      destination: "name=iPhone 8 Plus,OS=11.2",
      #configuration: "Debug",
      build: true,
      clean: true
    )

    xcodebuild(
      project: "PinLayout.xcodeproj",
      scheme: "PinLayout-tvOS",
      destination: "name=Apple TV",
      build: true,
      clean: true
    )

    xcodebuild(
      workspace: "PinLayout.xcworkspace",
      scheme: "PinLayoutSample",
      build: true,
      clean: true,
      #destination: "name=iPhone 8 Plus,OS=11.2",
      destination: "generic/platform=iOS\" CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=\""
    )
  end

  lane :tests do
    scan(
      scheme: "PinLayoutSample", 
      workspace: "PinLayout.xcworkspace",
      devices: [
        "iPhone 7 (10.2)",
        "iPhone 8 (11.4)",
        "iPad Air (11.4)",
        "iPhone X (11.4)"
      ]
    )
  end

  lane :doc do 
    jazzy
  end

  lane :travis do
    build
    tests
    pod_lib_lint(allow_warnings: true, verbose: false)
  end
end


##### MAC platform
##############################################
platform :mac do
  lane :install do
    bundle_install
    cocoapods(use_bundle_exec: true, try_repo_update_on_error: true)
  end

  lane :build do
    install 
    xcodebuild(
      project: "PinLayout.xcodeproj",
      scheme: "PinLayout-macOS",
      #destination: "name=Apple TV",
      build: true
      #clean: true,
      #destination: "generic/platform=iOS\" CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=\""
    )

    #xcodebuild(
    #  workspace: "PinLayout.xcworkspace",
    #  scheme: "PinLayoutSample",
    #  build: true,
    #  clean: true,
    #  #destination: "name=iPhone 8 Plus,OS=11.2",
    #  destination: "generic/platform=iOS\" CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=\""
    #)
  end

  #lane :tests do
  #  scan(
  #    scheme: "PinLayout-macOS", 
  #    workspace: "PinLayout.xcworkspace",
  #    destination: "platform=macOS,arch=x86_64"
  #  )
  #end

  lane :travis do
    build
   # tests
  end
end
