How do I start a Swift (6) REPL that allows me to import my package, but without using `swift run --repl`?

Since swift run --repl no longer works for me when I have certain packages in my dependencies and neither that post nor the SwiftPM bug have gotten any traction, I'm looking for alternate ways to do what I need. So, how can I start a swift repl session that'd allow me to import MyModuleName (a static library target)?

I tried the simplistic swift repl -L .build/debug -I .build/debug but that only lead to the same module redefinition errors I saw with swift run --repl and it also failed to find my module:

  1> import CellularAutomataGP
error: error while processing module import: /Users/myusername/Documents/Programming/swift/CellularAutomata/.build/debug/Atomics-tool.build/module.modulemap:2:8: redefinition of module 'Atomics'
module Atomics {
       ^

error: /Users/myusername/Documents/Programming/swift/CellularAutomata/.build/debug/Histogram.build/module.modulemap:2:8: redefinition of module 'Histogram'
module Histogram {
       ^

error: /Users/myusername/Documents/Programming/swift/CellularAutomata/.build/debug/SwiftBasicFormat-tool.build/module.modulemap:2:8: redefinition of module 'SwiftBasicFormat'
module SwiftBasicFormat {
       ^

// ... few hundred lines omitted

error: repl.swift:2:8: no such module 'CellularAutomataGP'
import CellularAutomataGP

Frankly it's incredibly annoying that the REPL is now somehow broken compared to 5.10 and that there's seemingly no solution.

I’ve never used swift run --repl before so I’m not quite sure how it works but perhaps Arena can do what you’re looking for:

1 Like

Ah, thank you! Seems like that might do the trick, I'll give it a go.

Edit: well I'll be a monkey's uncle, it actually works. Weird that SwiftPM's REPL is borked (wonder if it's the for everybody or is this just my setup somehow?), but this is definitely better than nothing.