#swift
29 posts tagged swift. All posts
Publishing a Swift package: SwiftPM, Git tags and the Swift Package IndexCreate a Swift package with SwiftPM, tag a semantic version, push it to a public Git repository, and list it on the Swift Package Index so others can depend on it.
Swift closures: syntax, capturing values, escaping and autoclosuresHow Swift closures work: the short syntax forms, trailing closures, how values are captured, @escaping, retain cycles with [weak self], and @autoclosure.
Access control in Swift: private, fileprivate, internal, package, public and openSwift's six access levels (private, fileprivate, internal, package, public, open), what each one allows, and the defaults and rules that trip people up.
Swift memory management: ARC, reference cycles and exclusive accessHow Automatic Reference Counting frees Swift class instances, how to break reference cycles with weak and unowned, and what exclusive access and actors protect against.
Using Alamofire, RxSwift and SwiftyJSON in a Swift projectHow to add Alamofire, RxSwift and SwiftyJSON with Swift Package Manager, with a working example of each and when Apple's built-in APIs are the better choice.
Type casting in Swift: is, as, as? and as!How Swift's is, as, as? and as! operators work: upcasting, conditional and forced downcasting, casting in switch statements, and casting from Any and to protocols.
Mixing Swift and Objective-C: bridging headers and the generated Swift headerHow to call Objective-C from Swift with a bridging header, call Swift from Objective-C through the generated -Swift.h header, and how types bridge.
Creating, testing and publishing a Swift package with SwiftPMCreate a Swift library with swift package init, understand the Package.swift manifest, add a dependency, build and test it, and publish versions with Git tags.
Swift concurrency basics: async/await, actors, task groups and cancellationSwift concurrency with working examples of async/await, actors, task groups, and cancellation, including a timeout helper and common gotchas.
Swift package conventions: layout, access control, tests and versioningPractical conventions for Swift packages: naming, layout, access control including package, DocC comments, tests, semantic versioning and a clean Package.swift.
Swift standard library basics: numbers, strings, collections and algorithmsA tour of Swift's standard library: integer and floating-point types, String and Character, Array, Set and Dictionary, and sorted, filter, map and reduce.
Swift for mobile apps: strengths, drawbacks and when to pick something elseThe practical pros and cons of Swift for mobile development: safety, Apple tooling, Objective-C interop, Android support, and language churn.
Swift enums: cases, associated values, raw values, and switchHow Swift enums work, covering basic cases, associated values, raw values, switch pattern matching, CaseIterable, and adding methods to an enum.
Where Swift is heading: concurrency, server-side Swift and new platformsWhere Swift is heading beyond iOS: compile-time data-race safety, server-side frameworks, Linux, Windows, Android and WebAssembly SDKs, and what happened to Swift for TensorFlow.
Contributing to an open-source Swift package: fork, test and open a pull requestFind a Swift package to work on, fork and clone it, build and test with SwiftPM or Xcode, and open a pull request that maintainers can review quickly.
Unit testing in Swift with XCTest and Swift TestingSet up a test target in Xcode, write unit tests with XCTest assertions, run them, and see the same tests written with the newer Swift Testing framework.
Building a first iOS app in Xcode with Swift and storyboardsCreate an iOS app project in Xcode, find your way around the workspace, connect a storyboard button and label to Swift code, then run and debug it.
Swift error handling: throws, do-catch, try?, typed throws and rethrowsHow Swift error handling works: defining Error types, throwing and propagating errors, do-catch with patterns, try? and try!, typed throws, rethrows and defer.
Calling C++ from Swift: native interop and Objective-C++ wrappersHow to use C++ code from Swift: direct C++ interoperability since Swift 5.9 with SwiftPM or Xcode, and the older Objective-C++ wrapper approach.
Swift performance tips: build settings, dispatch, copy-on-write and inliningSwift performance tips that hold up: build with -O and whole-module optimization, cut dynamic dispatch, use copy-on-write and inout well, and measure first.
Functional programming in Swift with closures, map/filter/reduce, and value typesFunctional programming in Swift with closures, map/filter/reduce, function types, value-type immutability, pattern matching, and recursion, with runnable examples.
Swift generics: generic functions, generic types and constraintsHow to write generic functions and types in Swift, constrain them with protocols and where clauses, and what generics cost at runtime.
Swift extensions: adding methods, properties and protocol conformances to existing typesHow Swift extensions add methods, computed properties, initializers and protocol conformances to existing types, plus what they can't do.
Swift Package Manager basics: creating a package and managing dependenciesCreate a Swift package from the command line, add a dependency such as Alamofire to Package.swift, and update, pin or remove dependencies with SwiftPM.
Debugging Swift in Xcode: breakpoints, LLDB, logging and sanitizersHow to debug Swift code in Xcode with breakpoints, LLDB's p, po and v commands, print and Logger output, and the Address and Thread Sanitizers.
Swift basics: variables, types, control flow and functionsSwift basics for newcomers: let and var, type inference, the core value types, optionals, if, switch, loops and functions with argument labels.
Swift operators: arithmetic, bitwise, ranges and custom operatorsSwift's arithmetic, comparison, logical, bitwise, range and assignment operators, the overflow and nil-coalescing operators, and how to define a custom operator.
Swift optionals: if let, guard let, optional chaining and ??How Swift optionals represent missing values, and how to unwrap them safely with if let, guard let, optional chaining, the ?? operator and map.
Swift protocols: requirements, extensions, associated types and compositionHow to define and adopt Swift protocols, add default implementations with extensions, use associated types, inheritance and composition, and choose between some and any.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)