How should I set opt-in in a multiplatform project...
# multiplatform
f
How should I set opt-in in a multiplatform project?
Copy code
sourceSets {
    all { languageSettings.optIn("opt.in.Class") }
    commonMain {
        dependecies {
            implementation("dep.that.require.annotation")
        }
    }

}
If I do it that way I get a warning that
opt.in.Class
is unresolved for some source sets.
Copy code
sourceSets {
    commonMain {
        languageSettings.optIn("opt.in.Class")
        dependecies {
            implementation("dep.that.require.annotation")
        }
    }

}
If I do it this way I get an error that opt in should be applied to all dependent source sets.
j
The first way works for me. Which source set does it say it's unresolved for?
f
androidMain
. I get the following warning when build project:
Copy code
> Task :module:compileDebugKotlinAndroid
w: Opt-in requirement marker com.russhwolf.settings.ExperimentalSettingsApi is unresolved. Please make sure it's present in the module dependencies
j
Seems odd. Have you tried also adding it explicitly to the
androidMain
source set?
f
Adding opt-in or dependency on lib?
j
Opt-in
f
That worked. I can’t understand why though. As it seems to me
all { }
should’ve added opt-in to all source sets
j
I would think so. Maybe file a bug.
f
Okay. Thank you for your help!