Thomas Lextrait

Sr iOS Developer at Square

Read this first

Deleting Old iOS Simulators

I’ve been developing iOS apps for some time now and after a few iOS versions, my list of simulators starts looking like this:

Screen Shot 2018-11-27 at 1.48.17 PM.png

Each simulator takes from 100MB to 1GB of space, so this can eat up your disk space really quick! The trick is to simply delete the simulators you don’t need.

In the menu bar simply go into “Window” and click “Devices and Simulators”. The shortcut for this is ⌘+⇧+2 (Command+Shift+2).

Screen Shot 2018-11-27 at 1.48.30 PM.png

Then go into the “Simulators” tab and hit the delete key on all the simulators you no longer want!

Screen Shot 2018-11-27 at 1.48.37 PM.png

You can also rename your simulators:

Screen Shot 2018-11-27 at 2.10.28 PM.png

Continue reading →


A Few Xcode Tips

In this post I just want to share a few super useful tips & tricks I’ve learned over time with Xcode.

 Shortcuts

 ⌘+⇧+O

cmdshifto.png

If you don’t know ⌘+⇧+O (Command+Shift+O) then I’m really sorry because life must be hard. This is definitely the very most important shortcut in Xcode. Try it out, ⌘+⇧+O is a magical “open anything” shortcut. It summons a search bar, a little bit like CMD+Space does on Finder and allows you fuzzy-search anything in your codebase. It can find text, symbols, class names, methods, and more. Given it does fuzzy search, if you want to find a class named MySuperCrazyLongNamedViewController you can type something like MSuCrNa and it will find it.

 Mash+U

“Mash” is common language for ⌘+⌥+⌃ (Command+Option+Control). So hitting ⌘+⌥+⌃+U will run all the unit tests in the file current open.

 Mash+G

⌘+⌥+⌃+G will run again whichever was the very last unit test you ran.

 ⌘+⇧+?

...

Continue reading →


A Day At Square

Square,_Inc._logo.svg (1).png

I work at Square as a Senior iOS Engineer and here’s what a typical day looks like for me.

 Sunrise – 6AM-7:30AM

I usually get up at 6am, brush my teeth, feed my pets and jump in my car to get to work around 6:30am. I don’t usually eat anything nor make coffee because I’ll get those in the office. I live in Hayward, California and the commute to San Francisco is 27 miles. This usually takes 1 to 2 hours driving in a gas car, or about 1 hour in a low-emissions vehicle. This is because low emissions vehicles are allowed to take the HOV (high occupancy vehicle) lanes and skip much of the traffic. I recently switched my car for an electric car and saved myself 30-60 minutes a day. I could also take the BART and the trip is about 45 minutes, but it does take extra time to get to the BART station and parking the car.

Below is a timelapse video of my commute.

The video above was shot...

Continue reading →


Un-implemented Methods in Swift

A great feature of Swift is that you can require that subclasses of a class implement a method. This can be achieved with required. However, if you’re on the other side wanting to subclass something with no intention to implement all the required methods then it’s a lousy situation and this has bothered me for a while. Xcode recommends by default that you crash the app. A super famous example is this:

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

A lot of of the iOS SDK classes are NSCoding, which means they can be serialized and deserialized. If you subclass UIButton for example then you’ll have to implement the method above because UIButton is NSCoding. By default, Xcode fills the implementation of your method with fatalError("init(coder:) has not been implemented"), which suggests that if you don’t plan on implementing the...

Continue reading →


measureBlock: How Does Performance Testing Work In iOS?

I was working on a mini project at Square involving performance unit testing for iOS. Essentially I’m looking into how we could introduce performance unit testing, what our options are and how it would scale on our CI. In this post I’ll just focus on the one tool Apple provides as part of its unit testing suite: the magical measureBlock method. The question was: how does it work? and is this going to work for us and our CI (continuous integration) process?

 What’s measureBlock?

For those who don’t know measureBlock here’s a little background. When you write a unit test in XCTest, a feature allows you to measure how long a block of code takes to execute. It looks like this in Objective-C:

