I'm working on a category for NSDate to add methods such as [date isEquivalentToToday]. I had the category working great and then moved into a custom cocoapod. As soon as I did that it stopped working. It turns out it's because [NSCalendar currentCalendar] and [calendar components:fromDate] don't seem to work at all when they're called within a cocoapod. Can anyone explain why that is and if there's a way to make this work?
If you need some code to look at this is what I was doing at the top of isEquivalentToToday:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:[NSDate date]];
NSDate *today = [calendar dateFromComponents:components];
When this code is included in the app itself, it returns an NSDate representing today with a time component of zero.
As soon as I move this same code into a cocoapod and have my app call it, the first two lines return nil.
I tried passing a valid NSCalendar object into the cocoapod, but then the components:fromDate: method still returns nil.
I'd rather not just pull this code back into my project since it's nice having it split out into a reusable pod. But right now I don't see any other way to get this working again. Anyone else run into this before?
After spending more time looking into it, it looks like the code is actually functioning correctly, but the debugger isn't reporting the correct information when I step into the pod or stop on a breakpoint inside it.
I was able to fix the issue by moving this code back into my main project.