This time we're gonna be going over installing Swift to a bun to now you might be wondering what I would do if you haven't heard about it first and how can we install Swift to this new thing called Ubuntu well first of all let's clear out ubuntu is a distro of Linux I believe it's based off of Debian and essentially Swift was just open sourced if you didn't hear about it on December the 3rd and so using this new open-source swift we're going to be able to install Swift itself the programming language the compiler onto Linux this is great because guess what let's say you don't have a Mac you have a Windows machine a Linux machine any machine you can run Swift on that computer you can directly run it on Windows just yet however if you run on a bunch of actual machine on Windows or Mac you can install Swift to those virtual machines and see if so if Swift is for you if it is you can get a Mac and start doing iOS development but then you may be wondering hey why do I need to get a Mac to do iOS development if I already have one - well it's simple because Apple has not yet open source the Xcode IDE that would be a bit too much instead what they've done is they've open source Swift itself so using Swift you can create a bun to console apps not much more than that however now I'm gonna be going showing you how you can exactly do these steps now first of all what we're gonna be doing is we're going to run a virtual box if you don't know a virtual box is it's a virtual machine software that I believe Oracle has developed so this is VirtualBox free it's open source ID I think yes it's open source and we're going to run a virtual box for Ubuntu ah sorry now we're not just going to do this for any old abun - we're going to have been doing this for guess which version I don't think you're exactly heard about this but this is going to be version 16.04 okay so I might be wondering how cool hasn't even released or actually if you already know this Apple has not yet released a source code for ubuntu 16.04 this is due to the fact that sixteen point oh four is still an alpha however since I hasn't really changed much since since it hasn't changed much since 15.10 we can use the same 15.10 libraries for I want to so now this is the first step we're gonna run a VirtualBox instance for ubuntu 16.04 now again I'm running this on Mac but you can run this on Windows pretty much any other operating system even Linux itself even though you don't really need to then next what we're gonna do is we're going to well tweak it a bit but next we're really just going to install the Swift compiler so this is quite self-explanatory we're gonna clone the the sorry we're going to clone the repository from github and then we're going to install and to be technical here we're going to install Swift compiler and its dependencies okay so and it's dependencies finally the last step will be to compile and run a project perfect I'm not gonna tell you what project this is yet but this is going to make really good use of the libraries that a bundt who gives us that well normal Swift does not so yeah this is gonna be the three things are going to be covering in this video again if you already have a machine that has a bun - or some other really related in exist row but basically what I'd say is if your version of well Linux has the app to get or I think if that's in a package package manager then you should be fine should work on pretty much any Linux like that but I haven't tested it so I can't give a guarantee but if you have any questions you can leave it in the comments below anyway more info on that in the end of the video so if you've already seen to step one you're gonna see step two and I will write as we get for the Mac part I'll show you a little box on screen where you will be able to skip to step two but yeah now let's get into the Mac part where I'm really gonna be showing you how you can install a bun to install the Swift compiler and run a project so let's go to the Mac part so welcome back to the Mac part now I'm gonna be showing you how you can actually install Linux to VirtualBox or Ubuntu okay so let's get started first thing we're going to do is we're going to have to head over to the abun - site and get a copy of xenial xerus 16.04 abun su so what I've really done yes since it takes a long time to actually download because it's a quite big file I've already downloaded it for me but others want to be a link to in the description to a page where you can download it now let me just show you where you do download this and how you download it it's called 1604 to again you could just google this or you could just click the link in the description I'm gonna go to the daily build and then right as you get to this page which is we're gonna get with the link in the description just click on this dot ISO file here xenial desktop and be 64 even if you don't have an AMD chip that's not what it means it doesn't need an amnesic okay so now this is going to be a 64-bit image because swift only works with 64-bit computers so if you have 32-bit abun to sorry it is not going to work for you anyway so now that you've downloaded xenial xerus next what we're going to do is we're going to download VirtualBox so if I open up VirtualBox so as you can see we're currently on virtualbox 5.0 and there's a big button that tells you that okay so then you're just gonna go over here and then click on any 64 again for OSX you can also download for windows solaris or linux ok so once you've downloaded VirtualBox and installed VirtualBox which is an extremely straightforward process you just open the package file I've I'm sure you've done this a million times for Xcode etc so once you're done with that we're actually you know I actually did start the download here didn't die so I'm just gonna cancel that you don't need to do that ok so now we're gonna open up VirtualBox and as you can see I already do have one running image of a bun too but you can just ignore that pretend that's not there that doesn't really affect anything so next what we're gonna do is we're gonna click on new then you're going to say something like a bun 2:16 point out for ok Swift then what we're going to do is we're going to say type Linux version a bun to 64 bits we're going to have the memory size set to half my memory you can set it to anything you'd like I always like to sense a half then what we're going to do is we're going to click on create a virtual hard disk now now click create now I'm just going to name this the default no need to change it now I'm just going to give this around 20 gigs no 15 gigs of space on my hard drive I'm going to make this dynamically allocated and I'm going to make this a VDI so it works the best so now just click on the create button once more and perfect so now what we're going to do is we're going to head over to Google or actually there will be a link to to this article in the description but we're going to be using this as a source on how we can install uh Swift to Linux so I'm still so from Twilio ok perfect so this is the website you're gonna be going to so as you can see they give you tons of commands to do stuff we'll get into that just in a minute ok now before you start your machine remember do not start yet if you already have turn it off so what you're going to do is you're going to go to settings you're going to go to display and you're going to say enable 3d acceleration or else your display will be extremely laggy trust me I have experience ok then go to storage and see where this says CD drive empty click on that and then where it says optical drive click on this little CD icon and click choose virtual optical disk file then I'm going to head over to ok so I'm going to head over to my desktop then I'm going to sort by date and select the Zinio desktop that we just and open it up click OK and then click start perfect now let's minimize this ok now we just wait until it gives us some more options and so we just wait that's this screen will eventually become big don't worry well that's just it just a sec may give you an error but that's normal don't really do anything ok so now once a blue starts up the setup process can begin ok so now I'm going to install a bun to not try it so then sorry I'm not going to select any of these because I don't need to I'm going to click continue I'm going to erase disk and install one to again this isn't going to erase the newer files this is just the virtual hard disk that we're creating click install now click continue now I'm just going to type in my location not exactly just your city so it knows where you are yeah then choose your keyboard layout I'm just going to test okay perfect then yeah continue okay now I'm just going to set this to 10 maybe Bakshi's swift oh it has to start with a lowercase letter okay I'm going to type in a password and I'm going to set it to log in automatically perfect okay so now let's just click continue now we just wait for this to install which is actually quite a quick process so as you can see I'm just going to click this little arrow to see what it's actually currently doing so it doesn't really show us anything yet but when it's doing something that I can't show that's it well so as you can see the progress bar is moving along quite quickly just give it a few seconds till then let's talk about we're going to be doing so first of all what we're gonna be doing once a 1/2 is done installing we're going to be downloading the package file or the tar.gz file for Swift and we're going to be unzipping that using tar then we're going to export our path to the current directory which I won't exactly do because I'll tell you why in a minute then we have to do apt-get update because this is going to be a new a blue installation then we're going to install the dependencies and then I'll show you the rest later ok so now it's really installing the system to happen see what's doing graphics glitch okay yeah quite hot okay so actually you know what what I'm gonna do is I'm going to pause the video are actually you know it right as I said that it starts doing stuff okay so now just wait a minute or two let's just see if this loads if it does great you know I'm going to put a box on screen right now so that if you want to skip to the end of this when it's done installing then you can um skip so there's gonna be a box on screen now if you would like to skip for the next few seconds okay and this will take a long time I'm just going to pause the video I'm not gonna touch anything and then I will be back okay so I'm gonna pause the video and I'll be back so that was actually really quick for you but I've been waiting for around three to four minutes so now as you can see it shows this installation complete dialog and it says you need to restart the computer in order to use the new installation so I'm just going to click on restart now now I think this will give us a glitch and it just won't boot up again so let's see if that happens this time yeah it's doing that thing again it shows you this little error and just doesn't boot up after that so we're gonna fix that just click command Q power off the machine and click okay go back into VirtualBox start the Machine again and you should be on your way so okay perfect so now this is going to load then we should be ready okay felling good okay perfect so now as you can see right as we open this up it gives us some keyboard shortcuts now if you like to you can just click on input or I mean devices and click insert guest additions CD image and then install guest additions do all that stuff but I'm not going to because I don't need to if you'd like to I might leave some steps to it in the description but it's really straightforward just click the button and then and then just click run inside of a bun too and it will install the software for you however we don't exactly need that right now so now let's get to installing swift sounds going to Firefox because I don't I'm too lazy to install Chrome right now because I'm in the middle of video so let's go to Firefox which is the default browser so now let's just open up HTTP colon slash slash W dot github.com slash Apple slash Swift okay no no I actually just go to Swift org okay perfect then go to download then over here where it says linux ubuntu 15.10 just right-click on this and click copy link location then close Firefox click on this little tab here type in terminal then select terminal and click enter okay then what we're going to do is we're just gonna say W get right-click and paste now click enter now this will download the swift snapshot from Apple site now this should take a exactly two minutes as it says so yeah what I'm going to do is I'm going to pause the video while it downloads and then I will be right back so I'm going to pause the video while it downloads so as you can see it's almost done it's at like 95 percent now four seconds three seconds two seconds and one second and now it should be done okay perfect so now what we're gonna do is we're going to run Tarte okay so tar - z x VF and then the name of the file which is this so I'm going to copy the name of the file paste it in and as you can see I by mistake copied a little quote as well so now if we run this command it should theoretically unzip this file for us okay perfect now I'm just going to clear out the terminal and then we're going to go LS now I'm going to say I'm going to copy this folder name and I'm going to say mkdir this means create a directory called swift compiler with a dash in between then env and then paste in the thing that you just downloaded and unzipped - Swift compiler slash source okay now if we do LS the folder is gone however if we clear you don't need to do this sorry clear and say see the swift compiler now if we LS as we can see there's a source directory now if we see me into source we see there's a user directory if we Alice from there we go into bin and now as you can see we have tons of different files now if I run Swift get ready just a minute does it not recognize these Swift okay let's try this clear dot slash Swift perfect it worked and as you can see we have a swift ooh repl open right now so now we can type really anything in like print hello a boon to world and it prints it back out to us we can import stuff like foundation and do stuff like read line though I don't know exactly how we'd stop this now yeah so let you get the point in order to exit you can either type in : Q or you can't I say command D which is exactly what you use to exit paisans okay so now let's see what our next step is so what we're going to do is we're going to take this command next the export one and actually I'm not going to use this just yet we're gonna skip this and we're gonna do apt-get update and sudo ok if you don't know what this will do essentially is this will update our package manager so it has all the latest packages so we can get our dependencies and then it'll be able to run Swift much smoother so now if we just run sudo apt-get update then type in the password and now just wait for a few seconds for this until then here's a refreshing gif so yeah great anyway so okay that's done next let's copy this insanely long command which is well you may not have guessed this these are all the dependencies after each space there's a dependency and if I do input I mean devices shared clipboard' host to guest then I copy this and paste it in here after clearing it should or this a second copy based okay so that isn't working let's just open this up from here okay okay perfect let's roll down bet now it's just copying of this command now let's go back into our terminal okay now let's paste this in and now let's hope for the best after clicking enter now this may take a while so just I'm going to say yes bicep putting a capital y enter now we just wait for it to download each and every dependency for Swift and then we'll be able to continue so yeah let's just wait about that so okay so I'm going to pause the video while that loads and then I will be right back sorry for so many pauses but this might take a while goodbye so as you can see it's done solving the dependencies and now we can get to actually making our projects so as you can see I've clear this screen over here so now we're going to type in mkdir projects so now this will allow us to put all of our Swift files in here so just go into CD projects and clear so now as you can see there's nothing in here so now we're going to create a very simple test or file source file now let me just tell you what are we doing here using this new thing called vim well Jim is actually VI which is a very very powerful text editor from Unix and it's it's just great it's really powerful it may be hard for some users to use but it's a good resource to learn so it's VI M meaning modified so now if we run this it creates a new test or docks a file in which we can basically just edit whatever we'd like now so what I'm going to do is I'm going to click the I button meaning insert and I'll just say let test constant is equal to I don't know ah 10 or let's make a string hello Ubuntu okay then let's print out test constant and let's save and quit this file now if we do dot dot slash swift tester dot Swift essentially what this will do is so it'll go back one directory meaning towards our Swift bin it'll run the Swift executable giving it the parameter of tester not Swift and as you can see it runs hello Ubuntu so now we know how to create so flies Swift files so what do we do now well we hold from printing out hello Ubuntu to guessing games perfect so we're going to actually be creating a guessing game and a bun - using Swift so just type in vain guessing game dot swept then let's get started with some things first of all yes you can import foundation however it is not exactly completely ported to Linux yet there may be a few things that you'll find oh it's not been implemented yet it'll give you an NS unimplemented error and then so you won't be able to do that for the next I don't know week maybe month and until they implement it however one thing that has been almost completely input and implemented is G Lib C this is the GNU C library this will mean that we'll have Swift but we will use not stuff like arc for random which is what you would use in normal like Darwin UI kits foundation but now what you're going to use is s ran to seed and either random or rent I prefer R and so yeah now it's just uh array stuff so now continuing let's get started with making our default functions now our first function will be function get integer so this is going to return an integer and also func actually not required okay so and get integer we're going to say if let RL is equal to read line basically this will read a line from the user and check if they actually inputted something if they did it'll put it in here then we're checking if let are Li meaning RL as integer is equal to integer of RL if it is meaning there's an integer value in what they gave us or it is an integer value then we return our ally or else we just return sorry yeah or else we just return zero perfect now if I click escape : w and enter that saves it now if I say : q it quits but let's just run this command one more time because if we go to the end click I go here and click enter and enter and I say print guess integer and then we say escape : W and then : Q now what we can do is we can run Swift for this guessing game and oh okay I see what I did wrong I won character I got wrong okay so if I say over here this is not supposed to be a square bracket so sweet a curly brace a bracket so if I quit again clear and we run Swift now as you can see it gives us a prompt where I can type in any integer value and it goes it back to me if I type in any non integer gives us 0 and if I type in anything with integer values it just still gives us 0 so essentially now from here we're gonna be able to take input from the user and the reason that this is so useful is because well it's a guessing game we need to see what the users inputting so now if I clear this up and I'll go to them let's continue now I'm just going to remove this print statement yeah okay now let's declare our constants and actually up here I'll talk about that later actually okay so now our constants will be our current number and our R and Max and our variables will be far as one false and far actually yeah that's it okay then up here for the constants I'm going to make this lot on 100 I guess and current number to actually current number has to be declared after random acts due to the fact that it uses random acts i'll explain these in just a second so okay so now let me explain this after sitting okay so essentially what's happening is we are declaring random acts which is the maximum maximum number sorry that's our random function shamil to go to now the random function actually returns a gigantic value gigantic beyond belief and so what we have to do is we have to say percent or modulus for red max what this will do is it will return the remainder of the division statement of Rand divided by 100 or REM max so this will return either front this will return from 0 to 99 and so we just add 1 so if it's 0 it'll go to 1 if it's 1 it'll go to 2 if it's 2 2 etc etc and if it's 99 it'll go to 100 stuff like that ok so now we get a random number between 1 and 100 next we have variables has one self-explanatory this is whether the user has one yet or not and now this is going to be our main game loop okay so just say while not has one essentially what we're going to do is we're going to keep looping until the user has one and another variable just remembered of our current tries as equal to zero so in this loop we're going to say current tries is plus plus so this will essentially increment current rise by one so that we can keep track of how many tries the user has then we're going to check or actually we're going to let current guess is equal to yet integer and so that will give us a value that the user wants to guess or actually you know what let's just print enter a guess now enter a guess and then that'll happen okay perfect then what we need to do is say if current guess is equal to our current number then we're going to print out u1 in current tries tries perfect then we're going to check if the current tries or the current guess is greater than the number that they should be guessing then we say your number is too big else if again current gas is less than this time the current number and this will mean if their guess is smaller than the number they should be guessing then say your number is too small perfect close that up and also one more thing if the user wins we should tell the while loop to stop by saying has 1 is equal to true perfect now in theory this should be a perfectly good guessing game but one last thing I need to put in which is let's just print out the current number each time just to say okay so now it's quit and run it now okay it's just um them guessing game you have to before you actually call R and you have to surround it in int breath braces or you can Bertrand Maxwell 32 which I don't want to do okay so now let's just run our guessing game okay so it's 84 but let's just say 82 small 92 big it's 84 perfect got it in three tries now let's clear this and run this again it's 84 on it again it's 84 and pretty soon you get the point it's 84 all the time so how do we fix this you may be asking well it's simple all we need to do is open up the file and right as we start just say s R and time nil done essentially what this will do is it will seed the random function with your current time and so it always starts from a new random point and so now if I save and quit I clear and I run okay one last modification means to do you need to surround time in you and 32 that's it then we're done save quit clear and run as you can see 90 so if we say 100 to big 62 small 90 got it and three tries run it again 22 let's run it again 17 okay now let's go back into our file and remove the print so that there's a point of actually playing it and there we go save quit clear and run perfect now let's enter guess I asked 52 small 102 big 75 too small so it's in between 75 100 so let's say 86 too big 82 so long 84 too big 82 and 83 80 81 got it in ten tries okay so that was actually how you make a guessing game in Swift and yeah so I'm just gonna sum this up by saying this is how you can learn to use swift on pretty much any computer if you have Windows you can virtualize a book is you have a bun to great job if you have a Mac there's no point of a bun - you already have so but this is how you can without getting a Mac run swift and see if programming's for you if it is well then you might as well get a match and start programming for iOS and so that's going to be it for this tutorial if you liked the tutorial please leave a like it does help a lot and also subscribe to the channel if you're new or you like my cotton you want to see more of it if you have any questions concerns etc etc you can email me at tasman gmail.com you can get me you can contact me ask Tajima on twitter or you can just leave comment down below I'll reply to anyone I don't really care about that and that's going to be it for this tutorial goodbye and I'll see you in another interesting tutorial
Unlock the Power of Artificial Intelligence, Machine Learning, and Data Science with our Blog Discover the latest insights, trends, and innovations in Artificial Intelligence (AI), Machine Learning (ML), and Data Science through our informative and engaging Hubspot blog. Gain a deep understanding of how these transformative technologies are shaping industries and revolutionizing the way we work. Stay updated with cutting-edge advancements, practical applications, and real-world use.
Subscribe to:
Post Comments (Atom)
AI:List in this era since last 5000 years how does the pets and stray animals were used in various ways in home premises, outside field , colonies,and commercial work especially in old ancient countries with great legacy like India. How and what things were being done which people after those got useless, or got diseases end or un curable, or got died what’s being done to their bones, skin and various by products which people were responsible for it. When did it all changed to get a professional thing and commercialised on large and small scale. How other parts of work in ZuS, UK, Canada, Africa, MuddleEast, Oceania, Asia, Russia, Korea perform this manually or with tools which people category were responsible for it. Which AI humanoid robotics can be deployed using various neural networks and LLMs with the help if various AI automated techniques to perform it in more commercial way in totally renewable and recyclable manner with zero pollutants.
Here’s a comprehensive overview of how humans have used pets and stray animals over the past 5,000 years—across India, other ancient civ...

-
A joint attention-based deep learning system provides good predictive performance for differentiating autism spectrum disorder (ASD) from t...
-
Kiwi expat and former award-winning creative at Colenso BBDO, W+K and AMV BBDO London Ben Polkinghorne has founded a new AI start-up called...
-
With an expected annual growth rate of 37.3% between 2023 to 2030, AI has become a dominant technology worldwide. Whether banking and finan...
No comments:
Post a Comment