 During the presentation, I'm back on Swift Server last night. So before I go ahead about speaking in Swift, I want to ask you a question. How many of you are a Swift developer here? Almost all of them. Some of them didn't raise their hand. And how many have you done in Swift? Okay. So it may be an interesting talk for you guys. All right. So consider a scenario. Why do you need to do Swift? So I work for Property Guru. By the way, there is my colleague from Property Guru. So consider a scenario. In Property Guru, we have a project and we have four different countries. And for each country, we have four different apps. It's not actually the same app. You can localize for different countries. Different apps for different countries. Even though we have the same project. So we have this situation where we have one project and then we have four different targets. And for each country, we have its own configuration files, as of this time. And every time you want to do some kind of update, you have to update in four different configuration files. So you want to get some keys and then some values. You have to go find for this country, that country, and do it for four places, right? So then you have to. That's horrible, right? Just for one simple thing, you are changing four different configuration files. So we have a solution. So how about the simple solution? The easy one. Let's mod everything together. Mod all the configuration files into one single configuration file and then figure out something from there. So it would look something like this. So the left-hand side, right? We have some examples. So for target one, we have some new items. So these are the audio files and you have four different configuration files. Now you combine them together and then make it a single configuration file. So you can write different configuration for different targets. In case they were sharing the same thing, you can probably write one different case for all of them if you solve the problem. But there is a big problem here. It's not physical. There are more than 1,000 keys, right? So many of you are meeting and nobody has time for that, right? That's too much. So we thought about it. So we have to somehow automate this thing. So automate means combining these four configuration files into one file. So we thought, okay, let's try this free file. Excitingly, we have a lot of scripting in our project. A lot of things will be written in Python and Shell and other things. So we thought, okay, we have Swift. Why don't we try to do it in Swift? And then we ended up doing it and it was pretty cool. So that was just a scenario. Why, actually, we should be interested as an iOS developer in trying the scripting in Swift. It's pretty cool. First of all, it's a very familiar language. Even though most of you are probably very familiar with Shell or Python, right? But writing scripting in Swift is pretty cool. You can use a lot of familiar things already. And I'll give you another scenario where we can actually use scripting. For example, the first case, you have this file and then you want to generate the keys. Instead of typing those similar keys, like in the quotations, you can just create an enum keys for the finished file. So you write a scripting file and before the project is built, you run this scripting file and it's automatically generated for that. Similarly for the image assets, you can write it on Swift later. You want to have a rule like... So your file is too long, more than 400 lines. That's too much, right? We don't want our file to be too long. Then you run it, 250 maximum. So you want to throw a warning or error depending on the length of the file or some kind of rule depending on your company thing. You can divide those into six scripting as well. And some people have seen, they write the localized strings. They start reading from the localized bundle. They read from the cloud and then they have their own way of kind of automatically reading those strings from your project and then putting them inside the localized bundle and then reading them from the cloud. All right, that's the setup. So if you haven't used it before, the way to start writing scripting files, of course you can just open a normal file, call it just Swift, just like a shell, you can import the user being Swift and then start writing it there. If you are working on Xcode, you can do it, open it, new project in Nightwear in command line 2. This will give you this one. Create a simple folder and give you a write. So, okay, so I'll talk a little bit about it. So you can write your own stuff. That's a normal way. How about if you want to import hot-party frameworks or hot-party libraries? For that, there is a way. You need to just generate the framework of the library. And to generate the framework, we have some tools here. Of course, you can generate from the package, right? Everybody does the package. This Gokapos came up with their own, or Gokapos Chrome. By the way, the Uniquash is the again such, the file between Chrome and Cartes, back in history, the name Cartes and Chrome, so we'll finish some history behind that. You can see package manager. So the key is just to, if you want to use ThoughtBuddy library in your scripting, you just need to create the framework and then you have to put something at the top to show it. So in this example, I'm using a framework called Suplant. So this framework is pretty useful for writing some color to output in the console. So the framework is located at the home folder. So by putting that framework inside the home folder and writing a line at the top, now I can import Suplant in my command line. Suplant. So before I go to a simple demo, I'll just show you guys some cool command line libraries available in GitHub and pretty cool. I recommend everybody to go and check. The Suplant that I just talked, it has some nice tools for you to write color to output or to some helper like Ron, Ask, or a cool helper. And command line, command line. I think a lot of them do the same thing. My favorite is Suplant, but I recommend everybody to go back and check it out. All right. So, yeah. That's for the top. Now I'll just do a quick demo just to show you guys how to do this. Let's start from the expert part. We want to use the script from the command line, right? So I need to write something here at the top to tell that it is using a suite. So let's go ahead and run this one. What happens, right? Okay. The reason I couldn't do that was it's not executable yet. So I can run it like this. It was made by converting into an executable file. So this symbol... There's nothing right now. I'll just say print. All right. So the demo tray I'm going to show you is... I'm going to show you just how to use a script at the beginning and then how to call, like, say, some other command lines from within the script code. So the demo I'm going to show you is there is an API. The API will give you the, say, the Olympic medal lists. And then if you give a country name, it will give you the number of gold medals. Those medals won't buy a country. Right. So I have some helpers in this here. So this is a medal struck here. So position, country, gold count, silver count, all those things. I have some helpers methods to print things. So there is nothing here, nothing to explain. Pretty simple stuff. So I'll go through this. I'm not going to type everything in here. Something might go wrong. So I'll explain about this function over here. This run command. So this helps me. If I pass something into this function run command, it will use the system once path, user being environment, and then run these arguments. This method, this class process, used to be called NSTask in the earlier version of Swift. Later they named to task, and then the latest version of the Swift, it is called process. And then the class that used to be called process is now called command line. So don't get confused with that one. These processments actually get NSTask. So what I'm doing here is I'm launching the NSTask using the arguments that we are passing in the function. And then the output of the result of the command line, for example, if you say git status, it is going to output something. So I'm going to put the output inside the output here. There is a data. That's what it is doing. So that is the main part. What it does here is, there is two functions here. It's focused on the personal get methods. So if you pass, let's say 10, 15, you just give you the top, top those top 10 top five countries with the mail and the round picks, right? So there is this API called a medal boat which gives you the things. So I'm here. I'm calling the call command line from this function. Run command call and then minus s is to silent the verbose. I'm getting the output as a data using the method here. This round command, right? So it will take some time to get the output from the API and then the output is available in the output there. And then I'm going to, I'm using the JSON parser, converting those things into medals and then I'm printing the methods out. So I want to run this thing now. So I have this method called read input. So like I said, the method that used to, the class that used to be called process is now called command line. Command line and then the arguments are the arguments that you are passing in the command line thing, right? So it is taking, checking the arguments that you are passing. There are more than one arguments. And then it checks if it's a country or if it's a count and then it will call one of those APIs and then give you the result. And then this is the main thing and this is all our definition. And then the beginning, the one thing that this main function, main.swift is calling this reading input function which reads the user arguments and then prints out the result. Alright, so we should be okay now. So let's go, let's say, free. So it's commuting. So it gave me the top three countries and then printed out the middle count for those countries. And, do you want to move on? It's a single point. Alright, so 54 is one goal middle. Right, so yeah, just wanted to do a simple demo nothing fancy here. I can go one more time just devise like and getting the arguments from the command writer arguments using it to get the country of the count and then I'm using the main function called run command which is just passing the elements inside and then calling the list task which is called now called process putting the output into data the thing, the key is I don't want, if you don't put this like put the output into data everything outside inside the console so when you call the call method from here from inside this file it will give you some statistics and then the content of the drive so you won't see it because you're putting out here and that's it. That's the whole demo. Thanks. Please ask. The first time is slow but the second time almost it became very fast. I haven't benchmarked it but having used it in our project you don't feel it is pretty fast. How do you debug with breakpoints that you do? Actually you can debug you can run this thing inside the expo project itself right? So here you can debug if you're not run from the command line from here I think you can put the breakpoint here and then debug it like this But then you have to pass arguments You can build right you can set the environment here somewhere in the screen and then put some arguments whatever you want to put and then debug it. Yeah this is the internal console Yeah So let me finish this You see the result So by default it brings all the countries that are in the mirror You see all of them here Okay, thanks very much.