is there any way to create swift files programmatically using command line tool
I have to create a set of files with specific code in it based on the inputs given I have to use swift command line tool to generate swift files
can anyone help me with your suggestions
I need the code in swift i have to write a swift command line applications which generates a set of swift files
Asked
Active
Viewed 251 times
-2

John Bollinger
- 160,171
- 8
- 81
- 157

Sarwesh reddy
- 19
- 8
-
Show an example of what you want. – DJDaveMark Jan 18 '18 at 10:22
-
Read manual for bash command `touch`. – Dominik Bucher Jan 18 '18 at 10:29
-
can we create a swift file with a specific code in it using swift programming – Sarwesh reddy Jan 18 '18 at 10:30
-
Please refer to this answer: https://stackoverflow.com/questions/26971240/how-do-i-run-an-terminal-command-in-a-swift-script-e-g-xcodebuild – Dominik Bucher Jan 18 '18 at 10:31
-
Or you can set new question or edit this one and ask properly – Dominik Bucher Jan 18 '18 at 10:32
2 Answers
1
If you only need to create swift file you can try touch fileName.swift
command.
You can create multiple files by touch file1.swift file2.swift
or if there is any sequence in file names you can try touch file{1..5}.swift
.
And then using echo
command to fill file with code.

pacification
- 5,838
- 4
- 29
- 51
0
You can create a swift files in command line by doing touch myFile.swift myFile2.swift myFile3.swift
and then you can add whatever you want in it by doing echo "some text" > myFile.swift
. You can also append some text in it by doing echo "some text" >> myFile.swift

YoanGJ
- 479
- 5
- 25