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

Commit

Permalink
Migrated the Xcode project to use swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hebertialmeida committed Jan 30, 2019
1 parent 4a2164a commit 060c705
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
32 changes: 25 additions & 7 deletions FolioReaderKit.xcodeproj/project.pbxproj
Expand Up @@ -60,6 +60,11 @@
1A9590131D397BE900D56699 /* ScrollScrubber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A958F901D397BE900D56699 /* ScrollScrubber.swift */; };
1A9590151D397C1300D56699 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A9590141D397C1300D56699 /* Images.xcassets */; };
1A9590171D397CAF00D56699 /* FolioReaderKit.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 1A9590161D397CAF00D56699 /* FolioReaderKit.podspec */; };
1AC255CF220217DF00841FA2 /* MediaType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A41E8902031E22300A8F70C /* MediaType.swift */; };
1AC255D22202191F00841FA2 /* SMSegmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C471D0387F7003B4CCD /* SMSegmentView.swift */; };
1AC255D32202193700841FA2 /* SMSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C461D0387F7003B4CCD /* SMSegment.swift */; };
1AC255D42202195200841FA2 /* HADiscreteSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C441D0387F7003B4CCD /* HADiscreteSlider.swift */; };
1AC255D52202196D00841FA2 /* FolioReaderAddHighlightNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 256AE60A20A1D4DD00EAD746 /* FolioReaderAddHighlightNote.swift */; };
256AE60B20A1D4DD00EAD746 /* FolioReaderAddHighlightNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 256AE60A20A1D4DD00EAD746 /* FolioReaderAddHighlightNote.swift */; };
3A27F08C1FD9BE5800D84A57 /* FolioReaderUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27F08A1FD9BE5800D84A57 /* FolioReaderUserDefaults.swift */; };
3A27F08E1FD9BE5800D84A57 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27F08B1FD9BE5800D84A57 /* Extensions.swift */; };
Expand Down Expand Up @@ -105,7 +110,6 @@
B0D69CCA1D0387F7003B4CCD /* SMSegmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D69C471D0387F7003B4CCD /* SMSegmentView.swift */; };
B0D69CD11D0388EF003B4CCD /* AEXML.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCB1D0388EF003B4CCD /* AEXML.framework */; };
B0D69CD21D0388EF003B4CCD /* FontBlaster.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCC1D0388EF003B4CCD /* FontBlaster.framework */; };
B0D69CD31D0388EF003B4CCD /* JSQWebViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCD1D0388EF003B4CCD /* JSQWebViewController.framework */; };
B0D69CD51D0388EF003B4CCD /* ZFDragableModalTransition.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CCF1D0388EF003B4CCD /* ZFDragableModalTransition.framework */; };
B0D69CD61D0388EF003B4CCD /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0D69CD01D0388EF003B4CCD /* ZipArchive.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -202,7 +206,6 @@
1A65DDCC1DA73F8E0033C277 /* MenuItemKit.framework in Frameworks */,
B0D69CD11D0388EF003B4CCD /* AEXML.framework in Frameworks */,
B0D69CD21D0388EF003B4CCD /* FontBlaster.framework in Frameworks */,
B0D69CD31D0388EF003B4CCD /* JSQWebViewController.framework in Frameworks */,
B0D69CD51D0388EF003B4CCD /* ZFDragableModalTransition.framework in Frameworks */,
B0D69CD61D0388EF003B4CCD /* ZipArchive.framework in Frameworks */,
1A65DDD21DA744190033C277 /* Realm.framework in Frameworks */,
Expand Down Expand Up @@ -495,7 +498,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = FolioReader;
TargetAttributes = {
B0D6990A1D035FA2003B4CCD = {
Expand Down Expand Up @@ -621,6 +624,8 @@
3A27F0BD1FD9C25500D84A57 /* FolioReaderSharingProvider.swift in Sources */,
B0D6991B1D035FA2003B4CCD /* FolioReaderKitTests.swift in Sources */,
3A27F0BF1FD9C25500D84A57 /* FolioReaderWebView.swift in Sources */,
1AC255CF220217DF00841FA2 /* MediaType.swift in Sources */,
1AC255D22202191F00841FA2 /* SMSegmentView.swift in Sources */,
3A27F0BA1FD9C25500D84A57 /* FolioReaderPageIndicator.swift in Sources */,
3A27F0A51FD9C24A00D84A57 /* FRSpine.swift in Sources */,
3A27F0B81FD9C25500D84A57 /* FolioReaderKit.swift in Sources */,
Expand All @@ -638,11 +643,14 @@
3A27F0BE1FD9C25500D84A57 /* FolioReaderUserDefaults.swift in Sources */,
3A27F0B91FD9C25500D84A57 /* FolioReaderPage.swift in Sources */,
3A27F09D1FD9C24A00D84A57 /* FRBook.swift in Sources */,
1AC255D42202195200841FA2 /* HADiscreteSlider.swift in Sources */,
3A27F0BB1FD9C25500D84A57 /* FolioReaderPlayerMenu.swift in Sources */,
1AC255D52202196D00841FA2 /* FolioReaderAddHighlightNote.swift in Sources */,
3A27F0C41FD9C25C00D84A57 /* ScrollScrubber.swift in Sources */,
3A27F0C31FD9C25C00D84A57 /* QuoteImage.swift in Sources */,
3A27F0B71FD9C25500D84A57 /* FolioReaderHighlightList.swift in Sources */,
3A27F09E1FD9C24A00D84A57 /* FREpubParser.swift in Sources */,
1AC255D32202193700841FA2 /* SMSegment.swift in Sources */,
3A27F0A21FD9C24A00D84A57 /* FRResources.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -671,12 +679,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -709,7 +719,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -729,12 +739,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -760,7 +772,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -771,6 +783,7 @@
B0D699201D035FA2003B4CCD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
Expand All @@ -783,17 +796,19 @@
);
INFOPLIST_FILE = FolioReaderKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
B0D699211D035FA2003B4CCD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
Expand All @@ -806,11 +821,12 @@
);
INFOPLIST_FILE = FolioReaderKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -827,6 +843,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -843,6 +860,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderAddHighlightNote.swift
Expand Up @@ -75,7 +75,7 @@ class FolioReaderAddHighlightNote: UIViewController {

private func prepareScrollView(){
scrollView = UIScrollView()
scrollView.delegate = self as! UIScrollViewDelegate
scrollView.delegate = self as UIScrollViewDelegate
scrollView.contentSize = CGSize.init(width: view.frame.width, height: view.frame.height )
scrollView.bounces = false

Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderCenter.swift
Expand Up @@ -849,7 +849,7 @@ open class FolioReaderCenter: UIViewController, UICollectionViewDelegate, UIColl
}

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

let pageSize = self.readerConfig.isDirection(pageHeight, self.pageWidth, pageHeight)
let contentSize = page.webView?.scrollView.contentSize.forDirection(withConfiguration: self.readerConfig) ?? 0
Expand Down
6 changes: 3 additions & 3 deletions Source/FolioReaderHighlightList.swift
Expand Up @@ -71,7 +71,7 @@ class FolioReaderHighlightList: UITableViewController {
dateLabel.font = UIFont(name: "Avenir-Medium", size: 12)
cell.contentView.addSubview(dateLabel)
} else {
dateLabel = cell.contentView.viewWithTag(456) as! UILabel
dateLabel = cell.contentView.viewWithTag(456) as? UILabel
}

dateLabel.text = dateString.uppercased()
Expand Down Expand Up @@ -108,7 +108,7 @@ class FolioReaderHighlightList: UITableViewController {
highlightLabel.textColor = UIColor.black
cell.contentView.addSubview(highlightLabel)
} else {
highlightLabel = cell.contentView.viewWithTag(123) as! UILabel
highlightLabel = cell.contentView.viewWithTag(123) as? UILabel
}

highlightLabel.attributedText = text
Expand All @@ -127,7 +127,7 @@ class FolioReaderHighlightList: UITableViewController {
noteLabel.textColor = UIColor.gray
cell.contentView.addSubview(noteLabel)
} else {
noteLabel = cell.contentView.viewWithTag(789) as! UILabel
noteLabel = cell.contentView.viewWithTag(789) as? UILabel
}

noteLabel.text = note
Expand Down
8 changes: 3 additions & 5 deletions Source/FolioReaderWebView.swift
Expand Up @@ -173,7 +173,6 @@ open class FolioReaderWebView: UIWebView {
do {
let json = try JSONSerialization.jsonObject(with: jsonData!, options: []) as! NSArray
let dic = json.firstObject as! [String: String]
let rect = NSCoder.cgRect(for: dic["rect"]!)
guard let startOffset = dic["startOffset"] else { return }
guard let endOffset = dic["endOffset"] else { return }

Expand All @@ -194,10 +193,9 @@ open class FolioReaderWebView: UIWebView {
}

@objc func updateHighlightNote (_ sender: UIMenuController?) {
if let highlightId = js("getHighlightId()") {
let highlightNote = Highlight.getById(withConfiguration: readerConfig, highlightId: highlightId)
self.folioReader.readerCenter?.presentAddHighlightNote(highlightNote, edit: true)
}
guard let highlightId = js("getHighlightId()") else { return }
guard let highlightNote = Highlight.getById(withConfiguration: readerConfig, highlightId: highlightId) else { return }
self.folioReader.readerCenter?.presentAddHighlightNote(highlightNote, edit: true)
}

@objc func define(_ sender: UIMenuController?) {
Expand Down
11 changes: 7 additions & 4 deletions Source/Models/Highlight+Helper.swift
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Folio Reader. All rights reserved.
//

import Foundation
import UIKit
import RealmSwift

/**
Expand Down Expand Up @@ -141,16 +141,19 @@ extension Highlight {
/// - highlightId: The ID to be removed
/// - page: Page number
/// - Returns: Return a Highlight
public static func getById(withConfiguration readerConfig: FolioReaderConfig, highlightId: String) -> Highlight {
public static func getById(withConfiguration readerConfig: FolioReaderConfig, highlightId: String) -> Highlight? {
var highlight: Highlight?
let predicate = NSPredicate(format:"highlightId = %@", highlightId)

do {
let realm = try! Realm(configuration: readerConfig.realmConfiguration)
let realm = try Realm(configuration: readerConfig.realmConfiguration)
highlight = realm.objects(Highlight.self).filter(predicate).toArray(Highlight.self).first
return highlight!
return highlight
} catch let error as NSError {
print("Error getting Highlight : \(error)")
}

return highlight
}

/// Update a Highlight by ID
Expand Down

0 comments on commit 060c705

Please sign in to comment.