Charts: ChartAnimationEasing.swift file getting compiler error error on Xcode14-beta
What did you do?
I tried to run my application with Xcode 14 Beta and in Charts pod ChartAnimationEasing.swift file there’s an error with this function
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 + 1.0) * position + s) + 1.0 )
}
The error says that The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions. Is there anything I can do with it ?
I expect to run my application without any error however the Chart file getting error that relational with type-checking
Charts Environment
My podfile includes Charts like default
pod 'Charts'
Charts version/Branch/Commit Number: **Xcode version: Version 14.0 beta (14A5228q) **Swift version: swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8) Platform(s) running Charts: Xcode 14.0 Beta as I described, tried to run into multiple simulators and real devices macOS version running Xcode: MacOS Monterey 12.4 (21F79) CommandLineTool: Xcode14 14A5228q
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 13
- Comments: 15 (4 by maintainers)
Commits related to this issue
- fix: add double mark for compiler check related with issue danielgindi#4835. — committed to cafedeichi/Charts by cafedeichi 2 years ago
- Merge pull request #4836 from eliakorkmaz/issue-4835 Add double mark for compiler check related with issue #4835 — committed to ChartsOrg/Charts by pmairoldi 2 years ago
- Merge branch 'master' into test * master: (35 commits) fix ios tests fix ios tests fix tvos tests udpate ci update ci update ci update readme update ci update ci Release 4.1 fix... — committed to zebraciam/Charts by zebraciam 2 years ago
- Merge commit '203700608a6e956e591e7387d77423fa3fea6947' * commit '203700608a6e956e591e7387d77423fa3fea6947': (35 commits) fix ios tests fix ios tests fix tvos tests udpate ci update ci up... — committed to thyadang-techlabs/Charts by deleted user 2 years ago
- Merge branch 'master' of github.com:zwneng/Charts * 'master' of github.com:zwneng/Charts: (22 commits) fix ios tests fix ios tests fix tvos tests udpate ci update ci update ci update re... — committed to zwneng/Charts by zwneng 2 years ago
- Add double mark for compiler check related with issue #4835 — committed to mmazzei/Charts by eliakorkmaz 2 years ago
- Add double mark for compiler check related with issue #4835 — committed to felicapocket/Charts by eliakorkmaz 2 years ago
- Add double mark for compiler check related with issue #4835 — committed to danielwischer/Charts by danielwischer a year ago
- Merge branch 'master' into developer-338 * master: (22 commits) fix ios tests fix ios tests fix tvos tests udpate ci update ci update ci update readme update ci update ci Release ... — committed to nolano/Charts by deleted user 2 years ago
Above function is part of
ChartAnimationEasing.swiftfile so it should be fixed on framework side.Suggestion passes compiler checks.
return Double( position * position * ((s + Double(1.0)) * position + s) + Double(1.0) )hey people, sorry for late reply, yesterday we tried new Xcode14 beta and there was an error which I described it already.
After that I separate all of the items as a variable, it worked and successfully run my project into Xcode 14.
I achieved it with a so simple way with
but with a single line of which @McSims-Ubi described we can handle it. I am opening a pull request asap and link my issue as #4835 and after that it would be resolved, after that I open PR, I will comment in here.
The issue here isn’t with charts. My guess is that it’s this line:
return Double( position * position * ((s + 1.0) * position + s) + 1.0 )Try separating that into components and provide strict types for the1.0values and it shield resolve.People, the Charts library seems not to support beta as they say and you can see in the PR, if you need to fix it open the file and edit the line with
return Double( position * position * ((s + Double(1.0)) * position + s) + Double(1.0) )for now with unlocking the file untilXcode 14 GMrelease, so this issue will be open for a whileStill not working on Xcode14b3 for me (I did delete DerivedData + Clean Build Folder)
Same error with Xcode 14 beta 2
Hello guys, again
I just create a pull request you can see here -> https://github.com/danielgindi/Charts/pull/4836
Thanks for comments @richardpineo @McSims-Ubi
To break up the expression into distinct sub-expressions, you can try separating out each part of the calculation into its own intermediate variable. Here is one way you could do this:
internal static let EaseOutBack = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in let s: TimeInterval = 1.70158 var position: TimeInterval = elapsed / duration position -= 1.0 let a = position * position let b = (s + 1.0) * position let c = a * (b + s) let result = c + 1.0 return Double(result) } I hope this helps! Let me know if you have any further questions.
建议把最后return代码分开,swift不建议此操作通过一行解决
pr has open and needs to approval for the workflow