Closed ketzusaka closed 6 years ago
Thanks for pointing this out @ketzusaka. That's pretty strange that it only happens on NSMutableAttributedString
🤔. I may file a bug with Swift, but it would probably be good to change the parameter labels either way so it doesn't confuse the compiler. I'm down for the swiftyAttributes
name change. Do you want to make the PR? Otherwise I can take care of it :)
Yeah, I’ll open one once I get to the office :)
Thanks!
Fixed and released in v5.0.0 :)
I did the test in my FrameWork.
When I just add convenience init
func in extension NSAttributedString
, Xcode 10 compilation no error, The code is:
extension NSAttributedString {
public convenience init(string str: String, attributes: [String]) {
self.init(string: str, attributes: nil)
}
}
But, when also add new func and parameter type is NSAttributedString.EnumerationOptions
, Xcode 10 compilation error, The code is:
extension NSAttributedString {
public convenience init(string str: String, attributes: [String]) {
self.init(string: str, attributes: nil)
}
func test(options: NSAttributedString.EnumerationOptions) {
}
}
I delete the options: NSAttributedString.EnumerationOptions
, or use string
Int
or other type instead of NSAttributedString.EnumerationOptions
, Xcode 10 compilation success.
@wigl I don't think this pertains to the issue above -- but what's the compilation error you're getting? I can't reproduce it on Xcode 10.
I forgot to tell you that the above code is inside the framework.
When the above extension is in the main project, there is no problem. @eddiekaiger
We've had this issue in our project preventing Xcode 10 compilation since the release. The error is:
The usage was pretty basic, something like so:
After digging into it I discovered this doesn't happen unless we're importing SwiftyAttributes. If you duplicate the
testInit_withStringAndAttributes
test method, but replace theNSAttributedString
s withNSMutableAttributedString
s you'll get the same error when running the tests.Attempting to use the convenience initializer on a
NSMutableAttributedString
results in the following error:Taking out the convenience initializer on
NSAttributedString
, or giving the attributes parameter a different name resolves the issue.It's likely that this is a bug with Swift. I'm not sure if you'd rather file a bug with them and see what happens, or resolve the issue within the library now. Changing the attributes parameter would be a breaking change and be cause for a major bump.
Let me know if you're going to take action on this at the library level if ya can, as it is preventing us from building on XC10 :)
Here's the diff w/ the fix and test that I experimented with: