Skip to content

Building a package for Apple platform shouldn't use JExtractSwiftPlugin plugin and swift-java dependency at all #694

@tkrajacic

Description

@tkrajacic

As per discussion with @ktoso on Slack:

When using a shared Swift package between Android and iOS, macOS etc…, we can't have the JExtractSwiftPlugin be used, and we don't want the swift-java dependency at all even.

The current workaround is to use an ENV variable inside the Package.swift manifest which only adds the dependency and plugin to the target if built for Android (The environment variable needs to be set in the gradle script in that case)

import Foundation.NSProcessInfo

let isSwiftJavaBuild = ProcessInfo.processInfo.environment["SWIFT_JAVA_BUILD"] != nil

if isSwiftJavaBuild {
    package.targets.first?.dependencies.append(.product(name: "SwiftJava", package: "swift-java"))
    package.targets.first?.plugins?.append(.plugin(name: "JExtractSwiftPlugin", package: "swift-java"))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions