Create a swift file with swift

Hi
I have a question. How can I create a new swift file in s swift file? LG Konstantin
Can you explain what you mean ?

In Xcode, you create a new Swift File with File > New > File
then select Swift File in Source section.
I mean how I can create a script with a command in the script. That I say in the code to create a new file
You can create a text file with file extension .swift. But you cannot link the Swift file into your app binary.
What do you want to do with the Swift file you create?
I want the program to check at Start whether a Swift file already exists and if not, the code should create a script and write a few things it.

the code should create a script and write a few things it.

Even if you create a swift file and successfully write something on it, you cannot execute it. What do you want to do?
Otherwise, is it possible to create a text file local on the device and write the data in and then retrieve it in the code?
it sounds like you are either trying to make something that generates swift code, or something to store and load app settings. there are already preferences APIs for the settings part, and while your code can technically write text files with swift code in it and the swift code file extension, including these files to your project so that they can be compiled would still need to be done by the user generating them.

If you can explain your intensions surrounding this question we would be able to give you more relevant answers.
I started developing a game with Firebase and Firebase database. If the app should start if such a Swift file does not already exist, a user will be created. Then a Swift file is created by notifying the randomly generated email address. If the app is then restarted, the code should recognise that the file exists and log in with the email address noted there. Then the variables can be read out of the database.

if such a Swift file does not already exist, a user will be created. 

What your app needs to check is not a Swift file, but but a data representing a user.

How can I check that?

How can I check that? 

For example, you can create a type named User and store it into the UserDefaults.

Create a swift file with swift
 
 
Q