浏览代码

migrate to swift 4.2

Pierre-Marc Airoldi 7 年之前
父节点
当前提交
98a472cf77

+ 1 - 1
.swift-version

@@ -1 +1 @@
-4.0
+4.2

+ 4 - 4
.travis.yml

@@ -1,12 +1,12 @@
 language: objective-c
-osx_image: xcode9.3beta
+osx_image: xcode10
 matrix:
   include:
-    - osx_image: xcode9.3beta
+    - osx_image: xcode10
       env: PLATFORM="iOS"
-    - osx_image: xcode9.3beta
+    - osx_image: xcode10
       env: PLATFORM="tvOS"
-    - osx_image: xcode9.3beta
+    - osx_image: xcode10
       env: PLATFORM="macOS"
 env:
   global:

+ 1 - 1
Charts.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name = "Charts"
-  s.version = "3.1.1"
+  s.version = "3.2.0"
   s.summary = "Charts is a powerful & easy to use chart library for iOS, tvOS and OSX (and Android)"
   s.homepage = "https://github.com/danielgindi/Charts"
   s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }

+ 5 - 4
ChartsDemo-iOS/ChartsDemo-iOS.xcodeproj/project.pbxproj

@@ -658,6 +658,7 @@
 				TargetAttributes = {
 					225B361C1F6EB9A50005B3D5 = {
 						CreatedOnToolsVersion = 9.0;
+						LastSwiftMigration = 1000;
 					};
 					5B57BBAE1A9B26AA0036A6CC = {
 						CreatedOnToolsVersion = 6.1.1;
@@ -906,7 +907,7 @@
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-				SWIFT_VERSION = 4.0;
+				SWIFT_VERSION = 4.2;
 				TARGETED_DEVICE_FAMILY = 1;
 			};
 			name = Debug;
@@ -935,7 +936,7 @@
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-Swift";
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				SWIFT_VERSION = 4.0;
+				SWIFT_VERSION = 4.2;
 				TARGETED_DEVICE_FAMILY = 1;
 			};
 			name = Release;
@@ -1056,7 +1057,7 @@
 				SWIFT_OBJC_BRIDGING_HEADER = "Supporting Files/ChartsDemo-Bridging-Header.h";
 				SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-				SWIFT_VERSION = 4.0;
+				SWIFT_VERSION = 4.2;
 			};
 			name = Debug;
 		};
@@ -1075,7 +1076,7 @@
 				SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos";
 				SWIFT_OBJC_BRIDGING_HEADER = "Supporting Files/ChartsDemo-Bridging-Header.h";
 				SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h";
-				SWIFT_VERSION = 4.0;
+				SWIFT_VERSION = 4.2;
 			};
 			name = Release;
 		};

+ 1 - 1
ChartsDemo-iOS/Swift/AppDelegate.swift

@@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
     var window: UIWindow?
 
-    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         // Override point for customization after application launch.
         self.window = UIWindow(frame: UIScreen.main.bounds)
         

+ 2 - 2
ChartsDemo-macOS/ChartsDemo-macOS.xcodeproj/project.pbxproj

@@ -376,7 +376,7 @@
 				PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-OSX";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
-				SWIFT_VERSION = 4.0;
+				SWIFT_VERSION = 4.2;
 			};
 			name = Debug;
 		};
@@ -394,7 +394,7 @@
 				PRODUCT_BUNDLE_IDENTIFIER = "com.dcg.ChartsDemo-OSX";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
-				SWIFT_VERSION = 4.0;
+				SWIFT_VERSION = 4.2;
 			};
 			name = Release;
 		};

二进制
ChartsDemo-macOS/PlaygroundChart.playground/Contents.o


+ 3 - 3
README.md

