Skip to content

Commit

Permalink
Merge branch 'swift5'
Browse files Browse the repository at this point in the history
  • Loading branch information
poetmountain committed Jun 10, 2019
2 parents 0da1ec2 + 3d2684a commit 683bee3
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 63 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#### 2.0.0
- Support for Swift 5.0
- Updated syntax in MotionOptions for newer Swift naming conventions
- Updated Swift package file to newest version, requires Xcode 11 to import
- Bumped version to 2.0.0 due to breaking change in MotionOptions (Swift Package Manager requires packages use semantic versioning)

#### 1.3.3
- Support for Swift 4.2

Expand Down
4 changes: 2 additions & 2 deletions MotionMachine.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'MotionMachine'
s.version = '1.3.3'
s.swift_version = '4.2'
s.version = '2.0.0'
s.swift_version = '5.0'
s.license = { :type => 'MIT' }
s.summary = 'An elegant, powerful, and modular animation library for Swift.'
s.description = <<-DESC
Expand Down
20 changes: 17 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:5.0

// Package.swift
// MotionMachine
Expand Down Expand Up @@ -29,5 +29,19 @@ import PackageDescription

let package = Package(
name: "MotionMachine",
swiftLanguageVersions: [4.2]
)
platforms: [
.iOS(.v8), .tvOS(.v9)
],
products: [
.library(name: "MotionMachine", targets: ["MotionMachine"])
],
targets: [
.target(name: "MotionMachine", path: "Sources/"),
.testTarget(
name: "MotionMachineTests",
dependencies: ["MotionMachine"],
path: "Tests/Tests/"
)
],
swiftLanguageVersions: [.v5]
)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![MotionMachine logo](Guides/mmlogo.png)

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

Expand Down Expand Up @@ -170,7 +170,7 @@ Or add the Sources directory to your project.
## Compatibility

MotionMachine currently requires:
* Swift 4.2
* Swift 5.0
* Xcode 10.0 or later
* iOS 8.0 or later, tvOS 9.0 or later

Expand Down
16 changes: 9 additions & 7 deletions Sources/Motion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
* - 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.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {

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

Expand All @@ -537,7 +537,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
* - 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.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {

self.init(target: targetObject, properties: [], statesForProperties: nil, duration: duration, easing: easing, options: options)
}
Expand All @@ -552,13 +552,13 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
* - 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.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {

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


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

var properties = props ?? []

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

// unpack options values
repeating = options!.contains(.Repeat)
reversing = options!.contains(.Reverse)
resetObjectStateOnRepeat = options!.contains(.ResetStateOnRepeat)
if let unwrappedOptions = options {
repeating = unwrappedOptions.contains(.repeats)
reversing = unwrappedOptions.contains(.reverses)
resetObjectStateOnRepeat = unwrappedOptions.contains(.resetsStateOnRepeat)
}

motionState = .stopped
motionDirection = .forward
Expand Down
10 changes: 6 additions & 4 deletions Sources/MotionGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,13 @@ public class MotionGroup: Moveable, MoveableCollection, TempoDriven, MotionUpdat
* - motions: An array of `Moveable` objects which the MotionGroup should control.
* - options: An optional set of `MotionsOptions`.
*/
public init(motions: [Moveable]=[], options: MotionOptions?=MotionOptions.None) {
public init(motions: [Moveable] = [], options: MotionOptions? = .none) {

// unpack options values
repeating = options!.contains(.Repeat)
_reversing = options!.contains(.Reverse)
if let unwrappedOptions = options {
repeating = unwrappedOptions.contains(.repeats)
_reversing = unwrappedOptions.contains(.reverses)
}

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

// first grab the index of the object in the motions array so we can remove the corresponding tempoOverrides value
let index = motions.index {
let index = motions.firstIndex {
$0 == motion
}
if let motion_index = index {
Expand Down
16 changes: 8 additions & 8 deletions Sources/MotionMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public protocol ValueAssistant {

public extension ValueAssistant {

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

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

Expand All @@ -355,7 +355,7 @@ public extension ValueAssistant {
// utility methods for ValueAssistant
public extension ValueAssistant {

public func applyTo(value: inout Double, newValue: Double) {
func applyTo(value: inout Double, newValue: Double) {
if (additive) {
value += (newValue * additiveWeighting)
} else {
Expand All @@ -364,15 +364,15 @@ public extension ValueAssistant {

}

public func applyTo(value: inout CGFloat, newValue: CGFloat) {
func applyTo(value: inout CGFloat, newValue: CGFloat) {
if (additive) {
value += (newValue * CGFloat(additiveWeighting))
} else {
value = newValue
}
}

public func lastComponent(forPath path: String) -> String {
func lastComponent(forPath path: String) -> String {
let components = path.components(separatedBy: ".")
return components.last!
}
Expand Down Expand Up @@ -505,20 +505,20 @@ public struct MotionOptions : OptionSet {
public init(rawValue: Int) { self.rawValue = rawValue }

/// No options are specified.
public static let None = MotionOptions(rawValue: 0)
public static let none = MotionOptions(rawValue: 0)

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

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

/**
* 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.
*
* - remark: `Motion` and `PhysicsMotion` are the only MotionMachine classes that currently accept this option.
*/
public static let ResetStateOnRepeat = MotionOptions(rawValue: 1 << 2)
public static let resetsStateOnRepeat = MotionOptions(rawValue: 1 << 2)
}


Expand Down
10 changes: 6 additions & 4 deletions Sources/MotionSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,13 @@ public class MotionSequence: Moveable, MoveableCollection, TempoDriven, MotionUp
* - 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.
* - options: An optional set of `MotionsOptions`.
*/
public init(steps: [Moveable]=[], options: MotionOptions?=MotionOptions.None) {
public init(steps: [Moveable] = [], options: MotionOptions? = .none) {

// unpack options values
repeating = options!.contains(.Repeat)
_reversing = options!.contains(.Reverse)
if let unwrappedOptions = options {
repeating = unwrappedOptions.contains(.repeats)
_reversing = unwrappedOptions.contains(.reverses)
}

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

// first grab the index of the object in the motions array so we can remove the corresponding tempoOverrides value
let index = steps.index {
let index = steps.firstIndex {
$0 == sequenceStep
}

Expand Down
14 changes: 8 additions & 6 deletions Sources/PhysicsMotion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
* - 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.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, properties: [PropertyData], velocity: Double, friction: Double, options: MotionOptions?=MotionOptions.None) {
public convenience init(target targetObject: NSObject, properties: [PropertyData], velocity: Double, friction: Double, options: MotionOptions? = .none) {

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

Expand All @@ -562,13 +562,13 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
* - 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.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, velocity: Double, friction: Double, options: MotionOptions?=MotionOptions.None) {
public convenience init(target targetObject: NSObject, velocity: Double, friction: Double, options: MotionOptions? = .none) {

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


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

let properties = props ?? []

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

// unpack options values
repeating = options!.contains(.Repeat)
reversing = options!.contains(.Reverse)
resetObjectStateOnRepeat = options!.contains(.ResetStateOnRepeat)
if let unwrappedOptions = options {
repeating = unwrappedOptions.contains(.repeats)
reversing = unwrappedOptions.contains(.reverses)
resetObjectStateOnRepeat = unwrappedOptions.contains(.resetsStateOnRepeat)
}

motionState = .stopped
motionDirection = .forward
Expand Down
2 changes: 1 addition & 1 deletion Tests/MotionMachine/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


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

Expand Down
24 changes: 12 additions & 12 deletions Tests/MotionMachineTests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,26 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Poet & Mountain, LLC";
TargetAttributes = {
8B62C0241CEF9C0F0087727A = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0920;
DevelopmentTeam = HJVTQESL5X;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
TestTargetID = 8B62C0B81CF014210087727A;
};
8B62C0B81CF014210087727A = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0920;
LastSwiftMigration = 1020;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = 8B62C00C1CEF9C0F0087727A /* Build configuration list for PBXProject "MotionMachineTests" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -442,6 +443,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -499,6 +501,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -551,13 +554,13 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = HJVTQESL5X;
INFOPLIST_FILE = MotionMachineTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachineTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MotionMachine.app/MotionMachine";
};
name = Debug;
Expand All @@ -571,8 +574,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachineTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MotionMachine.app/MotionMachine";
};
name = Release;
Expand All @@ -585,8 +587,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachine;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -598,8 +599,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.poetmountain.MotionMachine;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tests/MotionGroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class MotionGroupTests: XCTestCase {
let did_repeat = expectation(description: "group called cycleRepeated notify closure")
let did_complete = expectation(description: "group called completed notify closure")

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

let group = MotionGroup(motions: [motion, motion2], options: [.Reverse])
let group = MotionGroup(motions: [motion, motion2], options: [.reverses])
.reversed({ (group) in
XCTAssertTrue(group.totalProgress <= 0.5)
XCTAssertTrue(group.cycleProgress <= 0.5)
Expand Down
Loading

0 comments on commit 683bee3

Please sign in to comment.