sbt / sbt-native-packager

sbt Native Packager
https://sbt-native-packager.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
1.59k stars 437 forks source link

MacOS .pkg application do not start after installing. "Extensions" file missing from app bundle #1531

Open lRaulMN7 opened 1 year ago

lRaulMN7 commented 1 year ago

Hello! I've been trying to create a .pkg that I can forward to other mac users to use my application. This is my current build.sbt

val scala3Version = "3.2.1"

enablePlugins(JDKPackagerPlugin)
enablePlugins(JavaAppPackaging)
Compile / mainClass := Some("com.myname.desktop.QaInterface")
Compile / discoveredMainClasses := Seq()

jdkPackagerType := "pkg"
name := "QaInterface"
maintainer := "myname"
packageSummary := "test"
packageDescription := "testing"

version := "0.1.3-SNAPSHOT"
jdkPackagerProperties := Map("app.name" -> name.value, "app.version" -> version.value)

jdkPackagerAppArgs := Seq(maintainer.value, packageSummary.value, packageDescription.value)

ThisBuild / assemblyMergeStrategy := {
    case PathList("META-INF", _*) => MergeStrategy.discard
    case _ => MergeStrategy.first
}

lazy val root = project
  .in(file("."))
  .settings(
    name := "QaInterface",
    version := "0.1.3-SNAPSHOT",
    assembly / mainClass := Some("com.myname.desktop.QaInterface"),
    scalaVersion := scala3Version,
    libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "2.1.0",
    libraryDependencies += "org.scalafx" %% "scalafx" % "18.0.2-R29"
  )

QaInterface looks like this:

object QaInterface extends JFXApp3{

    override def start(): Unit = {
      stage = new PrimaryStage {
        title = "QaInterface - "
        width = 650
        height = 450
        scene = new Scene {
          fill = Black
          }
        }
      }
  }

This works when I run it from the script, jar file, running from IntelliJ, but when trying to do a pkg using sbt jdkPackager:packageBin

After successfully installing the app using the installer, when I execute it, it crashes, reporting the following error in the macos console: Non-fatal error enumerating at <private>, continuing: Error Domain=NSCocoaErrorDomain Code=260 "The file “Extensions” couldn’t be opened because there is no such file." UserInfo={NSURL=Extensions/ -- file:///Applications/QaInterface.app/Contents/, NSFilePath=/Applications/QaInterface.app/Contents/Extensions, NSUnderlyingError=0x7fe0a7f09f30 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

I'm completely lost because I'm not doing any references to an "Extensions" folder in my code and also the documentation of jdkpackager withing sbt-native-packager doesn't mention it. Does anybody have an idea of why this could be happening? I've been researching, and this "Extension" file is not supposed to exist in the app bundle, right?

Using addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9") % sbt -version
sbt version in this project: 1.8.0 sbt script version: 1.8.0

MacOs Ventura 13.0.1

muuki88 commented 1 year ago

Thanks @lRaulMN7 for your issue. It's been years since I heard from the last mac user.

I'm not sure if this integration still works. Neither can I help with any MacOS related topics :(