Building a concurrency-proof token refresh flow in Combine – Donny Wals. Refreshing access tokens is a common task for many apps that use OAuth or other authentication mechanisms.
No matter what your authentication mechanism is, your tokens will expire (eventually) and you'll need to refresh them using a refresh token. Frameworks like RxSwift and Combine provide convenient ways to build pipelines that perform transformation after transformation on a succesful network response, allowing you to grab Data, manipulate and transform it to an instance of a model object or anything else.
Programming the not-so-happy path where you need to refresh a token is not as simple. Especially because in an ideal world you only fire a single token refresh request even if multiple requests fail due a token error at the same time. You'll want to retry every request as soon as possible without firing more than one token refresh call. Setting up a simple networking layer These are just a few simple models. The networking itself is modelled by this protocol: Building an authenticator.
Announcing the pod merge plugin for Cocoapods! Written by Siddharth on October 17, 2019 Improve your app's startup time by reducing dynamic frameworks If your app uses a lot of external dependencies in the form of cocoapods, and you’d like improve your app startup performance, I have good news for you!
The pre-main time of apps (especially the dylib load time) can get especially high if you app uses a lot of cocoapods, and you use the use_frameworks directive in your Podfile, linking your pods dynamically. These dynamically linked pods are then loaded one by one on app’s startup, slowing it down considerably. If you’ve watched Apple’s 2016 WWDC talk Optimizing App Startup Time, Apple recommends you to merge your dynamic frameworks to improve your app’s load time. I’m delighted to announce a cocoapods plugin to do just that! 🗄 Merges your pods based on a MergeFile The plugin introduces a new file to your workflow, the MergeFile: Gosh Darn SwiftUI - Cheat Sheet. Using Combine. Publisher, Subscriber A publisher provides data.
It is described with two associated types: one for Output and one for Failure. A subscriber requests data. It is also described with two associated types, one for Input and one for Failure. When you connect a subscriber to a publisher, both types must match: Output to Input, and Failure to Failure. Skilled.io. Learn Talks. Events. NSLondon May 2016 Romaine Reid - Utilising Motion Design to Enhance Your App Roy Marmelstein - Scandal and Controversy in iOS Development Munich iOS May 2016 Elmar Kretzer - Palau - NSUserDefaults in the age of Swift Madhava Jay - Giving back with GitHub Stefan Mayer-Popp - Framework based architecture using Cocoapods Seattle Xcoders May 2016.
To Read. Optionals in SwiftUI. A friend recently asked me if I’d write a few words about SwiftUI and optionals.
Like nearly everything in SwiftUI, you have to rewire your brain a little bit when thinking about this because SwiftUI is perfectly happy working with optional views, such as Image? And Text?. The tl;dr of this post is going to be “use map” but before I get there, let me dive in a little deeper. VisualKit: UI Framework (UIView - Theme - Stylable) We applied the atomic design philosophy in our project by creating new standard components and using them in multiple scenarios.
This approach allowed us to write reusable UI code. VisualKit is Jobandtalent’s UI Framework. In a nutshell, VisualKit is a big modular package of views and controls where each one of them can be easily themed and modified to fit the design, just like playing with Lego. Gaudí : Theming lib (Theme - Color - Dark Mode) This framework uses semantic color names to better adapt to dark mode and other possible themes living within the same app.
Work with your designer to get these right. As Apple recommends, don’t take shortcuts and don’t change the semantic meaning of the semantic color. Gaudí’s SemanticColor enum provides a clear hint about what that color actually is: Backward Compatible Dark Mode (Theme - Color) Earlier this year Apple announced Dark Mode on iOS, that offers an option for a user to choose a system-wide light or dark appearance.
It is available starting from iOS 13. But if you aren’t that lucky with the iOS adoption rate, there is still a need to support older versions of iOS. In this article let’s take a look at how we can introduce Dark Mode that works on all iOS versions including iOS 13. It should be pointed out that adopting the Dark Mode(or Dark Theme) is not that trivial as it might look at a first glance.
Night Mode Theme (Color - Star) Adopt Dark Mode (Theme - Color) My metro app, both in dark and light mode.
Rejoice! iOS 13 comes with Dark Mode! 🤩 I’ve just finished adopting the new appearance in my own apps, and I’ve learned a few things along the way: let’s see how you can do it, too! Before diving in, we need to be aware of a few things: In order to give our users the best experience, it is really important that you don’t skip this part. Requirements For your app to support Dark Mode, it must: Have been built and released with Xcode 11 If you use Xcode 10 (or earlier), the app will always display its normal appearance, even on devices with Dark Mode enabled. . ⚠️ Here’s another way to look at it: if your app has not been updated with Dark Mode support by the time iOS 13 launches, the app will always display its default appearance, regardless of the iOS system settings.
Using Apple words: “You really don’t want to be that one light appearance that’s stuck in dark appearance”. Backwards Compatibility For iOS 13 System Colors (Theme) Theme With UIAppearance. Something that has become a big thing in iOS applications is ‘dark mode’.
But just how do you do theming on iOS. Well here is a simple way using Swift. There are many ways you can go about creating a theme using particular color sets and switch between them in iOS applications. This is my suggestion for a simple fast system that uses UIAppearance with some Structs to change the colors of components on the fly. Style UIView with functions (Stylable - Theme - Protocol) Written by Pierre Felgines on February 19, 2019 Today I want to talk about UIView styling.
The common approach when we want to customize the display of native UI controls (for instance UIButton or UILabel) is to create a subclass that overrides a bunch of properties. That works well most of the time, but some problems may arise. We you use subclasses in Swift to style your views, you loose composition. For example, if you create two UIButton subclasses, FilledButton and RoundedButton, how do you create a button that is both filled and rounded ? One solution of this problem is to stop using subclasses, but to leverage Swift functions and type system.
Theme Views With Factories. Let‘s say we wanted to create two UIButtons, that share the same features but differ in colour and have distinct labels. A red button that says “Cancel,” and a button with no background and a black border that says “Next.” First let’s define a protocol with variables that define the properties that will differ based on our user interface needs. In our case, we would define the following: Color Schemes (Theme) The usual story so far: Application with an intuitive colour scheme attracts us. Selecting a contextual as well as soothing colour scheme for your next application must be the first step before you start writing down a single line of code. You know that, me too. But the world does not. Especially the clients or designers who love to do a little bit experiment with UI . “Evil begins when you begin to treat people as things.” Style Sheets (Stylable - Theme) Dynamic Type (Font - Text - Size - Accessibility) Table of contents : Apple introduced dynamic type in iOS 7 to allow users to specify their preferred text size in the Settings app.
App that supports dynamic type will be able to adjust text size based on the user preferred text size. Settings app > General > Accessibility > Larger Text. This accessibility feature help users with visual impairment , or weakend vision due to aging to be able to read text on the device. By default, the text size slider is positioned in the center. According to a report by PDF Viewer app team, around 27 percent of their users have specified a non-default text size, which is quite significant! Create And Setup Object With Closures (Init - UIView - Helper) A classic sight at the top of a view controller is a list of views being instantiated and some properties being set on each: let contentView: UIView = { let v = UIView() v.backgroundColor = .red v.clipsToBounds = true return v}() let stackView: UIStackView = { let s = UIStackView() s.axis = .vertical s.distribution = .fillEqually s.alignment = .center s.spacing = 8 return s}() When I look at that code, I can’t help but feel that there’s some redundant and duplicate information, specifically: So, I created a function that can be used to make setup closures a lot neater:
Mixins (Associated Objects) Introduction As expected from any new modern language, Swift 1.0 launched with the concept of protocols. Protocols serve as a way to define a blueprint of methods, properties, and contracts that other types must fulfill. Some key benefits we get from using protocols are: Object Descriptors (Formatting) When building our apps, its fairly well known that passage models into our views leads to bad things. UICollectionView Helpers (Collection - Protocol) One of my favorite things in UIKit is UICollectionView. Container View Controllers (UIViewController - Parent - Child) Loading View Controllers (State - Composition)
Transcript Sample Code: You can download the playground we use in this episode from GitHub. Reusable Behaviours in UIViewController (Loading - Empty State - Protocol) Associated Types in Protocol to Compose Behaviour. Cell Registration & Reuse (Protocol Extension - Generics - UITableView - UICollectionView) iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView.
Force Orientation. Now back to mobile development (next to a million other things) at Kidiyo, I was underwhelmed with the lack of support from the iOS SDK to force different landscapes across an app. In this blog I share a neat solution that works (at least) from iOS 9.0 onward. TL;DR: Get my Orientation extension and check how to use it. UIScrollView Layout Guides (Star) Aug 20, 2018 · 5 minute read iOS 11Auto Layout. Interface Builder Tips. Feb 19, 2018 · 3 minute read Interface Builder My top ten tips, tricks, dos and don’ts to make you feel like an Interface Builder expert.
I wrote about the first two of these nearly five years ago. UISwitch Customization (Component) An adaptive button (Component - UIControl - Accessibility) I know. I started this series by extolling the virtue of using a UIButton instead of building something completely custom. Animations in SwiftUI. UITableViewCell Display Animation (UITableView - Fade) Make Your App More Interactive (Animation - Transition - Tips) Custom View Controller Presentation (Modal - Animation)
Custom Transition. Custom Navigation Transitions (Modal - Interactive) Instagram Zoom (Image - Gesture) Tricky UIViewController Transition Animation (Bezier) Custom UICollectionView Layouts (Animation - Transition) UIMotionEffect (Button - Shadow - Depth) Circular Loading Animation in a UITableViewCell (TableView - Loader - Progress - Download)
Animating a Path Drawing (CGPath - CAShapeLayer - Bezier - Animation) Create Animations With SpriteKit. Protocol-Oriented State Machine for Layout Constraints (Auto-Layout) Animations with Auto-Layout. UIViewPropertyAnimator (Animation) Make iOS Animations Feel Right (Velocity - Deceleration) UIFieldBehavior (Gravity - Snap - Physics - Drag - PIP - UIKit Dynamics) UIKit Dynamics (Snap - Pan - Gesture - Gravity) UIDynamics (Gravity - Collision - Path - Grab - Pan - Game) Gestures in Fluid Interfaces (Projection - Velocity - Deceleration) Animations as Assets: Core Animation Archives. Optimizing Images (UIImage - Performance - Thumbnail - Downscaling - Downsampling - Tips) Image Resizing Techniques (UIImage - Resize - Drawing)
UIGraphicsImageRenderer (Drawing) Generics And Descriptors To Standardise Images (Placeholder - UIImage - ImageDescriptor - Style) Icon for File with UIKit (UIImage) Web API Client (Network - Async Await - Actor) Certificate Pinning in iOS (Security - SSL - TLS - Network) Handling Expired OAuth Tokens (Refresh - Authentication) Background Transfer (Upload - Network) Detect Internet Access (Connectivity - Reachability - NWPathMonitor - Captive Portal) Prefetch Table View Data (UITableViewDataSource - Prefetching) Cache Efficient Functions. Ultimate Guide to JSON Parsing (Codable) DynamicMemberLookup (DynamicCallable - Parsing - JSON) Bad Input With Decodable (JSON - Parsing - Debug) Serialization Of Enum With Associated Type (Codable) Simplify UserDefaults (Preferences - Typed - Star) Type-Safe UserDefaults (Preferences - Typed) UserDefaults Protocol (Preferences - Typed) Test Push Notifications (Simulator - Device) Background Task Scheduler (Refresh) Rich Notifications With Custom Input UI (Push - Extension)
Push Notifications With CloudKit. Debug From Push Notification Tap (Xcode) In-App Purchase Test Process (IAP - Problems - Testing - Sandbox) Combine framework in action (Reactive - Publisher - Binding) Debouncing In Background (GCD) DispatchQueues (GCD - Thread - Queue - Background) Dispatch On The Server (GCD - Semaphore) Data Flow With Channels (Notification - Observer) Swift Command Line APIs (Script - Tool) The FaceID/TouchID Missing Step (Security - Biometrics - Authentication) Sign In With Apple Technical Details (Authentication - User - JWT)
Sign In With Apple Integration (Authentication) Error Protocols (LocalizedError - RecoverableError - CustomNSError - NSError) Uniquely Identify iOS Device (DeviceCheck - Server - Unique Identifier - Tracking) Password / Security Code AutoFill And Automatic Strong Password (Associated Domain) Access Control Management (User - Group - Role - Policy - Rights) Composite Validators (Form - Validation) Strongly Typed Identifiers. Stop Filtering (Collection - Enumerate - Tips) Searching For Objects By Type (Tips - Lazy)