Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ISO8601DateFormatter' is ambiguous for type lookup in this context #76

Open
marcelofabri opened this issue Oct 5, 2016 · 5 comments
Open

Comments

@marcelofabri
Copy link

I'm updating my project to use Swift 3.0 and on 3.0 , NSISO8601DateFormatter becomes just ISO8601DateFormatter, which conflicts with this library.

Unfortunately, using ISO8601DateFormatter.ISO8601DateFormatter doesn't help either (seems to be a compiler bug: https://bugs.swift.org/browse/SR-1386).

An easy way to fix this would be using module_name in the Podspec (https://guides.cocoapods.org/syntax/podspec.html#module_name) to change the module to something else, allowing SomeModule.ISO8601DateFormatter.

@johnboyer
Copy link

I’d like to suggest that perhaps this project should be a changed to category in Objective-C and an extension in Swift. We’ve unit tested Apple’s new NSISO8601DateFormatter against this library and have determined that theNSISO8601DateFormatter meets our needs. Therefore, we’re planning replace to ISO8601DateFormatter with the NSISO8601DateFormatter class when we upgrade our codebase to iOS 10. We also plan to use Apple’s ISO8601DateFormatter in new projects using Swift 3.0.

@heymansmile
Copy link

heymansmile commented Oct 21, 2016

@marcelofabri There is the easy fix (XCode 8, Swift 3.0):

  1. Exclude import declaration: import Foundation
  2. Import class: import class ISO8601DateFormatter.ISO8601DateFormatter
  3. The class is available simple as ISO8601DateFormatter and the apple's one as Foundation.ISO8601DateFormatter

@marcelofabri
Copy link
Author

marcelofabri commented Oct 21, 2016

I needed Foundation on that file, so I've come up with another workaround:

// Fixes 'ISO8601DateFormatter' is ambiguous for type lookup in this context
// see http://stackoverflow.com/questions/36991735/how-to-reference-a-type-in-a-module-that-has-a-type-with-the-same-name-as-the-mo

import class ISO8601DateFormatter.ISO8601DateFormatter

typealias SomePrefixISO8601DateFormatter = ISO8601DateFormatter

Then I just used SomePrefixISO8601DateFormatter instead of ISO8601DateFormatter on other files

@rz-robsn
Copy link

May I suggest to simply add a 3-letter prefix to the ISO8601DateFormatter class ? This would be consistent with Apple's Objective-C Naming Convention.

This library would have never had this issue if it followed the 3-letter prefix rule, which was introduced to specifically to avoid name clashes like this one.

@johnboyer
Copy link

If you’re using iOS 10, I’d recommend migrating to NSISO8601DateFormatter and ISO8601DateFormatter in Objective-C and Swift, respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants