Skip to content

Commit d3c8df5

Browse files
committed
2.0.1 Update
1 parent dd9cacc commit d3c8df5

23 files changed

+188
-124
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 2.0.1
2+
- Fixed some retain cycles that were holding on to target objects
3+
- Updated examples project
4+
15
#### 2.0.0
26
- Support for Swift 5.0
37
- Updated syntax in MotionOptions for newer Swift naming conventions

Examples/MotionExamples.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
isa = PBXProject;
230230
attributes = {
231231
LastSwiftUpdateCheck = 0730;
232-
LastUpgradeCheck = 1000;
232+
LastUpgradeCheck = 1240;
233233
ORGANIZATIONNAME = "Poet & Mountain, LLC";
234234
TargetAttributes = {
235235
8BB379D31CFFA17D00A35AFD = {
@@ -241,7 +241,7 @@
241241
};
242242
buildConfigurationList = 8BB379CF1CFFA17D00A35AFD /* Build configuration list for PBXProject "MotionExamples" */;
243243
compatibilityVersion = "Xcode 3.2";
244-
developmentRegion = English;
244+
developmentRegion = en;
245245
hasScannedForEncodings = 0;
246246
knownRegions = (
247247
en,
@@ -333,6 +333,7 @@
333333
isa = XCBuildConfiguration;
334334
buildSettings = {
335335
ALWAYS_SEARCH_USER_PATHS = NO;
336+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
336337
CLANG_ANALYZER_NONNULL = YES;
337338
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
338339
CLANG_CXX_LIBRARY = "libc++";
@@ -352,6 +353,7 @@
352353
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
353354
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
354355
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
356+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
355357
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
356358
CLANG_WARN_STRICT_PROTOTYPES = YES;
357359
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -377,7 +379,7 @@
377379
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
378380
GCC_WARN_UNUSED_FUNCTION = YES;
379381
GCC_WARN_UNUSED_VARIABLE = YES;
380-
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
382+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
381383
MTL_ENABLE_DEBUG_INFO = YES;
382384
ONLY_ACTIVE_ARCH = YES;
383385
SDKROOT = iphoneos;
@@ -391,6 +393,7 @@
391393
isa = XCBuildConfiguration;
392394
buildSettings = {
393395
ALWAYS_SEARCH_USER_PATHS = NO;
396+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
394397
CLANG_ANALYZER_NONNULL = YES;
395398
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
396399
CLANG_CXX_LIBRARY = "libc++";
@@ -410,6 +413,7 @@
410413
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
411414
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
412415
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
416+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
413417
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
414418
CLANG_WARN_STRICT_PROTOTYPES = YES;
415419
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -428,7 +432,7 @@
428432
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
429433
GCC_WARN_UNUSED_FUNCTION = YES;
430434
GCC_WARN_UNUSED_VARIABLE = YES;
431-
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
435+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
432436
MTL_ENABLE_DEBUG_INFO = NO;
433437
SDKROOT = iphoneos;
434438
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";

Examples/MotionExamples/ButtonsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010

11-
protocol ButtonsViewDelegate {
11+
protocol ButtonsViewDelegate: class {
1212
func didStart()
1313
func didStop()
1414
func didPause()
@@ -24,7 +24,7 @@ public class ButtonsView: UIView {
2424

2525
var uiCreated: Bool = false
2626

27-
var delegate: ButtonsViewDelegate?
27+
weak var delegate: ButtonsViewDelegate?
2828

2929

3030
class func instanceFromNib() -> UIView {

Examples/MotionExamples/Classes/AdditiveViewController.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ public class AdditiveViewController: UIViewController, ButtonsViewDelegate {
129129
super.viewWillDisappear(animated)
130130

131131
group.stop()
132+
for motion in group.motions {
133+
group.remove(motion)
134+
}
132135
reverseGroup.stop()
133-
}
134-
135-
deinit {
136-
(view as! ButtonsView).delegate = nil
136+
for motion in reverseGroup.motions {
137+
reverseGroup.remove(motion)
138+
}
137139
}
138140

139141

Examples/MotionExamples/Classes/BasicMotionViewController.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class BasicMotionViewController: UIViewController, ButtonsViewDelegate {
3838

3939

4040
// setup motion
41-
motion = Motion(target: xConstraint, duration: 1.0, easing: EasingQuadratic.easeInOut(), options: [.Reverse])
41+
motion = Motion(target: xConstraint, duration: 1.0, easing: EasingQuadratic.easeInOut(), options: [.reverses])
4242
.add(PropertyData("constant", 200.0))
4343
.paused({ (motion) in
4444
print("paused!")
@@ -66,11 +66,7 @@ public class BasicMotionViewController: UIViewController, ButtonsViewDelegate {
6666

6767
motion.stop()
6868
}
69-
70-
deinit {
71-
(view as! ButtonsView).delegate = nil
72-
}
73-
69+
7470

7571

7672

Examples/MotionExamples/Classes/DynamicViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public class DynamicViewController: UIViewController, ButtonsViewDelegate {
5555
for motion in motions {
5656
motion.stop()
5757
}
58+
motions.removeAll()
5859
}
5960

6061
deinit {
61-
(view as! ButtonsView).delegate = nil
6262
view.removeGestureRecognizer(tapRecognizer)
6363
}
6464

@@ -143,7 +143,7 @@ public class DynamicViewController: UIViewController, ButtonsViewDelegate {
143143
}
144144

145145
let pt = gesture.location(in: self.view)
146-
//print("gesture pt \(pt)")
146+
print("gesture pt \(pt)")
147147

148148
var y_offset : CGFloat = 0.0
149149

@@ -170,6 +170,10 @@ public class DynamicViewController: UIViewController, ButtonsViewDelegate {
170170
motion_y.additive = true
171171

172172
let group = MotionGroup(motions: [motion_x, motion_y])
173+
group.updated { [weak self] (group) in
174+
guard let strong_self = self else { return }
175+
//print("constraints \(strong_self.constraints)")
176+
}
173177
group.completed { [weak self] (group) in
174178
guard let strong_self = self else { return }
175179

Examples/MotionExamples/Classes/GroupMotionViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class GroupMotionViewController: UIViewController, ButtonsViewDelegate {
4141

4242

4343
// setup motion
44-
group = MotionGroup(options: [.Reverse])
44+
group = MotionGroup(options: [.reverses])
4545
.add(Motion(target: constraints["circleX"]!,
4646
properties: [PropertyData("constant", 200.0)],
4747
duration: 1.0,
@@ -82,12 +82,12 @@ public class GroupMotionViewController: UIViewController, ButtonsViewDelegate {
8282
super.viewWillDisappear(animated)
8383

8484
group.stop()
85+
for motion in group.motions {
86+
group.remove(motion)
87+
}
8588
}
8689

87-
deinit {
88-
(view as! ButtonsView).delegate = nil
89-
}
90-
90+
9191

9292

9393

Examples/MotionExamples/Classes/PhysicsMotionViewController.swift

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ public class PhysicsMotionViewController: UIViewController, ButtonsViewDelegate
3838

3939

4040
// setup motion
41-
motion = PhysicsMotion(target: xConstraint, properties: [PropertyData("constant")], velocity: 300.0, friction: 0.72)
42-
.paused({ (motion) in
43-
print("paused!")
44-
})
45-
.resumed({ (motion) in
46-
print("resumed!")
47-
})
48-
.completed({ (motion) in
49-
print("completed!")
50-
})
41+
createMotion()
5142

5243
createdUI = true
5344
}
@@ -69,10 +60,6 @@ public class PhysicsMotionViewController: UIViewController, ButtonsViewDelegate
6960
motion.stop()
7061
}
7162

72-
deinit {
73-
(view as! ButtonsView).delegate = nil
74-
}
75-
7663

7764

7865

@@ -119,6 +106,20 @@ public class PhysicsMotionViewController: UIViewController, ButtonsViewDelegate
119106
}
120107

121108

109+
private func createMotion() {
110+
motion = PhysicsMotion(target: xConstraint, properties: [PropertyData("constant")], velocity: 300.0, friction: 0.72)
111+
.paused({ (motion) in
112+
print("paused!")
113+
})
114+
.resumed({ (motion) in
115+
print("resumed!")
116+
})
117+
.completed({ (motion) in
118+
print("completed!")
119+
})
120+
}
121+
122+
122123
// MARK: - ButtonsViewDelegate methods
123124

124125
func didStart() {

Examples/MotionExamples/Classes/SequenceContiguousViewController.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public class SequenceContiguousViewController: UIViewController, ButtonsViewDele
7373
let group = MotionGroup(motions: [move_right, change_color])
7474
let expand_group = MotionGroup(motions: [expand_width, expand_height, corner_radius])
7575

76-
sequence = MotionSequence(steps: [group, move_down, expand_group], options: [.Reverse])
76+
sequence = MotionSequence(steps: [group, move_down, expand_group], options: [.reverses])
7777
.stepCompleted({ (sequence) in
7878
print("step complete")
7979
})
@@ -101,10 +101,9 @@ public class SequenceContiguousViewController: UIViewController, ButtonsViewDele
101101
super.viewWillDisappear(animated)
102102

103103
sequence.stop()
104-
}
105-
106-
deinit {
107-
(view as! ButtonsView).delegate = nil
104+
for step in sequence.steps {
105+
sequence.remove(step)
106+
}
108107
}
109108

110109

Examples/MotionExamples/Classes/SequenceViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class SequenceViewController: UIViewController, ButtonsViewDelegate {
4040

4141

4242
// setup motion
43-
sequence = MotionSequence(options: [.Reverse])
43+
sequence = MotionSequence(options: [.reverses])
4444
.stepCompleted({ (sequence) in
4545
print("step complete")
4646
})
@@ -59,7 +59,7 @@ public class SequenceViewController: UIViewController, ButtonsViewDelegate {
5959
duration: 0.7,
6060
easing: EasingQuadratic.easeInOut())
6161

62-
let group = MotionGroup(motions: [down, color], options: [.Reverse])
62+
let group = MotionGroup(motions: [down, color], options: [.reverses])
6363

6464
sequence.add(group)
6565
}
@@ -81,11 +81,11 @@ public class SequenceViewController: UIViewController, ButtonsViewDelegate {
8181
super.viewWillDisappear(animated)
8282

8383
sequence.stop()
84+
for step in sequence.steps {
85+
sequence.remove(step)
86+
}
8487
}
8588

86-
deinit {
87-
(view as! ButtonsView).delegate = nil
88-
}
8989

9090

9191

MotionMachine.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'MotionMachine'
3-
s.version = '2.0.0'
3+
s.version = '2.0.1'
44
s.swift_version = '5.0'
55
s.license = { :type => 'MIT' }
66
s.summary = 'An elegant, powerful, and modular animation library for Swift.'

Sources/CATempo.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public class CATempo : Tempo {
4646
*/
4747
public override init() {
4848
super.init()
49-
displayLink = CADisplayLink.init(target: self, selector: #selector(update))
50-
displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode(rawValue: RunLoop.Mode.common.rawValue))
49+
50+
displayLink = CADisplayLink(weakTarget: self, selector: #selector(update))
51+
displayLink?.add(to: RunLoop.main, forMode: .common)
5152
}
5253

5354
deinit {

Sources/Motion.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
235235
// MARK: Motion state properties
236236

237237
/// The target object whose property should be moved.
238-
private(set) public var targetObject: NSObject?
238+
private(set) public weak var targetObject: NSObject?
239239

240240
/// A `MotionState` enum which represents the current state of the motion operation. (read-only)
241241
private(set) public var motionState: MotionState
@@ -336,7 +336,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
336336
public var reversing: Bool = false
337337

338338
/// Provides a delegate for updates to a Moveable object's status, used by `Moveable` collections.
339-
public var updateDelegate: MotionUpdateDelegate?
339+
public weak var updateDelegate: MotionUpdateDelegate?
340340

341341

342342

@@ -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? = .none) {
525+
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = 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? = .none) {
540+
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = 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? = .none) {
555+
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = 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? = .none) {
561+
private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions? = MotionOptions.none) {
562562

563563
var properties = props ?? []
564564

@@ -781,7 +781,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
781781

782782
// determine if target property is a value we can update directly, or if it's an element of a struct we need to replace
783783
property.parentKeyPath = property.path
784-
var keys: [String] = property.path.components(separatedBy: ".")
784+
let keys: [String] = property.path.components(separatedBy: ".")
785785
let key_count = keys.count
786786

787787
if (key_count > 1) {
@@ -1145,7 +1145,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
11451145
let elapsed_time = self.currentTime - startTime
11461146

11471147
for index in 0 ..< properties.count {
1148-
var property = properties[index]
1148+
let property = properties[index]
11491149

11501150
var new_value: Double = 0.0
11511151

0 commit comments

Comments
 (0)