Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit 060c705

Browse files
Migrated the Xcode project to use swift 4.2
1 parent 4a2164a commit 060c705

File tree

7 files changed

+41
-24
lines changed

7 files changed

+41
-24
lines changed

FolioReaderKit.xcodeproj/project.pbxproj

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
1A9590131D397BE900D56699 /* ScrollScrubber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F901D397BE900D56699 /* ScrollScrubber.swift */; };
6161
1A9590151D397C1300D56699 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A9590141D397C1300D56699 /* Images.xcassets */; };
6262
1A9590171D397CAF00D56699 /* FolioReaderKit.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 1A9590161D397CAF00D56699 /* FolioReaderKit.podspec */; };
63+
1AC255CF220217DF00841FA2 /* MediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A41E8902031E22300A8F70C /* MediaType.swift */; };
64+
1AC255D22202191F00841FA2 /* SMSegmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C471D0387F7003B4CCD /* SMSegmentView.swift */; };
65+
1AC255D32202193700841FA2 /* SMSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C461D0387F7003B4CCD /* SMSegment.swift */; };
66+
1AC255D42202195200841FA2 /* HADiscreteSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C441D0387F7003B4CCD /* HADiscreteSlider.swift */; };
67+
1AC255D52202196D00841FA2 /* FolioReaderAddHighlightNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 256AE60A20A1D4DD00EAD746 /* FolioReaderAddHighlightNote.swift */; };
6368
256AE60B20A1D4DD00EAD746 /* FolioReaderAddHighlightNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 256AE60A20A1D4DD00EAD746 /* FolioReaderAddHighlightNote.swift */; };
6469
3A27F08C1FD9BE5800D84A57 /* FolioReaderUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27F08A1FD9BE5800D84A57 /* FolioReaderUserDefaults.swift */; };
6570
3A27F08E1FD9BE5800D84A57 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27F08B1FD9BE5800D84A57 /* Extensions.swift */; };
@@ -105,7 +110,6 @@
105110
B0D69CCA1D0387F7003B4CCD /* SMSegmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C471D0387F7003B4CCD /* SMSegmentView.swift */; };
106111
B0D69CD11D0388EF003B4CCD /* AEXML.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCB1D0388EF003B4CCD /* AEXML.framework */; };
107112
B0D69CD21D0388EF003B4CCD /* FontBlaster.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCC1D0388EF003B4CCD /* FontBlaster.framework */; };
108-
B0D69CD31D0388EF003B4CCD /* JSQWebViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCD1D0388EF003B4CCD /* JSQWebViewController.framework */; };
109113
B0D69CD51D0388EF003B4CCD /* ZFDragableModalTransition.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCF1D0388EF003B4CCD /* ZFDragableModalTransition.framework */; };
110114
B0D69CD61D0388EF003B4CCD /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CD01D0388EF003B4CCD /* ZipArchive.framework */; };
111115
/* End PBXBuildFile section */
@@ -202,7 +206,6 @@
202206
1A65DDCC1DA73F8E0033C277 /* MenuItemKit.framework in Frameworks */,
203207
B0D69CD11D0388EF003B4CCD /* AEXML.framework in Frameworks */,
204208
B0D69CD21D0388EF003B4CCD /* FontBlaster.framework in Frameworks */,
205-
B0D69CD31D0388EF003B4CCD /* JSQWebViewController.framework in Frameworks */,
206209
B0D69CD51D0388EF003B4CCD /* ZFDragableModalTransition.framework in Frameworks */,
207210
B0D69CD61D0388EF003B4CCD /* ZipArchive.framework in Frameworks */,
208211
1A65DDD21DA744190033C277 /* Realm.framework in Frameworks */,
@@ -495,7 +498,7 @@
495498
isa = PBXProject;
496499
attributes = {
497500
LastSwiftUpdateCheck = 0730;
498-
LastUpgradeCheck = 0920;
501+
LastUpgradeCheck = 1010;
499502
ORGANIZATIONNAME = FolioReader;
500503
TargetAttributes = {
501504
B0D6990A1D035FA2003B4CCD = {
@@ -621,6 +624,8 @@
621624
3A27F0BD1FD9C25500D84A57 /* FolioReaderSharingProvider.swift in Sources */,
622625
B0D6991B1D035FA2003B4CCD /* FolioReaderKitTests.swift in Sources */,
623626
3A27F0BF1FD9C25500D84A57 /* FolioReaderWebView.swift in Sources */,
627+
1AC255CF220217DF00841FA2 /* MediaType.swift in Sources */,
628+
1AC255D22202191F00841FA2 /* SMSegmentView.swift in Sources */,
624629
3A27F0BA1FD9C25500D84A57 /* FolioReaderPageIndicator.swift in Sources */,
625630
3A27F0A51FD9C24A00D84A57 /* FRSpine.swift in Sources */,
626631
3A27F0B81FD9C25500D84A57 /* FolioReaderKit.swift in Sources */,
@@ -638,11 +643,14 @@
638643
3A27F0BE1FD9C25500D84A57 /* FolioReaderUserDefaults.swift in Sources */,
639644
3A27F0B91FD9C25500D84A57 /* FolioReaderPage.swift in Sources */,
640645
3A27F09D1FD9C24A00D84A57 /* FRBook.swift in Sources */,
646+
1AC255D42202195200841FA2 /* HADiscreteSlider.swift in Sources */,
641647
3A27F0BB1FD9C25500D84A57 /* FolioReaderPlayerMenu.swift in Sources */,
648+
1AC255D52202196D00841FA2 /* FolioReaderAddHighlightNote.swift in Sources */,
642649
3A27F0C41FD9C25C00D84A57 /* ScrollScrubber.swift in Sources */,
643650
3A27F0C31FD9C25C00D84A57 /* QuoteImage.swift in Sources */,
644651
3A27F0B71FD9C25500D84A57 /* FolioReaderHighlightList.swift in Sources */,
645652
3A27F09E1FD9C24A00D84A57 /* FREpubParser.swift in Sources */,
653+
1AC255D32202193700841FA2 /* SMSegment.swift in Sources */,
646654
3A27F0A21FD9C24A00D84A57 /* FRResources.swift in Sources */,
647655
);
648656
runOnlyForDeploymentPostprocessing = 0;
@@ -671,12 +679,14 @@
671679
CLANG_WARN_BOOL_CONVERSION = YES;
672680
CLANG_WARN_COMMA = YES;
673681
CLANG_WARN_CONSTANT_CONVERSION = YES;
682+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
674683
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
675684
CLANG_WARN_EMPTY_BODY = YES;
676685
CLANG_WARN_ENUM_CONVERSION = YES;
677686
CLANG_WARN_INFINITE_RECURSION = YES;
678687
CLANG_WARN_INT_CONVERSION = YES;
679688
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
689+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
680690
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
681691
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
682692
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -709,7 +719,7 @@
709719
ONLY_ACTIVE_ARCH = YES;
710720
SDKROOT = iphoneos;
711721
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
712-
SWIFT_VERSION = 4.0;
722+
SWIFT_VERSION = 4.2;
713723
TARGETED_DEVICE_FAMILY = "1,2";
714724
VERSIONING_SYSTEM = "apple-generic";
715725
VERSION_INFO_PREFIX = "";
@@ -729,12 +739,14 @@
729739
CLANG_WARN_BOOL_CONVERSION = YES;
730740
CLANG_WARN_COMMA = YES;
731741
CLANG_WARN_CONSTANT_CONVERSION = YES;
742+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
732743
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
733744
CLANG_WARN_EMPTY_BODY = YES;
734745
CLANG_WARN_ENUM_CONVERSION = YES;
735746
CLANG_WARN_INFINITE_RECURSION = YES;
736747
CLANG_WARN_INT_CONVERSION = YES;
737748
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
749+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
738750
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
739751
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
740752
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -760,7 +772,7 @@
760772
MTL_ENABLE_DEBUG_INFO = NO;
761773
SDKROOT = iphoneos;
762774
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
763-
SWIFT_VERSION = 4.0;
775+
SWIFT_VERSION = 4.2;
764776
TARGETED_DEVICE_FAMILY = "1,2";
765777
VALIDATE_PRODUCT = YES;
766778
VERSIONING_SYSTEM = "apple-generic";
@@ -771,6 +783,7 @@
771783
B0D699201D035FA2003B4CCD /* Debug */ = {
772784
isa = XCBuildConfiguration;
773785
buildSettings = {
786+
CODE_SIGN_IDENTITY = "";
774787
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
775788
DEFINES_MODULE = YES;
776789
DEVELOPMENT_TEAM = "";
@@ -783,17 +796,19 @@
783796
);
784797
INFOPLIST_FILE = FolioReaderKit/Info.plist;
785798
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
786-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
799+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
787800
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
788801
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKit;
789802
PRODUCT_NAME = "$(TARGET_NAME)";
790803
SKIP_INSTALL = YES;
804+
SWIFT_VERSION = 4.2;
791805
};
792806
name = Debug;
793807
};
794808
B0D699211D035FA2003B4CCD /* Release */ = {
795809
isa = XCBuildConfiguration;
796810
buildSettings = {
811+
CODE_SIGN_IDENTITY = "";
797812
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
798813
DEFINES_MODULE = YES;
799814
DEVELOPMENT_TEAM = "";
@@ -806,11 +821,12 @@
806821
);
807822
INFOPLIST_FILE = FolioReaderKit/Info.plist;
808823
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
809-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
824+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
810825
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
811826
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKit;
812827
PRODUCT_NAME = "$(TARGET_NAME)";
813828
SKIP_INSTALL = YES;
829+
SWIFT_VERSION = 4.2;
814830
};
815831
name = Release;
816832
};
@@ -827,6 +843,7 @@
827843
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKitTests;
828844
PRODUCT_NAME = "$(TARGET_NAME)";
829845
SWIFT_SWIFT3_OBJC_INFERENCE = On;
846+
SWIFT_VERSION = 4.2;
830847
};
831848
name = Debug;
832849
};
@@ -843,6 +860,7 @@
843860
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKitTests;
844861
PRODUCT_NAME = "$(TARGET_NAME)";
845862
SWIFT_SWIFT3_OBJC_INFERENCE = On;
863+
SWIFT_VERSION = 4.2;
846864
};
847865
name = Release;
848866
};

