swift Errors
42 error patterns
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
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
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
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
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
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
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
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
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
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
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
Core Data unique constraint conflict
CoreData.*NSConstraintConflict.*conflicting.*values.*constraint
- •Set merge policy: context.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
- •Check for existing records before inserting
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
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
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
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
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
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
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
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'
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
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
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 }
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
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+)
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
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
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
Auto Layout constraint conflict
Unable to simultaneously satisfy constraints
- •Lower the priority of one conflicting constraint
- •Remove the redundant constraint causing the conflict
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
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
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
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)
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
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
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
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
Ambiguous function or property reference
Ambiguous use of
- •Add explicit type annotation to disambiguate
- •Use full module-qualified name: ModuleName.functionName
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
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()
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
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