swiftlang / swiftlang/swift-java

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

Open
#694 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
1.2k
Forks
123
Avg merge
1d 7h
Merged PRs (30d)
16

Description

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"))
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Package.swift manifest and the Gradle script described in the issue. Review how the Swift package is configured for Apple and Android builds, then verify that Apple builds do not add the SwiftJava dependency or JExtractSwiftPlugin while Android builds retain the required integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.