The Swift for TensorFlow team has developed a Jupyter kernel for Swift based on the Python LLDB API.
One problem I found while trying it is that modern macOS APIs are unavailable (SR-8371):
In : import Foundation In : ProcessInfo.processInfo.userName error: <REPL>:1:25: error: 'userName' is only available on OS X 10.12 or newer
It seems that by default the LLDB target is started with the triple set to
x86_64-apple-macosx10.11.0 instead of the current running triple (
x86_64-apple-macosx10.14 in my case).
On the other hand, the Swift REPL is executed by default with the current running triple:
$ swift Welcome to Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1). Type :help for assistance. 1> import Foundation 2> ProcessInfo.processInfo.userName $R0: String = "pvieito"
What LLDB API could I use to have the same behavior on the Kernel code? You can read the current implementation of the LLDB target initialization here.
Something like this works but I don't think it is a clean solution:
target_triple = None if platform.system() == "Darwin": target_triple = "x86_64-apple-macosx" + platform.mac_ver() self.target = self.debugger.CreateTargetWithFileAndTargetTriple(repl_swift, target_triple)