Skip to content

Commit 683bee3

Browse files
committed
Merge branch 'swift5'
2 parents 0da1ec2 + 3d2684a commit 683bee3

15 files changed

+91
-63
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#### 2.0.0
2+
- Support for Swift 5.0
3+
- Updated syntax in MotionOptions for newer Swift naming conventions
4+
- Updated Swift package file to newest version, requires Xcode 11 to import
5+
- Bumped version to 2.0.0 due to breaking change in MotionOptions (Swift Package Manager requires packages use semantic versioning)
6+
17
#### 1.3.3
28
- Support for Swift 4.2
39

MotionMachine.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = 'MotionMachine'
3-
s.version = '1.3.3'
4-
s.swift_version = '4.2'
3+
s.version = '2.0.0'
4+
s.swift_version = '5.0'
55
s.license = { :type => 'MIT' }
66
s.summary = 'An elegant, powerful, and modular animation library for Swift.'
77
s.description = <<-DESC

Package.swift

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.0
22

33
// Package.swift
44
// MotionMachine
@@ -29,5 +29,19 @@ import PackageDescription
2929

3030
let package = Package(
3131
name: "MotionMachine",
32-
swiftLanguageVersions: [4.2]
33-
)
32+
platforms: [
33+
.iOS(.v8), .tvOS(.v9)
34+
],
35+
products: [
36+
.library(name: "MotionMachine", targets: ["MotionMachine"])
37+
],
38+
targets: [
39+
.target(name: "MotionMachine", path: "Sources/"),
40+
.testTarget(
41+
name: "MotionMachineTests",
42+
dependencies: ["MotionMachine"],
43+
path: "Tests/Tests/"
44+
)
45+
],
46+
swiftLanguageVersions: [.v5]
47+
)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![MotionMachine logo](Guides/mmlogo.png)
22

