swift Errors

42 error patterns

swift3 fixes

SwiftUI preview crash

SwiftUI.*Previews.*crashed.*The preview process was terminated

  • Clean build folder: Cmd+Shift+K, then rebuild
  • Check for force-unwrapped optionals or fatalError in preview code
swift3 fixes

Swift Combine publisher cancelled unexpectedly

Swift.*Combine.*Cancelled.*sink received completion.*failure

  • Store the AnyCancellable in a Set to prevent premature deallocation
  • Use .store(in: &cancellables) to retain the subscription
swift3 fixes

Core Data model incompatible with persistent store

CoreData.*NSInternalInconsistencyException.*model.*incompatible.*store

  • Add a migration mapping model for schema changes
  • Use lightweight migration: addPersistentStore with NSMigratePersistentStoresAutomaticallyOption
swift3 fixes

App Store Connect binary contains simulator architecture

TestFlight.*ERROR ITMS-90.*Invalid Binary.*contains.*simulator architecture

  • Ensure build is for 'Any iOS Device', not simulator
  • Strip simulator architectures from frameworks in build phase
swift3 fixes

SwiftUI AttributeGraph cycle causing infinite loop

SwiftUI.*AttributeGraph.*cycle detected

  • Remove circular dependency between @State and body computation
  • Don't modify state during view body evaluation
swift3 fixes

SwiftUI state update from background thread

Swift.*Publishing changes from background threads is not allowed

  • Wrap state update in DispatchQueue.main.async or MainActor
  • Add @MainActor annotation to the ObservableObject class
swift3 fixes

Core Data merge conflict between contexts

Core Data.*NSMergeConflict.*for NSManagedObject

  • Set mergePolicy on the managed object context: NSMergeByPropertyObjectTrumpMergePolicy
  • Use NSPersistentContainer's automatic merge configuration
swift3 fixes

App Store Connect UIWebView deprecation rejection

App Store Connect.*ITMS-90809.*Deprecated API Usage.*UIWebView

  • Replace all UIWebView usage with WKWebView
  • Check third-party libraries for UIWebView references
swift3 fixes

SwiftUI state modification during view update

SwiftUI.*Modifying state during view update.*this will cause undefined behavior

  • Defer state changes to .onAppear{} or .task{}
  • Use DispatchQueue.main.async to break the update cycle
swift3 fixes

SwiftUI complex expression type-check timeout

SwiftUI.*The compiler is unable to type-check this expression in reasonable time

  • Break complex view body into smaller extracted subviews
  • Add explicit type annotations to ambiguous expressions
swift3 fixes

Swift Combine subscriber received duplicate subscription

Swift.*Combine.*receive.*was already called on this subscriber

  • Ensure each subscriber only subscribes once
  • Cancel previous subscription before creating new one
swift3 fixes

Core Data unique constraint conflict

CoreData.*NSConstraintConflict.*conflicting.*values.*constraint

  • Set merge policy: context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
  • Check for existing records before inserting
swift3 fixes

TestFlight missing Swift module in archive

TestFlight.*ITMS-90426.*Invalid Swift Support.*missing.*swiftmodule

  • Set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES in build settings
  • Ensure the framework includes the swiftmodule directory
swift3 fixes

SwiftUI NavigationPath type not Codable

SwiftUI.*NavigationPath.*type mismatch.*cannot navigate.*codable

  • Ensure all types pushed to NavigationPath conform to Hashable and Codable
  • Use .navigationDestination(for: Type.self) for each pushable type
swift3 fixes

Swift actor isolation violation

Swift.*actor.*isolated.*cannot be referenced from.*nonisolated.*context

  • Mark the calling function as async and use await for actor calls
  • Use nonisolated keyword if the property doesn't need isolation
swift3 fixes

Core Data iCloud sync store not reachable

Core Data.*coordinator.*persistent stores.*not reachable.*iCloud

  • Check CloudKit container is properly configured in capabilities
  • Verify iCloud account is signed in on device
swift3 fixes

App Store Connect bitcode configuration mismatch

App Store Connect.*ITMS-90725.*SDK.*does not contain.*bitcode

  • Apple no longer requires bitcode (Xcode 14+) - set ENABLE_BITCODE=NO
  • Rebuild all libraries without bitcode
swift3 fixes

SwiftUI environment object not provided

SwiftUI.*Reference to invalid.*environment.*object.*ObservableObject

  • Pass .environmentObject(myObject) higher in the view hierarchy
  • Ensure the object type matches: @EnvironmentObject var obj: MyType
swift3 fixes

Swift non-Sendable type in concurrent context

Swift.*Sendable.*capture of.*non-sendable type.*in.*@Sendable closure

  • Make the type conform to Sendable protocol
  • Use @unchecked Sendable if you can guarantee thread safety
swift3 fixes

Core Data entity class casting failure

