hiatus

In the past, I’ve tried to post consistently (monthly) and the results have been mixed. I’ve posted some useful tutorials and lots of posts for the sake of posting.

For now, I no longer want to stick to a routine schedule of random content. With some (super minor amount of) time freed up, I’m sure I’ll be able to waste it surfing the web, working on iOS apps, or simply doing life.

I can still see myself posting content (tips, tutorials, observations, etc.) here, but it’ll be more intentional.

Best,
-Rex

iOS Developer iPhone (Dec 2018)

As an indie iOS app developer, keeping up with Apple’s hardware can get expensive fast. From the Mac to the iPhones and iPads.

I’m focusing on native iPhone apps and currently use an iPhone 7 as my daily driver. I’m considering getting a new iPhone and want to find the right balance between 1.) phone size I want to use daily and 2.) phone is optimal for App Store Connect previews (videos) & screenshots.

Since I’m an AR app developer, having iPhone hardware is essential (the Simulator doesn’t cut it).

Looking at the state of iPhone hardware today (Dec 2018), some quick Googling shows that the iPhone 7, 7+/8+, and X form factors are the most common in the US.

When we look at Apple’s App preview & screenshot guidelines, it tells us that the 5.5 inch (iPhone 8+, etc) form factor is required (screenshots) and recommended (app previews).

For 2019, my guess is that supporting the 5.5 inch (8+) form factor and the 5.8 inch (X/XS) on App Store Connect would give me the most bang for my buck. It would be nice to have both a XS & XS Max to test with, but that’s way out of my budget.

Curiously enough, the app preview video resolutions are the same across the X line (X, XS, XS Max, XR at 886 x 1920 pixels (when portrait). The video resolution is bigger at 1080 x 1920 pixels for the plus line (8+, etc).

Using App Store Connect, I was able to manually verify the different screenshot upload resolutions for the iPhone XS Max (1242 × 2688), iPhone XS (1125 × 2436), and iPhone 8+ (1242 × 2208). It seems like there is no point to try to take or upload iPhone XR screenshots.

In summary, the iPhone plus (8+, etc) line is the most important for app previews & screenshots. After that, the XS & XS Max (in that order) will give you more App Store Connect coverage with diminishing returns.

Pokemon Go – Use items to evolve Pokémon 2 times (6/8) Evolve & Walk Chart

In Pokémon Go, I currently have two open Special Quests: Mew & Celebi.

I’m currently at step 6/8 for Celebi. I have too many of each evolution item (Dragon Scale, King’s Rock, Metal Coat, Sun Stone, and Up-Grade) from hitting Poke stops & playing over time. What I don’t have is enough candy. Since catching enough of these monsters is not reliable, I have to walk one as my buddy to get enough candy to evolve (with an item).

What I wanted to find out is which pokemon to walk & evolve. Crucial questions are 1.) how many kilometers it takes to walk as your buddy to get candy and 2.) how many candies it takes to evolve.

From To Item Evolve (candy) Walk (km)
Poliwhirl Politoed King’s Rock 100 3km
Slowpoke Slowking King’s Rock 50 3km
Gloom Bellossom Sun Stone 100 3km
Sunkern Sunflora Sun Stone 50 3km
Porygon Porygon2 Up-Grade 50 3km
Seadra Kingdra Dragon Scale 100 3km
Scyther Scizor Metal Coat 50 5km
Onix Steelix Metal Coat 50 5km

To use this chart, I would recommend looking at which pokemon in the From column you have. Next make a note of how many candy you have for each of those pokemon. To meet the quest requirements in a timely manner, you want to pick pokemon to evolve which only require 50 candy & 3km to walk per candy (also factoring in how much candy you have already).

Driving a rental car in Switzerland

Recently, I visited Switzerland for vacation (Sep ’18) and spent a week driving around sightseeing with family.

Disclaimer: you should do your own research (regarding topics such as driving laws).

While I’ve read many great things about the public transportation system (trains & buses) and I would encourage you to take their excellent train system, driving made sense for our situation.

Pros

  • Direct transportation. Walking between the train station & hotel each day is not trivial. The uphill hike from the train station to Gruyère didn’t seem easy either.
  • Flexible. Not being tied to a train/bus schedule allowed us to see more places.
  • Scalable. Having a large car makes sense financially with a large group. Our 8 day car rental was $400. A 2nd class, 8 day unlimited train ticket is over $400 for one person.
  • Storage capacity. Storing infant items, extra clothes, etc. in your car is very convenient.
  • Park centrally. All the city centers we visited had parking near the tourist areas (such as old town). The blue ‘P’ signs are very easy to find when you are looking for parking nearby.

