Ok, I am very new to python and am only about to start swift. I am looking for a way to save a variable in python and use it in swift.
I have never coded in swift so please give me an example.
I am writing background code I want to run behind swift and need to send strings from swift to inputs in python.
I also need to sync python variables to swift.
I am not even sure this is possible so tell me if it isn't.
I do not care if I need to send files.
CodePudding user response:
This is something that interests me a lot. However it is not as easy or as practical as you may think.
https://betterprogramming.pub/from-swift-import-python-f2fc2a997d4
here is an example that allows you to execute a python script in your swift app.
There really is not way to fully integrate the two where you are able to achieve what you want.
CodePudding user response:
It isn't clear what you are asking.
You can build apps that have part of their code in Objective-C and part in Swift, and share variables between the code.
You can't build apps that contain both Swift and Python code. Python is an interpreted language and Swift is compiled.
You could create command line commands in both languages that pass options to each other and pipe data to each other; you could pass files between Swift and Python, but that's about the extent of it.