FolioReaderKit.xcodeproj/xcshareddata/xcschemes/FolioReaderKit.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0920"
3+
LastUpgradeVersion = "1010"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
<TestableReference
@@ -56,7 +55,6 @@
5655
buildConfiguration = "Debug"
5756
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5857
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59-
language = ""
6058
launchStyle = "0"
6159
useCustomWorkingDirectory = "NO"
6260
ignoresPersistentStateOnLaunch = "NO"

Source/FolioReaderAddHighlightNote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FolioReaderAddHighlightNote: UIViewController {
7575

7676
private func prepareScrollView(){
7777
scrollView = UIScrollView()
78-
scrollView.delegate = self as! UIScrollViewDelegate
78+
scrollView.delegate = self as UIScrollViewDelegate
7979
scrollView.contentSize = CGSize.init(width: view.frame.width, height: view.frame.height )
8080
scrollView.bounces = false
8181

Source/FolioReaderCenter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
849849
}
850850

851851
public func getCurrentPageProgress() -> Float {
852-
guard let page = currentPage, let webView = page.webView else { return 0 }
852+
guard let page = currentPage else { return 0 }
853853

854854
let pageSize = self.readerConfig.isDirection(pageHeight, self.pageWidth, pageHeight)
855855
let contentSize = page.webView?.scrollView.contentSize.forDirection(withConfiguration: self.readerConfig) ?? 0

Source/FolioReaderHighlightList.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class FolioReaderHighlightList: UITableViewController {
7171
dateLabel.font = UIFont(name: "Avenir-Medium", size: 12)
7272
cell.contentView.addSubview(dateLabel)
7373
} else {
74-
dateLabel = cell.contentView.viewWithTag(456) as! UILabel
74+
dateLabel = cell.contentView.viewWithTag(456) as? UILabel
7575
}
7676

7777
dateLabel.text = dateString.uppercased()
@@ -108,7 +108,7 @@ class FolioReaderHighlightList: UITableViewController {
108108
highlightLabel.textColor = UIColor.black
109109
cell.contentView.addSubview(highlightLabel)
110110
} else {
111-
highlightLabel = cell.contentView.viewWithTag(123) as! UILabel
111+
highlightLabel = cell.contentView.viewWithTag(123) as? UILabel
112112
}
113113

114114
highlightLabel.attributedText = text
@@ -127,7 +127,7 @@ class FolioReaderHighlightList: UITableViewController {
127127
noteLabel.textColor = UIColor.gray
128128
cell.contentView.addSubview(noteLabel)
129129
} else {
130-
noteLabel = cell.contentView.viewWithTag(789) as! UILabel
130+
noteLabel = cell.contentView.viewWithTag(789) as? UILabel
131131
}
132132

133133
noteLabel.text = note

Source/FolioReaderWebView.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ open class FolioReaderWebView: UIWebView {
173173
do {
174174
let json = try JSONSerialization.jsonObject(with: jsonData!, options: []) as! NSArray
175175
let dic = json.firstObject as! [String: String]
176-
let rect = NSCoder.cgRect(for: dic["rect"]!)
177176
guard let startOffset = dic["startOffset"] else { return }
178177
guard let endOffset = dic["endOffset"] else { return }
179178

@@ -194,10 +193,9 @@ open class FolioReaderWebView: UIWebView {
194193
}
195194

196195
@objc func updateHighlightNote (_ sender: UIMenuController?) {
197-
if let highlightId = js("getHighlightId()") {
198-
let highlightNote = Highlight.getById(withConfiguration: readerConfig, highlightId: highlightId)
199-
self.folioReader.readerCenter?.presentAddHighlightNote(highlightNote, edit: true)
200-
}
196+
guard let highlightId = js("getHighlightId()") else { return }
197+
guard let highlightNote = Highlight.getById(withConfiguration: readerConfig, highlightId: highlightId) else { return }
198+
self.folioReader.readerCenter?.presentAddHighlightNote(highlightNote, edit: true)
201199
}
202200

203201
@objc func define(_ sender: UIMenuController?) {

Source/Models/Highlight+Helper.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright (c) 2015 Folio Reader. All rights reserved.
77
//
88

9-
import Foundation
9+
import UIKit
1010
import RealmSwift
1111

1212
/**
@@ -141,16 +141,19 @@ extension Highlight {
141141
/// - highlightId: The ID to be removed
142142
/// - page: Page number
143143
/// - Returns: Return a Highlight
144-
public static func getById(withConfiguration readerConfig: FolioReaderConfig, highlightId: String) -> Highlight {
144+
public static func getById(withConfiguration readerConfig: FolioReaderConfig, highlightId: String) -> Highlight? {
145145
var highlight: Highlight?
146146
let predicate = NSPredicate(format:"highlightId = %@", highlightId)
147+
147148
do {
148-
let realm = try! Realm(configuration: readerConfig.realmConfiguration)
149+
let realm = try Realm(configuration: readerConfig.realmConfiguration)
149150
highlight = realm.objects(Highlight.self).filter(predicate).toArray(Highlight.self).first
150-
return highlight!
151+
return highlight
151152
} catch let error as NSError {
152153
print("Error getting Highlight : \(error)")
153154
}
155+
156+
return highlight
154157
}
155158

156159
/// Update a Highlight by ID

0 commit comments

Comments
 (0)