Cons

  • Parking
    • Expensive. This goes without saying if you are planning a trip to Switzerland. Parking in the city center for a day is not cheap. Bern was particularly expensive to park in. In Bern, I made the tradeoff to pay more for parking and enjoy the city longer.
    • Coins. Older parking areas may require coins (if they do not accept credit card).
    • Tight parking. Many older cities (such as Zurich) have extremely narrow parking spots & turns. This is a huge factor if you care about not scratching your rental car. Drive carefully & slow.
    • Language. The parking signs may not have English instructions.
  • Speed limits. I did my best to stay under the speed limit everywhere. I was told (online & in-person) that speeding in Switzerland comes with big fines. Driving & constantly checking your speed makes for very stressful driving.
  • Expensive. The cost of car rental, parking, and gas quickly add up. However, I felt the cost of driving wasn’t bad compared to buying a few train passes.

Tips

  • While driving in Zurich, many parking garages would show “FREI”. This confused me initially as I read it as “free parking” (no cost). The actual meaning is “free spots” (parking available).
  • Not a big deal, there are a lot of tunnels to drive through around the country.
  • My rental car had a number of helpful features: current location speed limit display, parking collision detection, and standard GPS navigation. I’d highly recommend these features.
  • To stay under or at the speed limit, I often relied on my rental car’s cruise control system to set the exact speed. Beware because you will often enter lower speed areas, and you’ll need to lower your speed suddenly.
  • While driving in Switzerland, your headlights always need to be on. I set my car rental to have automatic lights. Easy.
  • I would recommend renting from Sixt at the Zurich airport. (I have no affiliation with them.) I was able to get my BMW 2 series rental quickly and received good customer service.
  • There are car free areas in Switzerland, so do not plan to drive to them.

Driving in Switzerland is not cheap, but it comes with many benefits. I would recommend driving in Switzerland if you are traveling with a large family or kids.

iOS 12 Siri Shortcuts

The latest update (v1.3.6) of my iPhone app, Power Focus, passed app review today! The App Store review turnaround is amazing nowadays. Super quick.

My app includes minimal iOS 12 Siri Shortcuts support. Watching the WWDC session, there’s two ways to add Siri Shortcuts support: NSUserActivity & Intents. I went with the former since I didn’t need custom Siri UI.

Of different online resources, Anton’s medium post was really helpful as it covers the essentials of using NSUserActivity. With NSUserActivity, the important parts are donating Shortcuts during app usage and handling them in your App Delegate. That’s it.

The experience of implementing minimal iOS 12 Siri Shortcuts was painless and I would recommend your app using NSUserActivity to inform iOS when key actions occur.

Using SVG / PDF assets in your iOS app

This guide covers a simple way to use SVG (Scalable Vector Graphics) assets in your iOS app. This was tested on macOS High Sierra 10.13 with Xcode 9.4 and Swift 4.

There are many websites where you can find SVG icons. Check out Material or ionicons

  1. Install homebrew & python3 for macOS (if you don’t have it)
  2. Install cairosvg. The code below installs various dependencies
    brew install python3 cairo pango gdk-pixbuf libffi
    
    pip3 install cairosvg
  3. Convert your SVG icons to PDF files. Make sure to navigate to the location of your SVG icon files. Run this command for each icon file (with the relevant *.svg & *.pdf input / output file name):
    cairosvg icon.svg -o icon.pdf
  4. Drag your PDF files into your Xcode Assets.xcassets folder
  5. Adjust the settings for each icon in your xcassets. You may want to adjust:
    1. Name – this is important as you will refer to this in your Swift code to use the icon
    2. Set ‘Render As’ to ‘Template Image’
    3. Check the box for ‘Resizing – Preserve Vector Data’
    4. Set ‘Scales’ to ‘Single Scale’
  6. Use your icon in your app. I did this programmatically in Swift, and this works in your ViewController. Make sure to update the ‘iconName’ to match what is in your xcassets for your icon file.
    if let icon = UIImage(named: "iconName") {
        let image = UIImageView(image: icon)
        image.translatesAutoresizingMaskIntoConstraints = false
        image.tintColor = UIColor.blue
        view.addSubview(image)
    
        NSLayoutConstraint.activate([
            image.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            image.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            image.widthAnchor.constraint(equalToConstant: 24),
            image.heightAnchor.constraint(equalToConstant: 24),
            ])
    }
  7.  That’s it. Your SVG file was converted to a PDF file, added into your Xcode assets, and called from your ViewController!

DJI Spark – First Impressions

I’m new to drones and picked up a DJI Spark Fly More Combo during Prime Day, where it was $50 off. The price before tax was $500. The combo includes the remote control, an extra battery, and more helpful accessories.

The Spark hardware is a marvel of engineering. It’s not that big, but it packs a lot of technology inside. I chose the Spark since I wanted something small & novice friendly. The operating noise is very loud for my taste, but it’s to be expected for current drones.

The setup experience to start using the drone was very confusing. After charging my batteries & the remote control, it took me a long time to understand how to pair & fly the Spark.

The key revelation is that the Spark drone and the remote control each have their own WiFi network. Depending on which way you want to fly (using phone or remote), you have to connect to the right WiFi network. The problem is that the WiFi network(s) don’t always show up.

I couldn’t find any Spark WiFi networks, so I had to hold the power button on my drone for 10 seconds to reset the drone’s WiFi. Then I could connect to the drone with my phone.

