Xcode, Xcode, Xcode... How not to love? How not to hate? - ITgenerator

Free e-book! "The complete guide on how to avoid mistakes in creating mobile apps" DOWNLOAD NOW

Xcode, Xcode, Xcode… How not to love? How not to hate?

Dominika Czarnecka

16/04/2018 5 min read

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:

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:

  1. Reboot your Mac into Recovery Mode (hold command + R while restarting until Apple logo appears).
  2. Utilities -> Terminal
  3. In the Terminal type in csrutil disable and press enter.
  4. 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

  1. go to Window
  2. Devices and Simulators (command + shift + 2)
  3. Choose your device
  4. Check Connect via a network
  5. 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.

  1. Go to projects settings
  2. Choose your target
  3. Build Settings
  4. Click +
  5. Select New Run Script Phase
  6. Add this to your script :

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.

  1. Go to projects settings
  2. Choose your target
  3. Build Settings
  4. Find Swift Compiler – Warning Policies
  5. 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

You can always tap command + F to look for text in a current file or in an active console.

 

Rate this post:
5/5 - (1 vote)

Dominika Czarnecka
iOS Developer at ITgenerator

The complete guide on how to avoid mistakes in creating mobile apps

Ebook - The complete guide on how to avoid mistakes in creating mobile apps

It is fast, safe, beautiful and costs as much as a nice car - except it is a mobile app

For Business

It is fast, safe, beautiful and costs as much as a nice car - except it is a mobile app

5/5 - (1 vote) Mobile apps are everywhere. You wake up in the morning and check WhatsApp or messenger, you go for a run with Endomondo, play games like Minecraft...

Keep reading

Join our
tech-driven
community!

Shape your future with the great team