@@ -1,4 +1,4 @@
-**Version 3.1.1**, synced to [MPAndroidChart #f6a398b](https://github.com/PhilJay/MPAndroidChart/commit/f6a398b)
+**Version 3.2.0**, synced to [MPAndroidChart #f6a398b](https://github.com/PhilJay/MPAndroidChart/commit/f6a398b)
 
 ![alt tag](https://raw.github.com/danielgindi/Charts/master/Assets/feature_graphic.png)
   ![Supported Platforms](https://img.shields.io/cocoapods/p/Charts.svg) [![Releases](https://img.shields.io/github/release/danielgindi/Charts.svg)](https://github.com/danielgindi/Charts/releases) [![Latest pod release](https://img.shields.io/cocoapods/v/Charts.svg)](http://cocoapods.org/pods/charts) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/danielgindi/Charts.svg?branch=master)](https://travis-ci.org/danielgindi/Charts) [![codecov](https://codecov.io/gh/danielgindi/Charts/branch/master/graph/badge.svg)](https://codecov.io/gh/danielgindi/Charts)
@@ -78,8 +78,8 @@ For [Realm](https://realm.io/) support, please add `pod 'ChartsRealm'` too.
 Charts now include Carthage prebuilt binaries.
 
 ```carthage
-github "danielgindi/Charts" == 3.1.1
-github "danielgindi/Charts" ~> 3.1.1
+github "danielgindi/Charts" == 3.2.0
+github "danielgindi/Charts" ~> 3.2.0
 ```
 
 In order to build the binaries for a new release, use `carthage build --no-skip-current && carthage archive Charts`.

+ 2 - 2
Source/Charts/Charts/BarLineChartViewBase.swift

@@ -877,8 +877,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
             let velocity = _panGestureRecognizer.velocity(in: self)
             if _data === nil || !isDragEnabled ||
                 (self.hasNoDragOffset && self.isFullyZoomedOut && !self.isHighlightPerDragEnabled) ||
-                (!_dragYEnabled && fabs(velocity.y) > fabs(velocity.x)) ||
-                (!_dragXEnabled && fabs(velocity.y) < fabs(velocity.x))
+                (!_dragYEnabled && abs(velocity.y) > abs(velocity.x)) ||
+                (!_dragXEnabled && abs(velocity.y) < abs(velocity.x))
             {
                 return false
             }

+ 1 - 1
Source/Charts/Charts/PieChartView.swift

@@ -389,7 +389,7 @@ open class PieChartView: PieRadarChartViewBase
             {
                 #if os(OSX)
                     let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
-                    paragraphStyle.lineBreakMode = NSParagraphStyle.LineBreakMode.byTruncatingTail
+                    paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail
                 #else
                     let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
                     paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail

+ 1 - 1
Source/Charts/Filters/DataApproximator+N.swift

@@ -15,7 +15,7 @@ extension CGPoint {
         let dx = linePoint2.x - linePoint1.x
         let dy = linePoint2.y - linePoint1.y
         
-        let dividend = fabs(dy * self.x - dx * self.y - linePoint1.x * linePoint2.y + linePoint2.x * linePoint1.y)
+        let dividend = abs(dy * self.x - dx * self.y - linePoint1.x * linePoint2.y + linePoint2.x * linePoint1.y)
         let divisor = sqrt(dx * dx + dy * dy)
         
         return dividend / divisor

+ 0 - 1
Source/Charts/Renderers/CandleStickChartRenderer.swift

@@ -71,7 +71,6 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer
         let phaseY = animator.phaseY
         let barSpace = dataSet.barSpace
         let showCandleBar = dataSet.showCandleBar
-        let entryCount = dataSet.entryCount
         
         _xBounds.set(chart: dataProvider, dataSet: dataSet, animator: animator)
         

+ 1 - 1
Source/Charts/Renderers/ChartDataRendererBase.swift

@@ -24,7 +24,7 @@ open class DataRenderer: Renderer
     /// Subclasses should populate this array in drawData() or drawDataSet() to make the chart accessible.
     @objc final var accessibleChartElements: [NSUIAccessibilityElement] = []
 
-    @objc open let animator: Animator
+    @objc public let animator: Animator
     
     @objc public init(animator: Animator, viewPortHandler: ViewPortHandler)
     {

+ 1 - 1
Source/Charts/Renderers/Renderer.swift

@@ -16,7 +16,7 @@ import CoreGraphics
 open class Renderer: NSObject
 {
     /// the component that handles the drawing area of the chart and it's offsets
-    @objc open let viewPortHandler: ViewPortHandler
+    @objc public let viewPortHandler: ViewPortHandler
 
     @objc public init(viewPortHandler: ViewPortHandler)
     {

+ 8 - 8
Source/Charts/Utils/Platform+Accessibility.swift

@@ -4,12 +4,12 @@ import Foundation
 
 internal func accessibilityPostLayoutChangedNotification(withElement element: Any? = nil)
 {
-    UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, element)
+    UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: element)
 }
 
 internal func accessibilityPostScreenChangedNotification(withElement element: Any? = nil)
 {
-    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, element)
+    UIAccessibility.post(notification: UIAccessibility.Notification.screenChanged, argument: element)
 }
 
 /// A simple abstraction over UIAccessibilityElement and NSAccessibilityElement.
@@ -21,7 +21,7 @@ open class NSUIAccessibilityElement: UIAccessibilityElement
     {
         didSet
         {
-            accessibilityTraits = isHeader ? UIAccessibilityTraitHeader : UIAccessibilityTraitNone
+            accessibilityTraits = isHeader ? UIAccessibilityTraits.header : UIAccessibilityTraits.none
         }
     }
 
@@ -29,7 +29,7 @@ open class NSUIAccessibilityElement: UIAccessibilityElement
         {
         didSet
         {
-            accessibilityTraits = isSelected ? UIAccessibilityTraitSelected : UIAccessibilityTraitNone
+            accessibilityTraits = isSelected ? UIAccessibilityTraits.selected : UIAccessibilityTraits.none
         }
     }
 
@@ -93,7 +93,7 @@ extension NSUIView
 internal func accessibilityPostLayoutChangedNotification(withElement element: Any? = nil)
 {
     guard let validElement = element else { return }
-    NSAccessibilityPostNotification(validElement, .layoutChanged)
+    NSAccessibility.post(element: validElement, notification: .layoutChanged)
 }
 
 internal func accessibilityPostScreenChangedNotification(withElement element: Any? = nil)
@@ -144,7 +144,7 @@ open class NSUIAccessibilityElement: NSAccessibilityElement
 
         set
         {
-            let bounds = NSAccessibilityFrameInView(containerView, newValue)
+            let bounds = NSAccessibility.screenRect(fromView: containerView, rect: newValue)
 
             // This works, but won't auto update if the window is resized or moved.
             // setAccessibilityFrame(bounds)
@@ -154,8 +154,8 @@ open class NSUIAccessibilityElement: NSAccessibilityElement
             // This is a slightly hacky workaround that calculates the offset and removes it from frame calculation.
             setAccessibilityFrameInParentSpace(bounds)
             let axFrame = accessibilityFrame()
-            let widthOffset = fabs(axFrame.origin.x - bounds.origin.x)
-            let heightOffset = fabs(axFrame.origin.y - bounds.origin.y)
+            let widthOffset = abs(axFrame.origin.x - bounds.origin.x)
+            let heightOffset = abs(axFrame.origin.y - bounds.origin.y)
             let rect = NSRect(x: bounds.origin.x - widthOffset,
                               y: bounds.origin.y - heightOffset,
                               width: bounds.width,

+ 3 - 3
Source/Charts/Utils/Platform.swift

@@ -274,7 +274,7 @@ public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State
             stop()
         }
 
-		open func add(to runloop: RunLoop, forMode mode: RunLoopMode)
+        open func add(to runloop: RunLoop, forMode mode: RunLoop.Mode)
         {
             if displayLink != nil
             {
@@ -286,7 +286,7 @@ public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State
             }
 		}
 
-		open func remove(from: RunLoop, forMode: RunLoopMode)
+        open func remove(from: RunLoop, forMode: RunLoop.Mode)
         {
             stop()
 		}
@@ -397,7 +397,7 @@ public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State
         /// A private constant to set the accessibility role during initialization.
         /// It ensures parity with the iOS element ordering as well as numbered counts of chart components.
         /// (See Platform+Accessibility for details)
-        private let role: NSAccessibilityRole = .list
+        private let role: NSAccessibility.Role = .list
 
         public override init(frame frameRect: NSRect)
         {

+ 1 - 1
Source/Supporting Files/Info.plist

@@ -15,7 +15,7 @@
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
-	<string>3.1.1</string>
+	<string>3.2.0</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>