Swifterswift: DateTools conflict

Created on 6 Jun 2017  路  3Comments  路  Source: SwifterSwift/SwifterSwift

SwifterSwift has conflict with DateTools

2017-06-06_01-06-58

Most helpful comment

I had the same issue with this library: https://github.com/andreamazz/AMPopTip because they use shadowOffset, shadowRadius .... on UIView elements. I solve it the following way:

        popTip.setValue(8, forKey: "cornerRadius")
        popTip.setValue(70, forKey: "shadowRadius")
        popTip.setValue(1, forKey: "shadowOpacity")
        popTip.setValue(UIColor(red: 0, green: 0, blue: 0, alpha: 1.0), forKey: "shadowColor")
        popTip.setValue(CGSize.zero, forKey: "shadowOffset")

Instead of accessing directly to the property.

All 3 comments

Hey @AYastrebov, thanks for logging this issue.

This is a limitation for the project as a library like SwifterSwift extends such a large number of data types that it is possible for them to conflict with extensions provided in other 3rd party libraries.

Especially when an extension is a commonly used solution to a problem or revolves around a similar domain.

Here are my suggestions for you:

  • Provide a more fine-grained control over your imports

For example, if you only need SwifterSwift extensions relating to a single class

import class SwifterSwift.UIColor

This will allow you to use SwifterSwift extensions for UIColor while excluding the other types.

Unfortunately, if you need to rely on Date extensions provided to you in both DateTools and SwifterSwift -- I do not think there is a reasonable solution.

You could try:

var someDate: SwifterSwift.Date = Date()

To see if this resolves some of the ambiguity around the property/method access, but this is not ideal nor something I have tested myself.

  • Your final solution is to just cut and paste the specific SwifterSwift extensions you need into your own codebase and resolve any naming conflicts that you need to.

Let me know if any of these solutions help and feel free to paste some code to see if we can both resolve this.

Hey @SD10
Thanks for quick response!

The easiest solution for me was just to take needed component from DateTools and integrate it directly to the project and remove the corresponding pod. So I suppose this can be closed. Thanks!

I had the same issue with this library: https://github.com/andreamazz/AMPopTip because they use shadowOffset, shadowRadius .... on UIView elements. I solve it the following way:

        popTip.setValue(8, forKey: "cornerRadius")
        popTip.setValue(70, forKey: "shadowRadius")
        popTip.setValue(1, forKey: "shadowOpacity")
        popTip.setValue(UIColor(red: 0, green: 0, blue: 0, alpha: 1.0), forKey: "shadowColor")
        popTip.setValue(CGSize.zero, forKey: "shadowOffset")

Instead of accessing directly to the property.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SD10 picture SD10  路  3Comments

LucianoPAlmeida picture LucianoPAlmeida  路  4Comments

pawurb picture pawurb  路  3Comments

omaralbeik picture omaralbeik  路  3Comments

omaralbeik picture omaralbeik  路  5Comments