Despite being able to connect to my phone, I wanted to use my remote (instead of the phone’s virtual joysticks). This link about rebooting the remote helped fix my issue. With the remote WiFi to phone being so unreliable, I’ve gone and ordered a 3rd party Lightning to USB Cable.

The drone to phone or remote pairing process is very painful. The process involves pressing & holding various buttons on the drone or remote and waiting several seconds for different beeps & lights. It’s about as user unfriendly as you could get. There is potential for a firmware update or DJI GO 4 mobile app update that would help resolve some of these pain points, but I wouldn’t hold my breath.

Once you are able to pair the drone to the remote control (and pair your phone to the remote control), the flying part is fun. There’s a learning curve, but the remote control’s hardware joysticks make flying intuitive.

One other note, I’m currently residing in Los Angeles. LA is not drone friendly as there are many airports and restrictions. It’s very likely you can’t fly where you want to in LA. Definitely check out where you can fly drones in your area before purchasing a drone.

My Aging MacBook Situation

My personal daily driver is a 2011 MacBook Air (MBA). I’ve shipped 6 iPhone apps from it. For a computer bought in 2011, I’m happy with how long it has lasted.

I am interested in buying a new MacBook Pro (MBP) to replace my aging MacBook Air, but I’m not sure what to do. The possible choices I see are:

1.) the current MBP (June 2017 version)
2.) wait ? months for an updated MBP (most likely a minor CPU refresh)
3.) a 2015 MBP version (older hardware style with IMHO better keyboard)

Reasons to upgrade sooner:
* Xcode runs poorly on my MBA. Storyboard, Simulator, and Playgrounds are barely usable.
* macOS Mojave will not run on my MacBook Air. It’s only a matter of time before I’m locked out of macOS & Xcode updates.
* Apple announced a Keyboard Service Program.
* As a professional software developer, I can easily justify 2-3 year upgrade cycles.
* My MBA is showing it’s age; the battery is virtually gone.

Reasons to upgrade later:
* My MBA is able to run Xcode 9 (current) and will hopefully run Xcode 10 GM.
* Buying after a new hardware refresh (minor CPU bump most likely) maximizes the currentness of the purchase. This may not be rational, but it’s a factor nonetheless.
* My iPhone app development is primarily dependent on iPhone hardware updates & Xcode, not my Mac.
* Indecision – since none of the current MBP options (2015 or 2017) are very appealing, I can wait it out.

Reasons that don’t make a difference:
* I don’t like typing on the current generation MBP keyboard, but the next significant MBP hardware refresh is probably a few years away (too long).
* USB-C – I’ve found a Multi-Port Adapter (dongle) that works for me.

Inconclusion

In retrospect, I should have bought a decently equipped 2015 MBP in 2015.

If Xcode 10 GM doesn’t work on my Mac, then I’ll be forced to buy a new Mac right away. Otherwise I will wait around hoping Apple decides to update the MBP.

Git Config Email String

This is about a simple problem that is obvious after the fact. I was having an issue with my commits on github.com not being linked to my github account. It seemed like I had set everything up (git email configured locally & e-mail set in my github.com account), but it wasn’t working.

On a mac, you probably know you can set your git user e-mail this way:

git config --global user.email name@domain.com

Following the github guide (https://help.github.com/articles/setting-your-commit-email-address-in-git/), I included quotes when setting my git config email.

git config --global user.email "name@domain.com"

It turns out that was a mistake for me since my commits were being associated with “name@domain.com” instead of name@domain.com. Note: the inclusion vs exclusion of quote characters.

After running the git config command above without quotes, I was able to properly link my commits on github to my github user profile.

Intro to Computer Vision

I’m new to computer vision and a lot of the basic concepts are very interesting. As an iOS developer, my interests comes from using CoreML & Apple’s Vision in apps to improve the user experience.

Two common tasks are classification and object detection. Classification allows you to detect dominant objects present in an image. For example, classification can tell you that photo is probably of a car.

Object detection is much more difficult since it not only recognizes what objects are present, but also detects where they are in the image. This means that object detection can tell you that there is probably a car within these bounds of the image.

What’s important is that the machine learning model runs in an acceptable amount of time. Either asynchronous in the background or in real time. Apple provides a listing of sample models for classification at https://developer.apple.com/machine-learning/.

For real time object detection, TinyYOLO is an option, even if the frame rate is not near 60 fps today. Other real time detection models like YOLO or R-CNN are not going to provide a sufficient experience on mobile devices today.

One other interesting thing I came across is the PASCAL Visual Object Classes (VOC). These are common objects used for benchmarking object classification.

For 2012, the twenty object classes that have been selected were:

  • Person: person Animal: bird, cat, cow, dog, horse, sheep
  • Vehicle: aeroplane, bicycle, boat, bus, car, motorbike, train
  • Indoor: bottle, chair, dining table, potted plant, sofa, tv/monitor

These are common objects used to train classification models.

Computer vision used with machine learning has a tremendous amount of potential. Whether used with AR or other use cases, they can provide a compelling user experience beyond Not Hotdog.