https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
i

Idan

01/17/2023, 5:59 PM
Hello 👋 Im using KonfigBuild , and I want to pass the build flavor when xcode build using
-Pbuildkonfig.flavor=flavor
so I added
noPodspec()
to cocoapods {} in build.gradle.kts and manually edit shared.podspec -Pbuildkonfig.flavor=flavor to the build phase hardcoding the flavor is working but I want to set ENV VAR from the target in xcode, is it possible?
Copy code
spec.script_phases = [
        {
            :name => 'Build shared',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
                if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
                  echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
                  exit 0
                fi
                set -ev
                REPO_ROOT="$PODS_TARGET_SRCROOT"
                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
                    -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
                    -Pkotlin.native.cocoapods.archs="$ARCHS" \
                    -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" \
                    -Pbuildkonfig.flavor=$APP_ENV
            SCRIPT
        }
    ]
Another question Is it possible to customize the
script_phases
from build.gradle so I can keep the podspec gen?
a

a-dd

01/17/2023, 6:59 PM
Yes, something like this should work:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.PodspecTask>().configureEach {
    doLast {
        editScriptPhases(outputFile)
    }
}
i

Idan

01/18/2023, 12:55 PM
Thanks! will need to work on a podspec de/serializer 😬 will be a weekend activity
20 Views