3-
![swift](https://img.shields.io/badge/Swift-4.2-005AA5.svg)
3+
![swift](https://img.shields.io/badge/Swift-5.0-005AA5.svg)
44
![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20tvOS-005AA5.svg)
55
![license](https://img.shields.io/badge/license-MIT-005AA5.svg)
66

@@ -170,7 +170,7 @@ Or add the Sources directory to your project.
170170
## Compatibility
171171

172172
MotionMachine currently requires:
173-
* Swift 4.2
173+
* Swift 5.0
174174
* Xcode 10.0 or later
175175
* iOS 8.0 or later, tvOS 9.0 or later
176176

Sources/Motion.swift

+9-7
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
522522
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
523523
* - options: An optional set of `MotionsOptions`.
524524
*/
525-
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
525+
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
526526

527527
self.init(target: targetObject, properties: properties, statesForProperties: nil, duration: duration, easing: easing, options: options)
528528

@@ -537,7 +537,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
537537
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
538538
* - options: An optional set of `MotionsOptions`.
539539
*/
540-
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
540+
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
541541

542542
self.init(target: targetObject, properties: [], statesForProperties: nil, duration: duration, easing: easing, options: options)
543543
}
@@ -552,13 +552,13 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
552552
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
553553
* - options: An optional set of `MotionsOptions`.
554554
*/
555-
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
555+
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
556556

557557
self.init(target: targetObject, properties: nil, statesForProperties: templateObjects, duration: duration, easing: easing, options: options)
558558
}
559559

560560

561-
private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions?) {
561+
private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions? = .none) {
562562

563563
var properties = props ?? []
564564

@@ -578,9 +578,11 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
578578
#endif
579579

580580
// unpack options values
581-
repeating = options!.contains(.Repeat)
582-
reversing = options!.contains(.Reverse)
583-
resetObjectStateOnRepeat = options!.contains(.ResetStateOnRepeat)
581+
if let unwrappedOptions = options {
582+
repeating = unwrappedOptions.contains(.repeats)
583+
reversing = unwrappedOptions.contains(.reverses)
584+
resetObjectStateOnRepeat = unwrappedOptions.contains(.resetsStateOnRepeat)
585+
}
584586

585587
motionState = .stopped
586588
motionDirection = .forward

Sources/MotionGroup.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,13 @@ public class MotionGroup: Moveable, MoveableCollection, TempoDriven, MotionUpdat
468468
* - motions: An array of `Moveable` objects which the MotionGroup should control.
469469
* - options: An optional set of `MotionsOptions`.
470470
*/
471-
public init(motions: [Moveable]=[], options: MotionOptions?=MotionOptions.None) {
471+
public init(motions: [Moveable] = [], options: MotionOptions? = .none) {
472472

473473
// unpack options values
474-
repeating = options!.contains(.Repeat)
475-
_reversing = options!.contains(.Reverse)
474+
if let unwrappedOptions = options {
475+
repeating = unwrappedOptions.contains(.repeats)
476+
_reversing = unwrappedOptions.contains(.reverses)
477+
}
476478

477479
motionState = .stopped
478480
motionDirection = .forward
@@ -555,7 +557,7 @@ public class MotionGroup: Moveable, MoveableCollection, TempoDriven, MotionUpdat
555557
public func remove(_ motion: Moveable) {
556558

557559
// first grab the index of the object in the motions array so we can remove the corresponding tempoOverrides value
558-
let index = motions.index {
560+
let index = motions.firstIndex {
559561
$0 == motion
560562
}
561563
if let motion_index = index {

Sources/MotionMachine.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public protocol ValueAssistant {
335335

336336
public extension ValueAssistant {
337337

338-
public func retrieveCurrentObjectValue(forProperty property: PropertyData) -> Double? {
338+
func retrieveCurrentObjectValue(forProperty property: PropertyData) -> Double? {
339339

340340
guard let unwrapped_object = property.targetObject else { return nil }
341341

@@ -355,7 +355,7 @@ public extension ValueAssistant {
355355
// utility methods for ValueAssistant
356356
public extension ValueAssistant {
357357

358-
public func applyTo(value: inout Double, newValue: Double) {
358+
func applyTo(value: inout Double, newValue: Double) {
359359
if (additive) {
360360
value += (newValue * additiveWeighting)
361361
} else {
@@ -364,15 +364,15 @@ public extension ValueAssistant {
364364

365365
}
366366

367-
public func applyTo(value: inout CGFloat, newValue: CGFloat) {
367+
func applyTo(value: inout CGFloat, newValue: CGFloat) {
368368
if (additive) {
369369
value += (newValue * CGFloat(additiveWeighting))
370370
} else {
371371
value = newValue
372372
}
373373
}
374374

375-
public func lastComponent(forPath path: String) -> String {
375+
func lastComponent(forPath path: String) -> String {
376376
let components = path.components(separatedBy: ".")
377377
return components.last!
378378
}
@@ -505,20 +505,20 @@ public struct MotionOptions : OptionSet {
505505
public init(rawValue: Int) { self.rawValue = rawValue }
506506

507507
/// No options are specified.
508-
public static let None = MotionOptions(rawValue: 0)
508+
public static let none = MotionOptions(rawValue: 0)
509509

510510
/// Specifies that a motion should repeat.
511-
public static let Repeat = MotionOptions(rawValue: 1 << 0)
511+
public static let repeats = MotionOptions(rawValue: 1 << 0)
512512

513513
/// Specifies that a motion should reverse directions after moving in the forward direction.
514-
public static let Reverse = MotionOptions(rawValue: 1 << 1)
514+
public static let reverses = MotionOptions(rawValue: 1 << 1)
515515

516516
/**
517517
* Specifies that a motion's property (or parent, if property is not KVC-compliant) should be reset to its starting value on repeats or restarts.
518518
*
519519
* - remark: `Motion` and `PhysicsMotion` are the only MotionMachine classes that currently accept this option.
520520
*/
521-
public static let ResetStateOnRepeat = MotionOptions(rawValue: 1 << 2)
521+
public static let resetsStateOnRepeat = MotionOptions(rawValue: 1 << 2)
522522
}
523523

524524

Sources/MotionSequence.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,13 @@ public class MotionSequence: Moveable, MoveableCollection, TempoDriven, MotionUp
485485
* - steps: An array of `Moveable` objects the MotionSequence should control. The positions of the objects in the Array will determine the order in which the child motions should move.
486486
* - options: An optional set of `MotionsOptions`.
487487
*/
488-
public init(steps: [Moveable]=[], options: MotionOptions?=MotionOptions.None) {
488+
public init(steps: [Moveable] = [], options: MotionOptions? = .none) {
489489

490490
// unpack options values
491-
repeating = options!.contains(.Repeat)
492-
_reversing = options!.contains(.Reverse)
491+
if let unwrappedOptions = options {
492+
repeating = unwrappedOptions.contains(.repeats)
493+
_reversing = unwrappedOptions.contains(.reverses)
494+
}
493495

494496
motionState = .stopped
495497
motionDirection = .forward
@@ -574,7 +576,7 @@ public class MotionSequence: Moveable, MoveableCollection, TempoDriven, MotionUp
574576
public func remove(_ sequenceStep: Moveable) {
575577

576578
// first grab the index of the object in the motions array so we can remove the corresponding tempoOverrides value
577-
let index = steps.index {
579+
let index = steps.firstIndex {
578580
$0 == sequenceStep
579581
}
580582

Sources/PhysicsMotion.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
547547
* - friction: The friction used to calculate new values in the `PhysicsSolving` system. Acceptable values are 0.0 (no friction) to 1.0 (no movement); values outside of this range will be clamped to the nearest edge.
548548
* - options: An optional set of `MotionsOptions`.
549549
*/
550-
public convenience init(target targetObject: NSObject, properties: [PropertyData], velocity: Double, friction: Double, options: MotionOptions?=MotionOptions.None) {
550+
public convenience init(target targetObject: NSObject, properties: [PropertyData], velocity: Double, friction: Double, options: MotionOptions? = .none) {
551551

552552
self.init(targetObject: targetObject, properties: properties, velocity: velocity, friction: friction, options: options)
553553

@@ -562,13 +562,13 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
562562
* - friction: The friction used to calculate new values in the `PhysicsSolving` system. Acceptable values are 0.0 (no friction) to 1.0 (no movement); values outside of this range will be clamped to the nearest edge.
563563
* - options: An optional set of `MotionsOptions`.
564564
*/
565-
public convenience init(target targetObject: NSObject, velocity: Double, friction: Double, options: MotionOptions?=MotionOptions.None) {
565+
public convenience init(target targetObject: NSObject, velocity: Double, friction: Double, options: MotionOptions? = .none) {
566566

567567
self.init(targetObject: targetObject, properties: [], velocity: velocity, friction: friction, options: options)
568568
}
569569

570570

571-
private init(targetObject: NSObject, properties props: [PropertyData]?, velocity: Double, friction: Double, options: MotionOptions?) {
571+
private init(targetObject: NSObject, properties props: [PropertyData]?, velocity: Double, friction: Double, options: MotionOptions? = .none) {
572572

573573
let properties = props ?? []
574574

@@ -583,9 +583,11 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
583583
#endif
584584

585585
// unpack options values
586-
repeating = options!.contains(.Repeat)
587-
reversing = options!.contains(.Reverse)
588-
resetObjectStateOnRepeat = options!.contains(.ResetStateOnRepeat)
586+
if let unwrappedOptions = options {
587+
repeating = unwrappedOptions.contains(.repeats)
588+
reversing = unwrappedOptions.contains(.reverses)
589+
resetObjectStateOnRepeat = unwrappedOptions.contains(.resetsStateOnRepeat)
590+
}
589591

590592
motionState = .stopped
591593
motionDirection = .forward

Tests/MotionMachine/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
1818
return true
1919
}
2020

Tests/MotionMachineTests.xcodeproj/project.pbxproj

+12-12
Original file line numberDiff line numberDiff line change
@@ -297,25 +297,26 @@
297297
isa = PBXProject;
298298
attributes = {
299299
LastSwiftUpdateCheck = 0730;
300-
LastUpgradeCheck = 1000;
300+
LastUpgradeCheck = 1020;
301301
ORGANIZATIONNAME = "Poet & Mountain, LLC";
302302
TargetAttributes = {
303303
8B62C0241CEF9C0F0087727A = {
304304
CreatedOnToolsVersion = 7.3.1;
305-
LastSwiftMigration = 0920;
305+
DevelopmentTeam = HJVTQESL5X;
306+
LastSwiftMigration = 1020;
306307
ProvisioningStyle = Manual;
307308
TestTargetID = 8B62C0B81CF014210087727A;
308309
};
309310
8B62C0B81CF014210087727A = {
310311
CreatedOnToolsVersion = 7.3.1;
311-
LastSwiftMigration = 0920;
312+
LastSwiftMigration = 1020;
312313
ProvisioningStyle = Manual;
313314
};
314315
};
315316
};
316317
buildConfigurationList = 8B62C00C1CEF9C0F0087727A /* Build configuration list for PBXProject "MotionMachineTests" */;
317318
compatibilityVersion = "Xcode 3.2";
318-
developmentRegion = English;
319+
developmentRegion = en;
319320
hasScannedForEncodings = 0;
320321
knownRegions = (
321322
en,
@@ -442,6 +443,7 @@
442443
isa = XCBuildConfiguration;
443444
buildSettings = {
444445
ALWAYS_SEARCH_USER_PATHS = NO;
446+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
445447
CLANG_ANALYZER_NONNULL = YES;
446448
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
447449
CLANG_CXX_LIBRARY = "libc++";
@@ -499,6 +501,7 @@
499501
isa = XCBuildConfiguration;
500502
buildSettings = {
501503
ALWAYS_SEARCH_USER_PATHS = NO;
504+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
502505
CLANG_ANALYZER_NONNULL = YES;
503506
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
504507
CLANG_CXX_LIBRARY = "libc++";
@@ -551,13 +554,13 @@
551554
buildSettings = {
552555
BUNDLE_LOADER = "$(TEST_HOST)";
553556
CLANG_ENABLE_MODULES = YES;
557+
DEVELOPMENT_TEAM = HJVTQESL5X;
554558
INFOPLIST_FILE = MotionMachineTests/Info.plist;
555559
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
556560
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachineTests;
557561
PRODUCT_NAME = "$(TARGET_NAME)";
558562
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
559-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
560-
SWIFT_VERSION = 4.2;
563+
SWIFT_VERSION = 5.0;
561564
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MotionMachine.app/MotionMachine";
562565
};
563566
name = Debug;
@@ -571,8 +574,7 @@
571574
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
572575
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachineTests;
573576
PRODUCT_NAME = "$(TARGET_NAME)";
574-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
575-
SWIFT_VERSION = 4.2;
577+
SWIFT_VERSION = 5.0;
576578
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MotionMachine.app/MotionMachine";
577579
};
578580
name = Release;
@@ -585,8 +587,7 @@
585587
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
586588
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachine;
587589
PRODUCT_NAME = "$(TARGET_NAME)";
588-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
589-
SWIFT_VERSION = 4.0;
590+
SWIFT_VERSION = 5.0;
590591
};
591592
name = Debug;
592593
};
@@ -598,8 +599,7 @@
598599
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
599600
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachine;
600601
PRODUCT_NAME = "$(TARGET_NAME)";
601-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
602-
SWIFT_VERSION = 4.0;
602+
SWIFT_VERSION = 5.0;
603603
};
604604
name = Release;
605605
};

Tests/Tests/MotionGroupTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class MotionGroupTests: XCTestCase {
165165
let did_repeat = expectation(description: "group called cycleRepeated notify closure")
166166
let did_complete = expectation(description: "group called completed notify closure")
167167

168-
let group = MotionGroup(motions: [motion, motion2], options: [.Repeat])
168+
let group = MotionGroup(motions: [motion, motion2], options: [.repeats])
169169
.cycleRepeated({ (group) in
170170
XCTAssertEqual(group.totalProgress, 0.5)
171171
XCTAssertEqual(group.cycleProgress, 0.0)
@@ -206,7 +206,7 @@ class MotionGroupTests: XCTestCase {
206206
let did_reverse = expectation(description: "group called reversed notify closure")
207207
let did_complete = expectation(description: "group called completed notify closure")
208208

209-
let group = MotionGroup(motions: [motion, motion2], options: [.Reverse])
209+
let group = MotionGroup(motions: [motion, motion2], options: [.reverses])
210210
.reversed({ (group) in
211211
XCTAssertTrue(group.totalProgress <= 0.5)
212212
XCTAssertTrue(group.cycleProgress <= 0.5)

0 commit comments

Comments
 (0)