Tag Archives: xcode

Xcode run script

There always comes a time in the life of a iOS developer when it has to create a for various reasons a script to automate a certain task. For example, you can create a script on your production target that every time you make an production build your localisable files will be stripped of unused keys, this was a simple example but you can create more complex functionalities with this feature of Xcode.

How do you create an run script?














Thats it, simple as that.


Now lets talk about what can we write in here.

What sort of scripting language can we use, we can use basically any type of scripting language that comes installed on macOS, a few example would be:


Another great thing, which I found out from an Stackoverflow post, is the fact that we can specify input and output files. Basically we can tell Xcode which file we are going to read in our script so that the build script is run ONLY if one of those files has changed, if the files haven’t changed Xcode caches the result, so it won’t affect the build time. Output files are the files out script writes to, we specify those so that if they haven’t changed, Xcode can cache the build.

One specifically thing worth mentioning, is the fact that the order of the build phases, matters, so if you want your script to be run before the compile phase, you can do that by dragging it before the compile phase.

If you follow the 3 images in this post you will have a project which when you’ll run it it will produce a file named myFile.txt in the root of your project with the content “Hello world”, while this is useful, sometimes when you are writing your script, you need to check the output of the commands. If you modify the script by deleting “> myFile.txt”, the result will be just ‘echo “HelloWorld”‘, if we delete the initial file and run the project again, no file will be generated and we can no longer see the output. In order for us to see the output of the script, we need to access the Report navigator in Xcode and select the build phase.






Last but not least, you can use many path variables and even git commands to fetch any details about your project repo.

So you wanna learn iOS …

Hi there, this is my first post from many (hopefully) to follow in which I try to explain things I struggled with or things I found interesting while learning how to make apps for iPhone.

One of the first things someone who is willing to learn iOS development has to do is get his tools. Easier done then said if you are on a Mac, all you need to do is download Xcode and you are good to go. However, if you are on a Windows or Linux machine, you need to install a virtual machine which has macOS, which is not legal, but it can be achieved, or install macOS directly in you computer, if your hardware supports it. Otherwise, if you want to get you hands dirty, you can always build yourself a hackintosh, but in my humble opinion is if your can afford it, you should by a Mac, it will save you of a tons of “troubles” and you will love it.

Assuming you’ve installed Xcode, on any of the setups described above, we can move to the next step and explain a bit what is Xcode and why we are using it. Xcode is one of the most powerful and widely used IDE on Mac for developing C, C++, ObjectiveC and Swift apps. It’s highly optimised for building iOS, tvOS, watchOS and macOS apps, but people also use it to develop other types of apps.

Why use Xcode?

Apple has tried (successful in my opinion) to make the developers life as easy as possible. What do I mean by that? Basically all you need to develop, test and lunch your client side app is build in this IDE. It has a lot of powerful tools for debug (see Instruments), development, and deploying your app, and you don’t need to struggle with other things, such as different command line tools, or multiple programs or IDE’s just to achieve your purpose (creating an iOS app). Most of the developers I know, experts or beginners use it for development, but the development can be done in other environments as well for eq. Facebook developed Nuclide.

Xcode is definitely a perfect tool, but most of the people I know, in fact all the developers I know personally, get along with it pretty well and are contempt with its performance. Of course depending on the project, Xcode might not be the right tool for you but, if you are just starting developing apps for Apple platforms, I strongly suggest you to use it.

Other tools

What other tools? Like I said Xcode is all you need! Next time we’ll start to talk about actual development as its pretty straight forward to get a simple project up and running.

Start Xcode -> “Create new Xcode project” -> iOS Application -> Single View Application -> Enter a product name such as “My demo app” -> Next -> Choose a location on the disk and press create!

Now just press the “play” icon on the right of the macOS close, minimise and maximise buttons and your first iOS application will start on the selected simulator.

Thats it, you new shiny demo app is running.

See you next time!