Khoa Pham
Khoa Pham

Ohayo

Swift Discovery

Discover all the tech

Featured

My year in review 2020

Issue #715

I remember this time last year in December 2019, I spent almost every single bit of my free time on Puma because I want a Swift friendly version of fastlane that suits my need and leverages Swift 5 features.

Here’s my review of my …

How to generate XCTest test methods

Issue #576

Code

See Spek

Override testInvocations to specify test methods

https://developer.apple.com/documentation/xctest/xctestcase/1496271-testinvocations

Returns an array of invocations representing each test method in the test case.

Because …

How to use ObjC in Swift Package Manager

Issue #575

Create Objc target

Check runtime

Check for example _runtime(_ObjC) or os(macOS if you plan to use platform specific feature …

How to expression cast type in lldb in Swit

Issue #574

expr -l Swift -- import UIKit
expr -l Swift -- let $collectionView = unsafeBitCast(0x7fddd8180000, to: UICollectionView.self)
expr -l Swift -- $collectionView.safeAreaInsets

How to use Applications folder in macOS

Issue #573

There are 2 Applications folder

  • /System/Applications: contains Notes, Books, Calculator, …
  • /Applications: contains Safari, Xcode, Keynote, …

How to fix library not found with SPM and CocoaPods in Xcode

Issue #572

After migrating a few pods to use SPM, some libraries fail to load. This is because the workspace now uses both SPM and cocoapods

code signature in … not valid for use in process using Library Validation: mapped file has no Team ID …

How to make rotation in same direction in iOS

Issue #571

From CGFloat.pi / 2 to -CGFloat.pi / 2 + epsilon

How to get updated safeAreaInsets in iOS

Issue #570

Use viewSafeArea

@available(iOS 11.0, *)
override func viewSafeAreaInsetsDidChange() {
    super.viewSafeAreaInsetsDidChange()

    self.collectionView.reloadData()
}

Use …

How to disable implicit decoration view animation in UICollectionView

Issue #569

From documentation https://developer.apple.com/documentation/uikit/uicollectionviewlayout/1617726-initiallayoutattributesforappear

This method is called after the prepare(forCollectionViewUpdates:) method and before the …

How to make simple tracker via swizzling in Swift

Issue #568

Code

Swizzle viewDidAppear

import UIKit

var mapping: [String: (UIViewController) -> Void] = [:]
var hasSwizzled = false

public func track< …

How to make simple adapter for delegate and datasource for UICollectionView and UITableView

Issue #567

Code

Make open Adapter

import UIKit

public protocol AdapterDelegate: class {

  /// Apply model to view
  func configure(model: Any, view: UIView, indexPath: IndexPath)

  /// Handle …

How to make progress HUD in Swift

Issue #566

Code

Create a container that has blur effect

public class HUDContainer: UIVisualEffectView, AnimationAware {
    private let innerContentView: UIView & AnimationAware
    public let label = UILabel()
    public var …

How to specify year in date formatter in Swift

Issue #565

How to build static site using Publish

Issue #564

Code

Steps

Step 1: Create executable

swift package init --type executable

Step 2: Edit package

// swift-tools-version:5.1
// The …

How to use iTMSTransporter

Issue #563

Transporter app

The new Transporter app for macOS makes it easy to upload your binary to App Store Connect. To get started, download Transporter from the Mac App Store, and simply drag and …

How to use Timer and RunLoop in Swift

Issue #562

Run Timer in command line application

Timer.scheduledTimer(withTimeInterval: seconds, repeats: false, block: { _ in
    completion(.success(()))
})

RunLoop.current.run()

Read more …

How to use safeAreaInsets in iOS

Issue #561

Read more

How to send message from bot to Slack in Swift

Issue #560

Create a bot

Post message

After adding bot to …

How to parse xcrun simctl devices

Issue #559

public class GetDestinations {
    public init() {}

    public func getAvailable(workflow: Workflow) throws -> [Destination] {
        let processHandler = DefaultProcessHandler(filter: { $0.starts(with: "name=") })
        let …

How to parse xcrun instruments devices

Issue #558

public class GetDestinations {
    public init() {}

    public func getAvailable(workflow: Workflow) throws -> [Destination] {
        let processHandler = DefaultProcessHandler(filter: { $0.starts(with: "name=") })
        let …

How to use test environment variables with shared scheme in Xcode

Issue #557

Use ProcessInfo to access environment variables.

ProcessInfo().environment["username"]

Duplicate main shared scheme TestApp to TestAppWithCredentials, but don’t share this TestAppWithCredentials scheme

Khoa Pham

Hello, I’m Khoa

I’m a thinker and storyteller with a passion for exploring the intersection of creativity and technology

🧑‍💻 I love crafting high quality and useful apps
🔥 I love open source. My GitHub open source has 2.3k followers with packages that are integrated by 45k+ apps and over 3.4m+ downloads on CocoaPods.
✍️ I write here on my blog and on Medium, which has over 2.7k+ followers with tons of articles and 90k+ monthly views.
🖥 Follow me for sharings about Swift, SwiftUI, iOS and macOS development.
Hei