Hello iOS developer here :smile:. I'm trying to bu...
# ios
j
Hello iOS developer here 😄. I'm trying to build an Swift Package plugin that runs a gradle script to build my kmm shared lib; Basically boils down to this (just checking the gradle version here to see if its working)
Copy code
.prebuildCommand(displayName: "Gradle Build (path: \(projectRoot.description))", executable: projectRoot.appending(subpath: "gradlew"), arguments: ["-v"], environment: ["JAVA_HOME": javaHome], outputFilesDirectory: context.pluginWorkDirectory)]
Gradle seems to take issue, saying
ERROR: JAVA_HOME is set to an invalid directory
Now, the
JAVA_HOME
is set to use
/usr/libexec/java_home
, which points to a java 11 version i've installed through homebrew. For some reason however, gradle expects the
JAVA_HOME
to point to the java provided by Android Studio (which I don't want, because I want to run this on CI as well). What am I missing here?
Ah, got it; had to trim the whitespaces and newlines from the javaHome dir 🤦
t
@Jerry Nice approach! Are you using the approach productively? I haven't gotten it to work yet and would be happy to see an example. I think my problem is related to the sandbox.
j
No, unfortunately I abandoned pursuing this approach. I can't recall why exactly. We ended up having the KMM module as a git submodule in our iOS project, and just building the framework in a build phase script. We still had to jump some hoops to get it to build on our CI (Xcode Cloud), mostly documented here: https://stackoverflow.com/questions/72578619/building-kotlin-multiplatform-app-with-xcode-cloud/76092736#76092736
t
Thanks a lot Jerry, we've switched recently to a monorepo which simplifies the process of building the shared library a lot