- (void)testMyCodesPerformance
{
    [self measureBlock:^{
        [someClass doSomethingFancy];
    }];
}

Or in Swift:

func testMyCodesPerformance() {
    measureBlock {
...

Continue reading →


USCIS Help

I mostly focus on technical posts but usually when I write I try to write about things I personally struggled to find on the web so that perhaps my own post may help others looking for information in the future.

This will be about the United States Citizenship & Immigration Services (formerly I.N.S.). Plus I feel like immigration is a topic that affects people in technology a decent amount so I guess this should be relevant. Take this article as a list of resources that can help you getting processed by USCIS within your lifetime.

 Me

I’ve dealt with the US immigration and USCIS for over a decade and learned a lot over time. Some of my learnings I really wish I had learned earlier. For those who are citizens: a USCIS office is very much like the DMV with numbered waiting coupons except they have leather chairs. The reality with USCIS though is that if you fall through the cracks and...

Continue reading →


Getting Started With Chrome Extensions

Screen Shot 2018-01-18 at 4.27.30 PM.png

A long time ago, during an internship at Rakuten in Boston, I worked on a Firefox extension. It involved using an obscure markup language called XUL. There was very little documentation on it and it took me about a summer to build an MVP that could make requests to a NodeJS backend. That said, I wasn’t super keen on doing browser extension development again, however an opportunity arose.

At Yelp, all code repositories are stored in git on private servers. There is no UI so how do you do code reviews? Yelp engineers use an antiquated and open source piece of software called Review Board. Yelp is actually a contributor to the code base and maintains its own fork. Long story short… I didn’t like the Review Board UI and decided to fix it. However it was going to be a major pain for me to get access to Yelp’s fork of it and it wasn’t clear Yelp would let me deploy any changes. So I decided...

Continue reading →


Drone Hardware For The Rest Of Us

Coming from a software background I learned a few things about hardware while working on my Arduino drone. Much of what I learned is probably very simple and obvious and often that means it is not discussed much online as it’s considered common knowledge. However the landscape is changing: with Arduino, the barrier of entry has been lowered and people (such as me) who are not electrical engineers or hardcore hobbyists are able to build things. In this post I’ll go over a few things I learned and I hope it can save a few people many hours of research and trial & error.

 CW and CCW propellers

I always knew propellers could be designed to rotate either clockwise or counter clockwise.

FullSizeRender.jpg

However when I bought a set for 4 propellers on Amazon, I didn’t expect half of them to be clockwise and the other counter clockwise. It wasn’t mentioned on the listing at all. It is obvious now, quadcopter...

Continue reading →


Generic UI: Input<T>

Generic User Interface

For quite some time I’ve been bothered by the small use of generics in Apple’s iOS libraries. Third party libraries also typically make little use of generics. Generic typing is a fantastic feature of Objective-C and Swift. It allows developers to write code that is incredibly re-usable. The point of generics is really to write less code yet make it even more robust and less prone to errors.

TL;DR GitHub Generic UI

 What Are Generics? (or skip this to the next part)

For those who don’t use statically-typed languages much or just don’t know about generics, the simplest example is that of the array:

class Array<Element> { ... }

In this example the generic type is Element. The person who created the Array class made it so you can customize it for your own use. You can supply – at compile-time – the type of element the array will store. So if you make an Array<String> you will know...

Continue reading →


Find All Images With Given Attributes

I’m an iOS developer and with the release of Xcode 8 came a little issue. Apple introduced wide-color support on iOS 9. This meant that if you had 16 bit images then you couldn’t target older iOS versions, otherwise you would see something like this:

ERROR ITMS-90682: Invalid Bundle - The asset catalog at ‘Payload/XXXXX/Assets.car’ can’t contain 16-bit or P3 assets if the app supports iOS 8 or earlier.

So this prompted the need for me to easily find 16-bit images. Apple did help with that but it was really Xcode-project specific and I wanted to have something more generic.

 Note For iOS Devs (Others can skip)

For those of you who are finding this page because you’ve had this error, do also check this page: https://forums.developer.apple.com/thread/60919?tstart=0 and note the following:

If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will...

Continue reading →