Skip to main content
Journey Uncommon Logo
JourneyUncommon

Swift Interview Questions (549 to practise)

Swift is Apple's language for iOS and macOS. Reference-counting behaviour and value semantics drive most of its gotchas.

Retain cycles and capture lists, struct versus class copying, optionals and forced unwraps, protocol witness dispatch, and actor isolation in structured concurrency.

Total questions
549
Easy
60
Medium
245
Hard
244

Where it shows up: iOS, iPadOS, macOS, watchOS engineering, and server-side Swift at a handful of companies.

Sample Swift questions

Twenty real Swift questions from the library, code snippet included. Nothing here is paraphrased for search engines. It is the same text a signed-in user sees.

hardstatic vs dynamic witness dispatch

Given the protocol and extension below, what does this program print, and what governs each line's dispatch?

protocol Greeter {
    func hello() -> String          // a protocol requirement
}
extension Greeter {
    func hello() -> String { "default hello" }
    func bye()   -> String { "default bye"   }  // NOT a requirement
}
struct G: Greeter {
    func hello() -> String { "G hello" }
    func bye()   -> String { "G bye"   }
}
let g: Greeter = G()
print(g.hello())
print(g.bye())
Read the full question →
mediumprotocol-oriented programming

Given a protocol with a default method implementation in an extension AND a conforming type that provides its own implementation, what determines which version runs when the value is held in a variable typed as the protocol (existential)?

protocol Greeter {
    func hello()
}
extension Greeter {
    func hello() { print("protocol") }
    func bonus() { print("protocol bonus") }
}
struct Bob: Greeter {
    func hello() { print("Bob") }
    func bonus() { print("Bob bonus") }
}
let g: Greeter = Bob()
g.hello()
g.bonus()
Read the full question →
mediumresult builders

What does this code print, demonstrating how `buildOptional`/`buildEither` interact with control flow in a result builder?

@resultBuilder
enum StringBuilder {
    static func buildBlock(_ parts: String...) -> String { parts.joined() }
    static func buildEither(first: String) -> String { first }
    static func buildEither(second: String) -> String { second }
}
func make(@StringBuilder _ b: () -> String) -> String { b() }
let flag = false
print(make {
    "a"
    if flag { "b" } else { "c" }
})
Read the full question →
Sign in to answer

Everything above is free to read. Answering needs a free account.

We keep the correct answer, the explanation and the scoring behind sign-in so the platform stays honest, which is why the answer options and the worked explanation for every Swift question stay behind a free account. Signing in is free and takes a few seconds.

Swift topics covered

51 distinct Swift topics are tagged across the library. These are the real topic labels stored on the questions, not a hand-written list.

  • weak side tables (22)
  • associated types (21)
  • actors and actor isolation (20)
  • result builders (19)
  • existential containers (19)
  • retain cycles and capture lists (19)
  • escaping vs non-escaping closures (18)
  • generics and constraints (18)
  • structured concurrency task trees (17)
  • protocol-oriented programming (17)
  • property wrappers (17)
  • value witness tables (16)
  • phantom types (15)
  • unsafeBitCast and pointers (15)
  • custom operators (14)
  • weak vs unowned mechanics (13)
  • ARC internals retain release (13)
  • copy-on-write internals (13)
  • protocol witness tables (13)
  • ownership borrowing consuming (13)
  • custom error types (13)
  • Sendable and data-race safety (13)
  • weak self in closures (12)
  • opaque return types (11)
  • inlinable cross-module (11)
  • memory layout and alignment (10)
  • autoclosure (10)
  • KeyPath expressions (10)
  • async await runtime model (10)
  • structs vs classes (9)
  • static vs dynamic witness dispatch (9)
  • Codable custom keys (9)
  • type erasure (9)
  • metatype and runtime metadata (9)
  • whole-module optimization (8)
  • generic where clauses (7)
  • if let and guard let (6)
  • conditional conformance (6)
  • protocols basic conformance (6)
  • nil coalescing (5)
  • optionals and unwrapping (5)
  • enums with associated values (4)
  • defer (4)
  • arrays dictionaries sets (4)
  • access control (4)
  • closures and trailing closures (4)
  • optional chaining (3)
  • map filter reduce (2)
  • extensions simple (2)
  • do try catch (1)
  • tuples and pattern matching (1)

Search and filter every Swift question

Difficulty