I'm using Swift Playgrounds 4 to develop a test app containing some network code. Unfortunately Playgrounds runs the whole app code multiple times, at least two times: Once for the preview and once when you press "play".
This causes multiple instances of the network code to be running and makes testing very hard.
Is there a way to check if the code is running in preview?
Unfortunately the usual suggested solution using ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"]
does not work, because this results in "1" in both cases.