Swift Cheat Sheet for iPhone Location Services Access & Usage

This is a cheat sheet of the code and workflow for iPhone location access and usage, from requesting permission to using the location of the user’s device. Jump to… Framework Import Set Location Usage Description in Info.plist Initialize CLLocationManager and Implement CLLocationManagerDelegate Start Location Services, Check Location Authorization Status, Request Permission Alert Location Access Needed […]

Swift Cheat Sheet for iPhone Camera Access & Usage

This is a cheat sheet of the code and workflow for iPhone camera access and usage, from requesting permission to using the photo taken with a user’s device. Jump to… Framework Import Set Camera Usage Description in Info.plist Check and Respond to Camera Authorization Status Request Camera Permission Present Camera Alert Camera Access Needed Use […]

Swift 4 Upgrade Error: ‘init(colorLiteralRed:green:blue:alpha:)’ is unavailable

I upgraded a project to Swift 4 today and hit a compiler error: ‘init(colorLiteralRed:green:blue:alpha:)’ is unavailable: This initializer is only meant to be used by color literals. The fix is pretty simple: Don’t use that initializer! (thank you, Captain Obvious!) The correct initializer to use for specifying a red, green, blue, and alpha to get […]

Local Receipt Validation for iOS in Swift From Start to Finish

Local Receipt Validation for iOS in Swift From Start to Finish

Local receipt validation in Swift doesn’t seem to be widely written about. I’ve been able to find snippets of code scattered across the Internet, but nothing that brought everything together in one spot so that I could wrap my head around the whole process. I’ve been working on some code for a while, and this […]

Finalizing Receipt Validation in Swift – Computing a GUID Hash

The aim of this guide is to help you finalize the receipt validation process by computing the GUID hash for your app, and comparing it to the hash that’s stored within your receipt itself. This is a continuation of my receipt validation series. I’m assuming that… You’ve prepared to test receipt validation by setting up […]

Receipt Validation – Parse and Decode a Receipt with Swift

The aim of this guide is to help you parse a receipt and decode it so that you have readable pieces of metadata to inspect and finalize all of the receipt validation steps. This is a continuation of my receipt validation series. I’m assuming that… You’ve prepared to test receipt validation by setting up your […]

Receipt Validation – Verifying a Receipt Signature in Swift

You’ve prepared to test receipt validation by setting up your app in iTunes Connect. You’ve brought in a cryptography library like OpenSSL to be able to work with the PKCS #7 container that acts as the “envelope” for the receipt. Perhaps you’ve even done it the “easy way” with CocoaPods. You’ve located and loaded the […]

Using an Existing SQLite Store with NSPersistentContainer

If you’ve been creating the Core Data Stack without NSPersistentContainer and you’re thinking about switching things up to use NSPersistentContainer, you need to think about your existing SQLite persistent store. Creating the stack with NSPersistentContainer handles the creation of SQLite stores internally, so brand new setups using NSPersistentContainer are pretty easy. But how do you […]

Why is it called a “Closure” anyway? A Swift Conceptual Look.

Bottle with cork

What’s in a name? If a programming language comes with a named feature, you can be pretty sure it was named that way for a reason. It’s a safe bet that the language designers were purposeful in their naming, so if you can figure out that essential “Why’d they name it that?” question, you might […]

A Swift Implementation of the Core Data Stack Using NSPersistentContainer

If you’re targeting iOS 10 and above, you’ve got the opportunity to pick your poison when it comes to creating the Core Data stack. You could opt for the process I described in Creating the Core Data Stack with Backwards Compatibility in Swift — that process still works perfectly fine in iOS 10+. Alternatively, you […]