Fixes for Swift 5.7 compiler#4823
Conversation
| *.ipa | ||
| *.dSYM.zip | ||
| *.dSYM | ||
| *.dia |
There was a problem hiding this comment.
These files get spewed out when compiling with the development toolchain so I added them to the ignore file.
| "revision": "6b24333510e9044cf4716a07bed65eeed6bc6393", | ||
| "version": "0.0.8" | ||
| "revision": "0a5bc04095a675662cf24757cc0640aa2204253b", | ||
| "version": "1.0.2" |
There was a problem hiding this comment.
Xcode updated these automatically and I think its a reasonable update as they were very outdated.
| entries.replaceSubrange(subrange, with: newElements) | ||
| notifyDataSetChanged() | ||
| } | ||
|
|
There was a problem hiding this comment.
This was the fix.
There was a problem hiding this comment.
what's the original issue here? It has been too long; sorry
I would like to get this merged asap, so bear with me my direct asking
There was a problem hiding this comment.
also - if we are compiling with old Swift, like 5.0 or 5.4, will this cause a regression? Not fulling understanding the issue
There was a problem hiding this comment.
My understanding of the original bug is that you've always needed replaceSubrange to conform to RangeReplaceableCollection but the compiler wasn't failing when it was missing until 5.7 fixed this issue. You'd need to compile with an older toolchain to be sure, I don't know how far back you want to support in terms of toolchain.
There was a problem hiding this comment.
basically we usually just support latest one; but given this issue is totally different between 5.6/5.7, I'm not wure what would happen in the field.
Would @avaialble(iOS 16) , (macOS, 13) or something similar solve it?
There was a problem hiding this comment.
I was trying to compile on Xcode beta3, howerver, it still throws
Type 'ChartDataSet' does not conform to protocol 'RangeReplaceableCollection'
Unavailable instance method 'replaceSubrange(_:with:)' was used to satisfy a requirement of protocol 'RangeReplaceableCollection'
which Xcode beta you are building?
| } | ||
|
|
||
| open func drawText(_ text: String, at point: CGPoint, anchor: CGPoint = CGPoint(x: 0.5, y: 0.5), angleRadians: CGFloat, attributes: [NSAttributedString.Key : Any]?) | ||
| public func drawText(_ text: String, at point: CGPoint, anchor: CGPoint = CGPoint(x: 0.5, y: 0.5), angleRadians: CGFloat, attributes: [NSAttributedString.Key : Any]?) |
There was a problem hiding this comment.
Went with the Xcode suggested fix here.
There was a problem hiding this comment.
what's the error message for open?
There was a problem hiding this comment.
I can't remember now, sorry.
There was a problem hiding this comment.
what's the error message for open?
quoted from this issue:
Build error around CandleStickChartRenderer's and RadarChartRenderer's drawData(context: CGContext) where the IndexingIterator are not equivalent. Raw message:
error build: Referencing instance method 'makeIterator()' on 'Collection' requires the types 'IndexingIterator' and 'IndexingIterator' be equivalent
There was a problem hiding this comment.
The quoted issue doesn't seem to be relevant here. For me, the issue
CandleStickChartRenderer.swift:41:59: error build: Referencing instance method 'makeIterator()' on 'Collection' requires the types 'IndexingIterator<ChartData>' and 'IndexingIterator<CandleChartData>' be equivalent
still was still there with this PR's branch. It was gone only after I made the required conversions: radarData as ChartData in RadarChartRenderer:55 and candleData as ChartData at CandleStickChartRenderer:41
I am using Xcode 14 beta 3
There was a problem hiding this comment.
The open vs public is not an error, but a build warning:
Non-'@objc' instance method in extensions cannot be overridden; use 'public' instead
There was a problem hiding this comment.
The quoted issue doesn't seem to be relevant here. For me, the issue
CandleStickChartRenderer.swift:41:59: error build: Referencing instance method 'makeIterator()' on 'Collection' requires the types 'IndexingIterator<ChartData>' and 'IndexingIterator<CandleChartData>' be equivalentstill was still there with this PR's branch. It was gone only after I made the required conversions:
radarData as ChartDatain RadarChartRenderer:55 andcandleData as ChartDataat CandleStickChartRenderer:41I am using Xcode 14 beta 3
This is the way!
|
I also face other compiler errors:
internal static let EaseOutBack = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in
let s: TimeInterval = 1.70158
var position: TimeInterval = elapsed / duration
position -= 1.0
return Double( position * position * ((s + Double(1.0)) * position + s) + Double(1.0) )
}
for case let set as RadarChartDataSetProtocol in (radarData as ChartData) where set.isVisible
{
drawDataSet(context: context, dataSet: set, mostEntries: mostEntries)
} for case let set as CandleChartDataSetProtocol in (candleData as ChartData) where set.isVisible
{
drawDataSet(context: context, dataSet: set)
}from: #4860 (comment) |
|
Any update when this could be reviewed and merged? |
c3701a4 to
be742eb
Compare
my comments above haven't resolved yet, not sure yet. I tried this PR with beta 3, however couldn't build & run. Probably the latest time is when Xcode GM released and I can try it without bothering from beta releases. |
ChartsOrg#4823 (comment) (cherry picked from commit 696c6e5)
|
Thanks for contributing! |
|
@pmairoldi do you have a deadline for a new version? |
|
Waiting for Xcode 14 gm before releasing anything. |
|
@pmairoldi The GM is here, let me know if I can help you with anything. |
thanks pal! been busy with the new job, as we also had tons of issues regarding Xcode 14 RC and iOS 16 |
Issue Link 🔗
I'm currently experimenting with the latest development Swift 5.7 toolchain and the Charts library was not compiling due to a bug in the implementation of
RangeReplaceableCollectiononChartDataItem.This PR fixes that by adding the missing protocol method and also fixes a couple of compiler warnings (which I think also exist on the latest stable toolchain).
More info on this here: swiftlang/swift#58737 - the reason this compiled pre-5.7 was due to a bug in Swift which was due to be fixed in 5.6, reverted and will ship in 5.7 by the looks of it.
Goals ⚽
Library can now be compiled with Swift 5.7.
Testing Details 🔍
Library continues to compile under 5.6.
I wasn't able to get the snapshots to pass on my M1 Max laptop - maybe I'm using the wrong simulator. The failures were very subtle and I don't think are related to this change.