Skip to content

Commit 9ea62f4

Browse files
committed
Updates to fix compiler warnings and deprecations.
1 parent 0b481d8 commit 9ea62f4

File tree

9 files changed

+29
-15
lines changed

9 files changed

+29
-15
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 1.1.1
2+
Fixes for compiler warnings and deprecations.
3+
14
#### 1.1.0
25
Support for Swift 3.0.
36

Classes/EasingTypes/EasingElastic.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import Foundation
3131
*/
3232
public struct EasingElastic {
3333

34-
static let M_PI2 = M_PI * 2
34+
static let M_PI2 = Double.pi * 2
3535

3636
public static func easeIn() -> EasingUpdateClosure {
3737

Classes/EasingTypes/EasingSine.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public struct EasingSine {
3434
public static func easeIn() -> EasingUpdateClosure {
3535

3636
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
37-
let easing_value = -valueRange * cos((elapsedTime / duration) * M_PI_2) + valueRange + startValue
37+
let easing_value = -valueRange * cos((elapsedTime / duration) * MotionUtils.MM_PI_2) + valueRange + startValue
3838

3939
return easing_value
4040
}
@@ -45,7 +45,7 @@ public struct EasingSine {
4545
public static func easeOut() -> EasingUpdateClosure {
4646

4747
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
48-
let easing_value = valueRange * sin((elapsedTime / duration) * M_PI_2) + startValue
48+
let easing_value = valueRange * sin((elapsedTime / duration) * MotionUtils.MM_PI_2) + startValue
4949

5050
return easing_value
5151
}
@@ -56,7 +56,7 @@ public struct EasingSine {
5656
public static func easeInOut() -> EasingUpdateClosure {
5757

5858
func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
59-
var easing_value = (-valueRange * 0.5) * (cos(M_PI * (elapsedTime / duration)) - 1)
59+
var easing_value = (-valueRange * 0.5) * (cos(Double.pi * (elapsedTime / duration)) - 1)
6060
easing_value += startValue
6161

6262
return easing_value

Classes/MotionGroup.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ public class MotionGroup: Moveable, MoveableCollection, TempoDriven, MotionUpdat
520520
tempoOverrides.append(!useChildTempo) // use the opposite Boolean value in order to represent which tempos should be overriden by the group
521521

522522
// subscribe to this motion's status updates
523-
motion.updateDelegate = (self as? MotionUpdateDelegate)
523+
motion.updateDelegate = self
524524

525525

526526
return self

Classes/MotionMachine.swift

+12-6
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,12 @@ public struct MotionOptions : OptionSet {
523523
/// Represents an infinite number of repeat motion cycles.
524524
public let REPEAT_INFINITE: UInt = 0
525525

526+
/// Utility methods
527+
public struct MotionUtils {
528+
529+
static let MM_PI_2 = Double.pi / 2
530+
531+
}
526532

527533

528534
// MARK: - Utility extensions
@@ -549,13 +555,13 @@ func ≈≈ (a: Float, b: Float) -> Bool {
549555
let fabs_b = fabs(b)
550556
let diff = fabs(fabs_a - fabs_b)
551557

552-
if (a == 0.0 || b == 0.0 || diff < FLT_MIN) {
558+
if (a == 0.0 || b == 0.0 || diff < Float.leastNormalMagnitude) {
553559
// a or b is zero or both are extremely close to it
554560
// relative error is less meaningful here
555-
return diff < (FLT_EPSILON * FLT_MIN)
561+
return diff < (Float.ulpOfOne * Float.leastNormalMagnitude)
556562
} else {
557563

558-
return (diff / (fabs_a + fabs_b)) < FLT_EPSILON
564+
return (diff / (fabs_a + fabs_b)) < Float.ulpOfOne
559565
}
560566
}
561567

@@ -569,12 +575,12 @@ func ≈≈ (a: Double, b: Double) -> Bool {
569575
let fabs_b = fabs(b)
570576
let diff = fabs(fabs_a - fabs_b)
571577

572-
if (a == 0.0 || b == 0.0 || diff < DBL_MIN) {
578+
if (a == 0.0 || b == 0.0 || diff < Double.leastNormalMagnitude) {
573579
// a or b is zero or both are extremely close to it
574580
// relative error is less meaningful here
575-
return diff < (DBL_EPSILON * DBL_MIN)
581+
return diff < (Double.ulpOfOne * Double.leastNormalMagnitude)
576582
} else {
577-
return (diff / (fabs_a + fabs_b)) < DBL_EPSILON
583+
return (diff / (fabs_a + fabs_b)) < Double.ulpOfOne
578584
}
579585

580586
}

Classes/MotionSequence.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public class MotionSequence: Moveable, MoveableCollection, TempoDriven, MotionUp
539539
tempoOverrides.append(!useChildTempo) // use the opposite Boolean value in order to represent which tempos should be overriden by the sequence
540540

541541
// subscribe to this motion's status updates
542-
sequenceStep.updateDelegate = (self as? MotionUpdateDelegate)
542+
sequenceStep.updateDelegate = self
543543

544544

545545
return self

Classes/PhysicsMotion.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
11881188
}
11891189

11901190
if (no_delay_set) {
1191-
operationID = MotionSupport.register(additiveMotion: self as! Additive)
1191+
operationID = MotionSupport.register(additiveMotion: self as Additive)
11921192
}
11931193
}
11941194
}

Examples/MotionExamples.xcodeproj/project.pbxproj

+6-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
isa = PBXProject;
228228
attributes = {
229229
LastSwiftUpdateCheck = 0730;
230-
LastUpgradeCheck = 0730;
230+
LastUpgradeCheck = 0830;
231231
ORGANIZATIONNAME = "Poet & Mountain, LLC";
232232
TargetAttributes = {
233233
8BB379D31CFFA17D00A35AFD = {
@@ -340,8 +340,10 @@
340340
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
341341
CLANG_WARN_EMPTY_BODY = YES;
342342
CLANG_WARN_ENUM_CONVERSION = YES;
343+
CLANG_WARN_INFINITE_RECURSION = YES;
343344
CLANG_WARN_INT_CONVERSION = YES;
344345
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
346+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
345347
CLANG_WARN_UNREACHABLE_CODE = YES;
346348
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
347349
CODE_SIGN_IDENTITY = "iPhone Developer";
@@ -386,8 +388,10 @@
386388
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
387389
CLANG_WARN_EMPTY_BODY = YES;
388390
CLANG_WARN_ENUM_CONVERSION = YES;
391+
CLANG_WARN_INFINITE_RECURSION = YES;
389392
CLANG_WARN_INT_CONVERSION = YES;
390393
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
394+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
391395
CLANG_WARN_UNREACHABLE_CODE = YES;
392396
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
393397
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -406,6 +410,7 @@
406410
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
407411
MTL_ENABLE_DEBUG_INFO = NO;
408412
SDKROOT = iphoneos;
413+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
409414
VALIDATE_PRODUCT = YES;
410415
};
411416
name = Release;

MotionMachine.podspec

+1-1
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 = '1.1.0'
3+
s.version = '1.1.1'
44
s.license = { :type => 'MIT' }
55
s.summary = 'An elegant, powerful, and modular animation library for Swift.'
66
s.description = <<-DESC

0 commit comments

Comments
 (0)