Something changed in Gradle 7.6 from 7.5.x. I have...
# ios
r
Something changed in Gradle 7.6 from 7.5.x. I have this in the
podspec
file generated by the cocoapods plugin:
Copy code
spec.pod_target_xcconfig = {
        'KOTLIN_PROJECT_PATH' => ':',
        'PRODUCT_MODULE_NAME' => 'whatever',
    }
                
    spec.script_phases = [
        {
            :name => 'Build events',
            :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"
            SCRIPT
        }
    ]
Notice how
KOTLIN_PROJECT_PATH
has value
:
and the Gradle command ran has parameter
$KOTLIN_PROJECT_PATH:syncFramework
which would be
::syncFramework
. This worked with Gradle 7.5.1 but fails with Gradle 7.6:
Copy code
Cannot locate tasks that match '::syncFramework'. The path should not include an empty segment (try ':syncFramework' instead).
I suppose they added a check. Can't find it in the changelog. I guess I'll do some kind of
sed
task running after the
podGenIOS
task in order to fix the
podspec
(probably set
KOTLIN_PROJECT_PATH
to empty), but am I right thinking the generated
podspec
file is kinda broken?
My current workaround:
Copy code
tasks.create<Exec>("fixGeneratedPodspec") {
    commandLine(
        "sed",
        "-i.backup",
        "s/'KOTLIN_PROJECT_PATH' => ':'/'KOTLIN_PROJECT_PATH' => ''/",
        "events.podspec"
    )
    doLast {
        delete("events.podspec.backup")
    }
}

tasks.named("podGenIOS").get().finalizedBy("fixGeneratedPodspec")
326 Views