hope this fix your issue Something does not conform to NSObject. Swift 4 automatically infers constraints for the generic parameter U used in your flatMap function by looking at all parameters which include U. U is used as a generic parameter to Wrapper which requires U: NSObject. Something is not a subclass of NSObject.
Initializing a Struct in Swift Error: Generic parameter could not be inferred
may help you . For a generic type, the generic parameter is actually considered to be part of the type. So the type of your struct isn't MyStruct, it's MyStruct (or whatever generic type you use. Therefore, you can't just declare the type by itself if there's not any information for the compiler to use to infer the actual type. Instead, you have to include the generic type in your declaration: var myStruct: MyStruct?
Generic parameter 'A' could not be inferred (Swift 4, Bond and ReactiveKit frameworks migrating from Swift 2)