I'm currently writing a Swift program and I need a way to process user-created scripts. I want to do it in a way where there is a script, an API and the script should call this API.
Initially, I wanted to make that happen with Python. However, I don't know if and how I can provide context and values to Python scripts when running them (e.g. setting variables, so they can be accessed from within the script, etc.)
And then it hit me - Swift can be used as a scripting language! I still have the problem of script context and predefined values. Is something similar to Kotlin's scripting engine available for Swift? (Kotlin, being JVM-based, requires everything to be in a class. When scripting with Kotlin, I can create a class on the host and have the script code be run as if it was inside a method of the class, giving me access to its instance methods and properties.)
And how can I even run Swift scripts from within Swift anyway?
Example: Say I want a script to be able to call an API function
someFunction(a:b:c:). I can define this function in my compiled Swift program, but how can I make it accessible to a Swift script?
Edit: I forgot to mention that the program in question is not strictly a macOS application. It is a cross-platform command-line tool, and I'm developing on Linux.