By Alvin Alexander. Last updated: August 20, 2020
I was just reminded when reading this article that you have to use three % symbols when adding Scala.js and Scala-Native library dependencies in sbt. Specifically you’ll find that this libraryDependencies
line does not work for adding a Scala.js and Scala-Native library dependency:
"com.github.scopt" %% "scopt" % "3.6.0" // ERROR, DOESN’T WORK
This is the correct sbt syntax for Scala.js and Scala-Native libraries:
+= "com.github.scopt" %%% "scopt" % "3.6.0" // WORKS ---
As the author of that article notes, this syntax is equivalent to this build.sbt line:
"com.github.scopt" % "scopt_native0.2_2.11" % "3.6.0" --------------------
Again I underlined the relevant syntax in that example.
If you’re trying to add a Scala.js or Scala-Native library dependency to an sbt build.sbt file, I hope this example is helpful.