5 / 5 ( 1 vote )

Xcode: Apple’s official IDE for iOS programming, which’s got 2,5 stars in AppStore. How to upgrade Xcode, how to use some tips & tricks to make it easier to use, how to add useful features or helpful plugins? Here I am, to help you, to advise you, to show you some ways to make Xcode more… accessible.

I assume that this tutorial is for beginners to show them

there’s more than what by default Xcode and Swift offer. But if someone experienced found it helpful that makes me happy 🙂

I this article I will show you:

A faster way to handle localized strings.

Using Xcode and simulator for split-screen.

Debugging on a device via Wi-Fi.

Making words as warnings to be more organized.

Making warnings as errors.

4 different ways to search through Xcode.

This tutorial is dedicated for Swift and Xcode 9.

1.A faster way to handle localized strings for faster programming.

Wouldn’t it be better to use „text”.localized rather than NSLocalizedString(“text”, comment: „”)?

If you don’t need comments in your localized files then this solution may interest you. I modified an idea form here. The original framework is more than I need to my usual projects, but it enables changing language form code, so if someone is interesting place check it also.

Now, to work!

Add this extension to your project:

View the code on Gist.

To generate localized.strings copy the genstrings.swift file into your project’s root directory and run:

./genstrings.swift

I modified the original program to save the output to file. The default is localized.string, but if you want another file just add file name and type as argument. To modify input directory run it with a name and a type of a destination file and a path to your project directory as arguments.

It will search through all .swift files to export .localized strings to the destination file in the directory you’ve chosen.

And that’s it 🙂 I hope you will find it helpful and time-saving.

Using Xcode and simulator for split-screen.

Are you tired of swiping left/right from Xcode to simulator and back? Here’s trick for you!

But be aware that this is experimental, not supported by simulator yet and you’re doing it at your own risk.

There shouldn’t happen anything unexpected, but you can ask someone more experienced to help you.

Follow this steps:

If you’ve got MacOS 10.11 or higher you need to disable SIP(System Integrity Protection). If you want open this article on another device, because you need to go to Recovery Mode.

To turn off SIP:

Reboot your Mac into Recovery Mode (hold command + R while restarting until Apple logo appears). Utilities -> Terminal In the Terminal type in csrutil disable and press enter . Now restart your Mac normally.

Not in normal mode to enable fullscreen simulator:

Create AppleInternal folder by tapping in terminal:

sudo mkdir /AppleInternal

Now alter restarting simulator select Internal Menu -> check Allow Fullscreen Mode.

And finally, you can drag and drop Simulator to fullscreen Xcode!

Remember to remove directory AppleInternal by tapping in terminal

sudo rmdir /AppleInternal

And to enable SIP by tapping in a terminal in Recovery Mode:

csrutil enable

Debugging on a device via Wi-Fi.

Everything is wireless, debugging can be also!

Of course, for the first debug on your new device you need to be connected via wire, but only for the first time 😉 After that just

go to Window Devices and Simulators ( command + shift + 2 ) Choose your device Check Connect via a network Plug off your phoneAnd run your project! Now you can fill free to connect your device only when you want to (or when you’r out of battery juice 😉 ).

Making words as a warning to be more organized.

What’s good from TODO, when you have to look for it through all files. So… maybe use it as a warning! You will always see that something needs your attention.

Go to projects settings Choose your target Build Settings Click + Select New Run Script Phase Add this to your script :

View the code on Gist.

And that’s it! It’s all set up 🙂 Now after every build, you will see new warnings like this:

Making warnings as errors.

Or maybe you’re a perfectionist who doesn’t want to have any warnings in your projects? You can always treat them like errors.

Go to projects settings Choose your target Build Settings Find Swift Compiler – Warning Policies Set Treat Warnings as Errors to Yes

Now every warning will be treated as an error and you want to be able to build your project when there’s even one warning.

4 different ways to search through Xcode.

New in a project? Or maybe the project is big to dive in directories? You can choose one from this ways to find what you’re looking for 🙂

Quick search: command + shift + O

It works like command + space , but only with files. So whenever you are looking for some file and you don’t know where it is just type command + shift + O and start searching!

Find Navigator ( command + shift + F )

If you are looking for a concrete phrase, but you don’t know in with a file it is, just go to Find Navigator and type it! You have some advanced parameters such as ignoring / matching case, starts with / ends with / contain / matching word.

Search on the bottom of Project Navigator

There’s also filter on the bottom of Project Navigator. Start taping your text and you will see only files which names contain that text.

Cmd + F