// Self-contained iOS-ready build for the ScopeDOPE ballistics engine.
//
// Differences from the original scopedope-shared :ballistics module (the two
// "iOS-readiness" fixes, plus independence):
//   1. iOS targets added: iosArm64, iosX64, iosSimulatorArm64, packaged as a single
//      XCFramework named "ScopeDopeBallistics" for the Swift app to consume.
//   2. androidTarget() and the android {} block removed — this module no longer
//      depends on the Android Gradle Plugin or the Android SDK, so it builds with
//      only the Kotlin toolchain. (The companion source edit replaces java.lang.Math
//      with a multiplatform helper so commonMain compiles for Kotlin/Native.)
//   jvm() is retained solely for fast headless validation (MultiZoneBcTest).
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins {
    alias(libs.plugins.kotlin.multiplatform)
}

kotlin {
    // Headless validation target — no Android SDK required.
    jvm()

    // iOS targets → one fat XCFramework consumed by the SwiftUI app.
    val xcframeworkName = "ScopeDopeBallistics"
    val xcf = XCFramework(xcframeworkName)
    listOf(
        iosArm64(),           // physical iPhoneOS devices
        iosX64(),             // Intel iOS simulator
        iosSimulatorArm64(),  // Apple-silicon iOS simulator
    ).forEach { target ->
        target.binaries.framework {
            baseName = xcframeworkName
            isStatic = true
            binaryOption("bundleId", "com.coldboreballisticsllc.scopedope.ballistics")
            xcf.add(this)
        }
    }

    sourceSets {
        commonMain.dependencies {
            implementation(libs.kotlin.stdlib)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
        jvmTest.dependencies {
            implementation(libs.kotlin.test.junit)
        }
    }
}
