Skip to content

Commit

Permalink
Update Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
cemolcay committed Apr 30, 2019
1 parent 3e44614 commit 790724c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 24 deletions.
22 changes: 10 additions & 12 deletions MusicTheory.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = cemolcay;
TargetAttributes = {
B219CC011E4CFB870060A6B6 = {
Expand All @@ -343,20 +343,20 @@
B219CC281E4CFBAF0060A6B6 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 77Y3N48SNF;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
B23E8EBB1F1C2BAE0094D316 = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = 77Y3N48SNF;
LastSwiftMigration = 0940;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = B22DCF3B1E1590E7006D561E /* Build configuration list for PBXProject "MusicTheory" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -670,8 +670,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VALID_ARCHS = x86_64;
};
name = Debug;
Expand All @@ -696,8 +695,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VALID_ARCHS = x86_64;
};
name = Release;
Expand All @@ -706,6 +704,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 @@ -771,6 +770,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 @@ -838,8 +838,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.cemolcay.MusicTheoryTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -856,8 +855,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.cemolcay.MusicTheoryTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions MusicTheorySwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "MusicTheorySwift"
s.version = "1.2.1"
s.version = "1.2.2"
s.summary = "A music theory library with `Note`, `Interval`, `Tone`, `Scale` and `Chord` representations in swift enums."

# This description is used to generate tags and improve search results.
Expand All @@ -32,7 +32,7 @@ A music theory library with `Key`, `Pitch`, `Interval`, `Scale` and `Chord` repr
Requirements
----
* Swift 4.0+
* Swift 5.0+
* iOS 8.0+
* macOS 10.9+
* tvOS 9.0+
Expand Down
6 changes: 3 additions & 3 deletions Source/Key.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public struct Key: Codable, Equatable, Hashable, ExpressibleByStringLiteral, Cus
/// - Parameter distance: Target KeyType distance. Zero is self.
/// - Returns: Returns the neighbouring KeyType distance away.
public func key(at distance: Int) -> KeyType {
guard let index = KeyType.all.index(of: self)
guard let index = KeyType.all.firstIndex(of: self)
else { return self }

let normalizedDistance = (distance + index) % KeyType.all.count
Expand All @@ -78,8 +78,8 @@ public struct Key: Codable, Equatable, Hashable, ExpressibleByStringLiteral, Cus
/// - Parameter keyType: Target `KeyType` you want to compare.
/// - Returns: Returns the integer value of distance in terms of their array index values.
public func distance(from keyType: KeyType) -> Int {
guard let index = KeyType.all.index(of: self),
let targetIndex = KeyType.all.index(of: keyType)
guard let index = KeyType.all.firstIndex(of: self),
let targetIndex = KeyType.all.firstIndex(of: keyType)
else { return 0 }
return targetIndex - index
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Pitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public func - (lhs: Pitch, rhs: Pitch) -> Interval {
let bottom = min(lhs, rhs)
let diff = top.rawValue - bottom.rawValue

let bottomKeyIndex = Key.KeyType.all.index(of: bottom.key.type) ?? 0
let topKeyIndex = Key.KeyType.all.index(of: top.key.type) ?? 0
let bottomKeyIndex = Key.KeyType.all.firstIndex(of: bottom.key.type) ?? 0
let topKeyIndex = Key.KeyType.all.firstIndex(of: top.key.type) ?? 0
let degree = abs(topKeyIndex - bottomKeyIndex) + 1
let isMajor = (degree == 2 || degree == 3 || degree == 6 || degree == 7)

Expand Down

0 comments on commit 790724c

Please sign in to comment.