kevinlawler / NSDate-TimeAgo

A "time ago", "time since", "relative date", or "fuzzy date" category for NSDate and iOS, Objective-C, Cocoa Touch, iPhone, iPad
ISC License
1.75k stars 322 forks source link

I cannot import pod to Swift project #83

Closed moyoteg closed 7 years ago

moyoteg commented 9 years ago

I cannot import pod to Swift project for some reason, when trying to bridge it all I get is a "not found" error. What am I doing wrong? Thanks!!

smasry commented 9 years ago

Works fine for me.
#import "NSDate+TimeAgo.h"

davepatterson commented 9 years ago

Simply adding import NSDate_TimeAgo to the .swift file you intend to use it in will work. There's no need to add #import "NSDate+TimeAgo.h" to your bridging header as NSDate+TimeAgo comes with an extension for swift.

mohamede1945 commented 7 years ago

Actually, when you import NSDate_TimeAgo You will be using the Objective-c API not the swift API, see the podspec here only adds '*.{h,m}' objective-c files not swift files. So, to fix it we need to make it '*.{h,m,swift}'.

mohamede1945 commented 7 years ago

Here is a screenshot of what has been added from the cocoapod.

screen shot 2017-05-06 at 11 17 21 pm

There is no swift files at all.

dimohamdy commented 7 years ago

@mohamede1945 podspec changed but there isn't any swift files How you fix this?

mohamede1945 commented 7 years ago

You can use objective-c classes just bridge your swift Date to NSDate. Here is an example

import NSDate_TimeAgo

extension Date {
    func bookmarkTimeAgo() -> String? {
        return (self as NSDate).timeAgo(withLimit: 60 * 60 * 24 * 7, dateFormat: .full, andTimeFormat: .none)
    }
}
mohamede1945 commented 7 years ago

Also, they updated the podspec, but they didn't release a new version on cocoapods.

dimohamdy commented 6 years ago

@mohamede1945 thanks