Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to selectively disable native targets #3695

Closed
arkivanov opened this issue Sep 15, 2023 · 5 comments
Closed

Provide a way to selectively disable native targets #3695

arkivanov opened this issue Sep 15, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request gradle Gradle plugin problems ios

Comments

@arkivanov
Copy link
Contributor

My Gradle module has org.jetbrains.compose Gradle plugin applied and the following targets enabled:

kotlin {
    androidTarget()
    jvm()
    js { browser() }
    ios()
}

But I don't need Compose for ios and js targets. I'm able to disable Compose for Web using the following configuration:

compose.web.targets()

However, it looks like there is no API for iOS. Currently I'm using the following workaround, which is not ideal.

plugins.removeAll { it is ComposeCompilerKotlinSupportPlugin }

class ComposeNoNativePlugin private constructor(
    private val delegate: KotlinCompilerPluginSupportPlugin = ComposeCompilerKotlinSupportPlugin(),
) : KotlinCompilerPluginSupportPlugin by delegate {
    @Inject constructor() : this(ComposeCompilerKotlinSupportPlugin())

    override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean {
        return when (kotlinCompilation.target.platformType) {
            KotlinPlatformType.native -> false
            else -> delegate.isApplicable(kotlinCompilation)
        }
    }
}

apply<ComposeNoNativePlugin>()
@arkivanov arkivanov added enhancement New feature or request submitted labels Sep 15, 2023
@MatkovIvan MatkovIvan added gradle Gradle plugin problems ios and removed submitted labels Sep 18, 2023
@eymar eymar self-assigned this Sep 22, 2023
@eymar
Copy link
Collaborator

eymar commented Sep 22, 2023

Thanks! Related: #3657

@eymar
Copy link
Collaborator

eymar commented Sep 22, 2023

To get it right, you have no Compose related code in the commonMain source set, right?

@arkivanov
Copy link
Contributor Author

Correct. I have a module that supports Android, JVM/Desktop, JS and iOS. And I only use Compose in androidMain and jvmMain source sets. See the code here.

@eymar
Copy link
Collaborator

eymar commented Sep 26, 2023

Closing this as fixed :)
It should be available in 1.5.10-beta02 (not released yet)

@eymar eymar closed this as completed Sep 26, 2023
@arkivanov
Copy link
Contributor Author

Thank you! 🙏

KotlinBuild pushed a commit to JetBrains/kotlin that referenced this issue Apr 19, 2024
… plugin should be applied

According to JB Compose team, it is a useful feature requested by their
users and a new plugin should also support it. For example:
JetBrains/compose-multiplatform#3695

^KT-67253 Verification Pending
KotlinBuild pushed a commit to JetBrains/kotlin that referenced this issue Apr 19, 2024
… plugin should be applied

According to JB Compose team, it is a useful feature requested by their
users and a new plugin should also support it. For example:
JetBrains/compose-multiplatform#3695

^KT-67253 Verification Pending
KotlinBuild pushed a commit to JetBrains/kotlin that referenced this issue Apr 19, 2024
… plugin should be applied

According to JB Compose team, it is a useful feature requested by their
users and a new plugin should also support it. For example:
JetBrains/compose-multiplatform#3695

^KT-67253 Verification Pending
KotlinBuild pushed a commit to JetBrains/kotlin that referenced this issue Apr 22, 2024
… plugin should be applied

According to JB Compose team, it is a useful feature requested by their
users and a new plugin should also support it. For example:
JetBrains/compose-multiplatform#3695

^KT-67253 Verification Pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gradle Gradle plugin problems ios
Projects
None yet
Development

No branches or pull requests

3 participants