Closed moyoteg closed 7 years ago
Works fine for me.
#import "NSDate+TimeAgo.h"
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.
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}'
.
Here is a screenshot of what has been added from the cocoapod.
There is no swift files at all.
@mohamede1945 podspec changed but there isn't any swift files How you fix this?
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)
}
}
Also, they updated the podspec, but they didn't release a new version on cocoapods.
@mohamede1945 thanks
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!!