Khoa Pham
Khoa Pham

Ohayo

Swift Discovery

Discover all the tech

How to make simple networking client in Swift

Issue #222

For more mature networking, visit https://github.com/onmyway133/Miami

final class NetworkClient {
    let session: URLSession
    let baseUrl: URL

    init(session: URLSession = .shared, baseUrl: URL) {
        self.session = session …

How to ignore App Transport Security in iOS

Issue #221

Ignore a host

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>example.com</key>
        <dict>
            <key> …

How to run simple http server in Go

Issue #220

Handle url parameter

package main

import (
  "net/http"
  "log"
)

func handleGreeting(w http.ResponseWriter, r *http.Request) {
  messages, ok := r.URL.Query()["message"]
    
  if !ok || len(messages[0]) < 1 { …

How to use Stripe and Apple Pay in iOS

Issue #219

Show basic add card in iOS

import UIKit
import Stripe

final class MainController: UIViewController {

    func showPayment() {
        let addCardViewController = …

How to test PublishSubject in RxSwift

Issue #218

Use homemade Recorder

class …

How to fix not found zlib problem in macOS Mojave

Issue #217

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes

The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require …

How to use Sonarqube in Swift projects

Issue #216

Install Sonarqube

https://docs.sonarqube.org/latest/setup/get-started-2-minutes/

What is Personal team in Xcode

Issue #215

https://developer.apple.com/library/archive/qa/qa1915/_index.html

Xcode 7 and Xcode 8 allow you to select the free personal team provided with your Apple ID for signing your app. This team allows you to build apps for your personal use on …

How to map from Swift 5 Resul to RxSwift PublishSubject

Issue #214

extension Result {
    func to(subject: PublishSubject<Success>) {
        switch self {
        case .success(let value):
            subject.onNext(value)
        case .failure(let error):
            subject.onError(error) …

How to update NSMenuItem while NSMenu is showing in macOS

Issue #213

Use Runloop

timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { [weak self] _ in
    let date = Date()
    self?.updateStopItem(seconds: finishDate.timeIntervalSince1970 - date.timeIntervalSince1970)
}) …

How to use Timer in Swift

Issue #212

Pre iOS 10

func schedule() {
    DispatchQueue.main.async {
      self.timer = Timer.scheduledTimer(timeInterval: 20, target: self,
                                   selector: #selector(self.timerDidFire(timer:)), userInfo: nil, repeats: …

How to overload functions in Swift

Issue #211

Function

Functions in Swift are distinguishable by

  • parameter label
  • parameter type
  • return type

so that these are all valid, and works for subscript as well

struct A {

  // return type
  func get() -> String { return "" } …

Understanding AVFoundation and MediaPlayer frameworks in iOS

Issue #210

Depending on what features we want to achieve, we need to go with either AVFoundation or MediaPlayer framework. As someone who worked with many apps that involve media playback, here are some of my observations

MPMoviePlayerController vs …

How to handle reachability in iOS

Issue #209

Here are what I learn about reachability handling in iOS, aka checking for internet connection. Hope you will find it useful, too.

This post starts with techniques from Objective age, but many of the concepts still hold true

The naive way …

Dealing with CSS responsiveness in Wordpress

Issue #208

During the alpha test of LearnTalks, some of my friends reported that the screen is completely blank in the search page, and this happened in mobile only. This article is how I identify the problem and found a workaround for the issue, it …

How to build with xcodebuild and automatic code signing

Issue #207

Team ID

Error

Message: "xcodebuild: error: invalid option '-teamID'

Use =

xcodebuild teamID=T78DK947F3

Does not work 😢

DEVELOPMENT_TEAM

https://pewpewthespells.com/blog/migrating_code_signing.html

xcodebuild DEVELOPMENT_TEAM= …

How to launch app at start up in macOS

Issue #205

ServiceManagement framework

https://developer.apple.com/documentation/servicemanagement/1501557-smloginitemsetenabled

SMLoginItemSetEnabled

Enable a helper application located in the main application bundle’s “Contents/Library/LoginItems” …

How to fix mismatched deployment between app and test target in Xcode

Issue #204

  • My macOS app target has deployment target 10.12, but when running test, I get
Compiling for OS X 10.11, but module 'MyApp' has a minimum deployment target of OS X 10.12: …

How to notarize macOS app

Issue #203

New Notarization Requirements

https://developer.apple.com/news/?id=04102019a

With the public release of macOS 10.14.5, we require that all developers creating a Developer ID certificate for the first time notarize their apps, and that all …

How to resize image using imagemagick

Issue #202

mogrify -resize 1280x800 s2.png

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