Xcode 9 build issue with Date vs NSDate for NSManagedObject

穿精又带淫゛_ 提交于 2019-12-04 04:57:57

Let me answer this myself. These are my observations (so far) and potential solution.

This issue seems RANDOM. Suddenly, the issue has disappeared and codegen has finally settled on Date on both simulator and device.

However, I applied macro based solution (and now no longer needed) to solve it -

// Workaround for Xcode 9 bug. The autogenerated code for 'Date' type attribute is NSDate vs Date based on device vs simualtor.

// This macro condition should be removed once an Xcode update fixes this issue
#if (arch(i386) || arch(x86_64))    // Simulator
    requiredDate <- (map["requiredDate"], NSDateTransform())    // milliseconds to NSDate
#else   // Device
    requiredDate <- (map["requiredDate"], DateTransform())    // milliseconds to Date
#endif

PS: I remember I tested it working at least on iPhone SE Simulator, iPhone 7 device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!