Core Data.*Could not cast value of type.*NSManagedObject.*to

  • Set Class name in .xcdatamodeld entity inspector
  • Ensure Module is set to 'Current Product Module'
swift3 fixes

App Store Connect nested frameworks not allowed

App Store Connect.*ITMS-90190.*invalid bundle.*contains disallowed file 'Frameworks'

  • Don't embed frameworks inside other frameworks
  • Use static libraries/XCFrameworks instead of dynamic nested frameworks
swift3 fixes

SwiftUI EXC_BAD_ACCESS from deallocated ObservableObject

SwiftUI.*Thread.*Crash.*EXC_BAD_ACCESS.*ObservableObject

  • Hold a strong reference to the ObservableObject in the view hierarchy
  • Use @StateObject (not @ObservedObject) for objects the view owns
swift3 fixes

Force unwrap of nil Optional value

unexpectedly found nil while (unwrapping|implicitly unwrapping) an Optional

  • Use optional binding: if let value = optional { ... }
  • Use guard let for early exit: guard let value = optional else { return }
swift3 fixes

Fatal nil unwrap at runtime

Fatal error: Unexpectedly found nil while unwrapping an Optional value

  • Replace force unwrap (!) with optional chaining (?.) or if-let binding
  • Check IBOutlet connections — disconnected outlets are nil at runtime
swift3 fixes

UI update called from background thread

UIKit.*from background thread

  • Wrap UI code in DispatchQueue.main.async { ... }
  • Use @MainActor attribute on functions that update UI (Swift 5.5+)
swift3 fixes

Codable decoding type mismatch

typeMismatch.*expected to decode.*but found

  • Check JSON key types match your model's property types
  • Use String(describing:) and manual decoding for flexible types
swift3 fixes

Codable key not found in JSON

keyNotFound.*No value associated with key

  • Make the property optional: var field: Type?
  • Provide a default in custom init(from:) using decodeIfPresent
swift3 fixes

Auto Layout modified from background thread

Modifications to the layout engine must not be performed from a background thread

  • Dispatch constraint changes to main queue
  • Use @MainActor for async functions that modify layout
swift4 fixes

Auto Layout constraint conflict

Unable to simultaneously satisfy constraints

  • Lower the priority of one conflicting constraint
  • Remove the redundant constraint causing the conflict
swift3 fixes

Memory leak from retain cycle

deinit.*never called|Closure capturing.*strong reference

  • Use [weak self] in closures that are stored by the object
  • Use [unowned self] if self is guaranteed to outlive the closure
swift3 fixes

Bad memory access (dangling pointer or zombie)

Thread \d+: EXC_BAD_ACCESS

  • Enable Zombie Objects in scheme diagnostics to identify the freed object
  • Check for use-after-free with unowned references — use weak instead
swift3 fixes

Type conversion error in function argument

Cannot convert value of type.*to expected argument type

  • Add explicit type cast or conversion: String(intValue), Int(stringValue)
  • Check if you need to unwrap an Optional before passing
swift3 fixes

Corrupted or invalid JSON data

dataCorrupted.*Invalid.*JSON

  • Validate JSON format with a linter before decoding
  • Print the raw data as string to inspect: String(data: data, encoding: .utf8)
swift3 fixes

Swift concurrency data race warning

Sending.*risks causing data races

  • Mark the type as @Sendable or make it conform to Sendable
  • Use actors to isolate mutable state
swift3 fixes

Escaping closure captures mutating self in struct

Escaping closure captures mutating 'self'

  • Change the struct to a class if it needs reference semantics
  • Capture specific properties instead of self
swift3 fixes

Swift type checker timeout on complex expression

The compiler is unable to type-check this expression in reasonable time

  • Break the expression into smaller intermediate variables with explicit types
  • Add explicit type annotations to closures
swift3 fixes

KVC non-compliant key (storyboard outlet mismatch)

this class is not key value coding-compliant for the key

  • Check Interface Builder connections — remove stale outlet connections
  • Ensure @IBOutlet property names match the storyboard references
swift3 fixes

Ambiguous function or property reference

Ambiguous use of

  • Add explicit type annotation to disambiguate
  • Use full module-qualified name: ModuleName.functionName
swift3 fixes

Protocol with Self/associated type used as concrete type

Protocol.*can only be used as a generic constraint.*Self or associated type

  • Use a generic constraint: func foo<T: Protocol>(val: T)
  • Use type erasure: AnyProtocol wrapper
swift3 fixes

Object deallocated immediately after creation

Instance will be immediately deallocated

  • Store the instance in a property to maintain a strong reference
  • Assign to a variable instead of discarding: let manager = Manager()
swift3 fixes

Symbol not found in current scope

Cannot find.*in scope

  • Import the module that defines the symbol
  • Check target membership — the file may not be in the current target
swift3 fixes

Main actor isolation violation

Main actor-isolated.*cannot be (called|accessed) from

  • Mark the calling function with @MainActor
  • Use await MainActor.run { } to dispatch to main actor