Swinject / SwinjectAutoregistration

Swinject extension to automatically register your services
MIT License
249 stars 45 forks source link

Resolve failure when building from Xcode 16 to a device with OS17. #92

Open s0ta91 opened 2 weeks ago

s0ta91 commented 2 weeks ago

This might just be a compiler issue, not really sure what's going on here, but I'm logging it so it can be referenced.

When building to a device with OS17.x from Xcode 16, I have the following crash in CheckResolver.swift line 63 in this function:

func checkResolved<Service, A, B, C, D>(initializer: ((A, B, C, D)) -> Service, services a: A?, _ b: B?, _ c: C?, _ d: D?){
   let unresolved = ( [a, b, c, d] as [Any?] ).filter { $0 == nil }
   if unresolved.count > 0 {
       let errorMessage = resolutionErrors(forInitializer: initializer).map { "\($0.message)\n" }.joined()
       fatalError("SwinjectAutoregistration: Resolution failed.\n\(errorMessage)Unresolved service: \(unresolvedService(a, b, c, d)!)\nInitializer: (\(A.self), \(B.self), \(C.self), \(D.self)) -> \(Service.self)")
   }
}

unresolved.count is equals to 1 Here's the different results I have for OS17.x and OS18

Build from Xcode 16 to iOS 17.5 => Crash

po ( [a, b, c, d] as [Any?] ) ▿ 4 elements

  • 0 : nil ▿ 1 : Optional ▿ some : <DefaultPassRepository: 0x106305a80> ▿ 2 : Optional ▿ some : <DefaultProfileRepository: 0x10800c800> ▿ 3 : Optional ▿ some : <DefaultEnvironmentRepository: 0x108824000>

unresolved: ▿ 1 element

  • 0 : nil

Build from Xcode 16 to iOS 18 => Ok

po ( [a, b, c, d] as [Any?] ) ▿ 4 elements

  • 0 : Optional ▿ some : nil ▿ 1 : Optional ▿ some : <DefaultPassRepository: 0x106305a80> ▿ 2 : Optional ▿ some : <DefaultProfileRepository: 0x10800c800> ▿ 3 : Optional ▿ some : <DefaultEnvironmentRepository: 0x108824000>

unresolved: ▿ 0 element

bradfol commented 1 week ago

Could you also share a code snippet for the registration that reproduces the crash?