mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-26 21:39:37 -04:00
swift 2.3 migrate
This commit is contained in:
parent
eda4a0ef18
commit
1ae7813b88
@ -70,7 +70,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
}
|
||||
|
||||
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
|
||||
guard url.scheme.caseInsensitiveCompare("kiwix") == .OrderedSame else {return false}
|
||||
guard url.scheme!.caseInsensitiveCompare("kiwix") == .OrderedSame else {return false}
|
||||
mainController?.load(url)
|
||||
return true
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ class BookmarkControllerAnimator: NSObject, UIViewControllerAnimatedTransitionin
|
||||
}
|
||||
|
||||
private func animateInTransition(transitionContext: UIViewControllerContextTransitioning) {
|
||||
guard let containerView = transitionContext.containerView(),
|
||||
let toController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as? BookmarkController,
|
||||
let containerView = transitionContext.containerView()
|
||||
guard let toController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as? BookmarkController,
|
||||
let toView = transitionContext.viewForKey(UITransitionContextToViewKey) else {return}
|
||||
let duration = transitionDuration(transitionContext)
|
||||
|
||||
@ -54,8 +54,8 @@ class BookmarkControllerAnimator: NSObject, UIViewControllerAnimatedTransitionin
|
||||
}
|
||||
|
||||
private func animateOutTransition(transitionContext: UIViewControllerContextTransitioning) {
|
||||
guard let containerView = transitionContext.containerView(),
|
||||
let fromController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as? BookmarkController,
|
||||
let containerView = transitionContext.containerView()
|
||||
guard let fromController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as? BookmarkController,
|
||||
let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey) else {return}
|
||||
let duration = transitionDuration(transitionContext)
|
||||
|
||||
|
@ -190,7 +190,7 @@ class LibraryLocalTBVC: UITableViewController, NSFetchedResultsControllerDelegat
|
||||
FileManager.removeItem(atURL: zimURL)
|
||||
|
||||
let indexFolderURL = zimURL.URLByAppendingPathExtension("idx")
|
||||
FileManager.removeItem(atURL: indexFolderURL)
|
||||
FileManager.removeItem(atURL: indexFolderURL!)
|
||||
}
|
||||
|
||||
if let _ = book.url {
|
||||
|
@ -112,7 +112,7 @@ extension MainController: LPTBarButtonItemDelegate, TableOfContentsDelegate, Zim
|
||||
|
||||
func webViewDidFinishLoad(webView: UIWebView) {
|
||||
guard let url = webView.request?.URL else {return}
|
||||
guard url.scheme.caseInsensitiveCompare("Kiwix") == .OrderedSame else {return}
|
||||
guard url.scheme!.caseInsensitiveCompare("Kiwix") == .OrderedSame else {return}
|
||||
|
||||
let title = webView.stringByEvaluatingJavaScriptFromString("document.title")
|
||||
let managedObjectContext = UIApplication.appDelegate.managedObjectContext
|
||||
@ -293,4 +293,4 @@ class HTMLHeading {
|
||||
var scrollToJavaScript: String {
|
||||
return "document.getElementById('\(id)').scrollIntoView();"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.984</string>
|
||||
<string>1.7.987</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -1,57 +0,0 @@
|
||||
//
|
||||
// KiwixUITests.swift
|
||||
// KiwixUITests
|
||||
//
|
||||
// Created by Chris on 12/11/15.
|
||||
// Copyright © 2015 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SnapshotAutomation: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
continueAfterFailure = false
|
||||
XCUIApplication().launch()
|
||||
|
||||
let app = XCUIApplication()
|
||||
if app.alerts.count > 0 {
|
||||
app.alerts["Welcome to Kiwix"].collectionViews.buttons["Dismiss"].tap()
|
||||
}
|
||||
|
||||
snapshot("01WelcomeScreen")
|
||||
|
||||
if app.toolbars.buttons["Library"].exists {
|
||||
// iPhone
|
||||
app.toolbars.buttons["Library"].tap()
|
||||
sleep(4)
|
||||
if app.alerts.count > 0 {
|
||||
app.alerts["Only Show Preferred Language?"].collectionViews.buttons["OK"].tap()
|
||||
}
|
||||
snapshot("02LibraryScreen")
|
||||
} else {
|
||||
// iPad
|
||||
app.navigationBars["Kiwix.MainController"].childrenMatchingType(.Button).elementBoundByIndex(4).tap()
|
||||
sleep(4)
|
||||
if app.alerts.count > 0 {
|
||||
app.alerts["Only Show Preferred Language?"].collectionViews.buttons["OK"].tap()
|
||||
}
|
||||
snapshot("02LibraryScreen")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// Use recording to get started writing UI tests.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
//
|
||||
// SnapshotHelper.swift
|
||||
// Example
|
||||
//
|
||||
// Created by Felix Krause on 10/8/15.
|
||||
// Copyright © 2015 Felix Krause. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
var deviceLanguage = ""
|
||||
var locale = ""
|
||||
|
||||
@available(*, deprecated, message="use setupSnapshot: instead")
|
||||
func setLanguage(app: XCUIApplication) {
|
||||
setupSnapshot(app)
|
||||
}
|
||||
|
||||
func setupSnapshot(app: XCUIApplication) {
|
||||
Snapshot.setupSnapshot(app)
|
||||
}
|
||||
|
||||
func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
|
||||
Snapshot.snapshot(name, waitForLoadingIndicator: waitForLoadingIndicator)
|
||||
}
|
||||
|
||||
public class Snapshot: NSObject {
|
||||
|
||||
public class func setupSnapshot(app: XCUIApplication) {
|
||||
setLanguage(app)
|
||||
setLocale(app)
|
||||
setLaunchArguments(app)
|
||||
}
|
||||
|
||||
class func setLanguage(app: XCUIApplication) {
|
||||
guard let prefix = pathPrefix() else {
|
||||
return
|
||||
}
|
||||
|
||||
let path = prefix.stringByAppendingPathComponent("language.txt")
|
||||
|
||||
do {
|
||||
let trimCharacterSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()
|
||||
deviceLanguage = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding).stringByTrimmingCharactersInSet(trimCharacterSet) as String
|
||||
app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))"]
|
||||
} catch {
|
||||
print("Couldn't detect/set language...")
|
||||
}
|
||||
}
|
||||
|
||||
class func setLocale(app: XCUIApplication) {
|
||||
guard let prefix = pathPrefix() else {
|
||||
return
|
||||
}
|
||||
|
||||
let path = prefix.stringByAppendingPathComponent("locale.txt")
|
||||
|
||||
do {
|
||||
let trimCharacterSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()
|
||||
locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding).stringByTrimmingCharactersInSet(trimCharacterSet) as String
|
||||
} catch {
|
||||
print("Couldn't detect/set locale...")
|
||||
}
|
||||
if locale.isEmpty {
|
||||
locale = NSLocale(localeIdentifier: deviceLanguage).localeIdentifier
|
||||
}
|
||||
app.launchArguments += ["-AppleLocale", "\"\(locale)\""]
|
||||
}
|
||||
|
||||
class func setLaunchArguments(app: XCUIApplication) {
|
||||
guard let prefix = pathPrefix() else {
|
||||
return
|
||||
}
|
||||
|
||||
let path = prefix.stringByAppendingPathComponent("snapshot-launch_arguments.txt")
|
||||
app.launchArguments += ["-FASTLANE_SNAPSHOT", "YES", "-ui_testing"]
|
||||
|
||||
do {
|
||||
let launchArguments = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String
|
||||
let regex = try NSRegularExpression(pattern: "(\\\".+?\\\"|\\S+)", options: [])
|
||||
let matches = regex.matchesInString(launchArguments, options: [], range: NSRange(location:0, length:launchArguments.characters.count))
|
||||
let results = matches.map { result -> String in
|
||||
(launchArguments as NSString).substringWithRange(result.range)
|
||||
}
|
||||
app.launchArguments += results
|
||||
} catch {
|
||||
print("Couldn't detect/set launch_arguments...")
|
||||
}
|
||||
}
|
||||
|
||||
public class func snapshot(name: String, waitForLoadingIndicator: Bool = true) {
|
||||
if waitForLoadingIndicator {
|
||||
waitForLoadingIndicatorToDisappear()
|
||||
}
|
||||
|
||||
print("snapshot: \(name)") // more information about this, check out https://github.com/fastlane/snapshot
|
||||
|
||||
sleep(1) // Waiting for the animation to be finished (kind of)
|
||||
XCUIDevice.sharedDevice().orientation = .Unknown
|
||||
}
|
||||
|
||||
class func waitForLoadingIndicatorToDisappear() {
|
||||
let query = XCUIApplication().statusBars.childrenMatchingType(.Other).elementBoundByIndex(1).childrenMatchingType(.Other)
|
||||
|
||||
while (0..<query.count).map({ query.elementBoundByIndex($0) }).contains({ $0.isLoadingIndicator }) {
|
||||
sleep(1)
|
||||
print("Waiting for loading indicator to disappear...")
|
||||
}
|
||||
}
|
||||
|
||||
class func pathPrefix() -> NSString? {
|
||||
if let path = NSProcessInfo().environment["SIMULATOR_HOST_HOME"] as NSString? {
|
||||
return path.stringByAppendingPathComponent("Library/Caches/tools.fastlane")
|
||||
}
|
||||
print("Couldn't find Snapshot configuration files at ~/Library/Caches/tools.fastlane")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension XCUIElement {
|
||||
var isLoadingIndicator: Bool {
|
||||
return self.frame.size == CGSize(width: 10, height: 20)
|
||||
}
|
||||
}
|
||||
|
||||
// Please don't remove the lines below
|
||||
// They are used to detect outdated configuration files
|
||||
// SnapshotHelperVersion [1.2]
|
@ -21,7 +21,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.1069</string>
|
||||
<string>1.7.1075</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
|
@ -101,7 +101,6 @@
|
||||
973BCD011CEB3FA500F10B44 /* Kiwix_OSXTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCD001CEB3FA500F10B44 /* Kiwix_OSXTests.swift */; };
|
||||
973BCD0C1CEB3FA500F10B44 /* Kiwix_OSXUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCD0B1CEB3FA500F10B44 /* Kiwix_OSXUITests.swift */; };
|
||||
973BCD1A1CEB402900F10B44 /* KiwixTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCD181CEB402900F10B44 /* KiwixTests.swift */; };
|
||||
973BCD1E1CEB403700F10B44 /* SnapshotAutomation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973BCD1C1CEB403700F10B44 /* SnapshotAutomation.swift */; };
|
||||
973C8D5C1C25F945007272F9 /* Preference.swift in Sources */ = {isa = PBXBuildFile; fileRef = 973C8D5B1C25F945007272F9 /* Preference.swift */; };
|
||||
973DD40F1D343F2F009D45DB /* libicudata.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4041D343F2F009D45DB /* libicudata.a */; };
|
||||
973DD4101D343F2F009D45DB /* libicui18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 973DD4051D343F2F009D45DB /* libicui18n.a */; };
|
||||
@ -143,7 +142,6 @@
|
||||
975334CB1CEB6A43007ED50B /* Preference.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 975334CA1CEB6A43007ED50B /* Preference.storyboard */; };
|
||||
975334D01CEB6AE3007ED50B /* PreferenceGeneralController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 975334CF1CEB6AE3007ED50B /* PreferenceGeneralController.swift */; };
|
||||
975334D21CEB6B01007ED50B /* LibraryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 975334D11CEB6B01007ED50B /* LibraryController.swift */; };
|
||||
97587A961D1061C0006EE1AA /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97587A951D1061C0006EE1AA /* SnapshotHelper.swift */; };
|
||||
975B90F91CEB75CB00D13906 /* ZimFilesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 975B90F81CEB75CB00D13906 /* ZimFilesController.swift */; };
|
||||
975B90FE1CEB909100D13906 /* iOSExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 975B90FD1CEB909100D13906 /* iOSExtensions.swift */; };
|
||||
975B90FF1CEB909900D13906 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779987A1C1E1C9600B1DD5E /* Extensions.swift */; };
|
||||
@ -354,7 +352,6 @@
|
||||
973BCD171CEB402900F10B44 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Kiwix-iOSTests/Info.plist"; sourceTree = SOURCE_ROOT; };
|
||||
973BCD181CEB402900F10B44 /* KiwixTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = KiwixTests.swift; path = "Kiwix-iOSTests/KiwixTests.swift"; sourceTree = SOURCE_ROOT; };
|
||||
973BCD1B1CEB403700F10B44 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Kiwix-iOSUITests/Info.plist"; sourceTree = SOURCE_ROOT; };
|
||||
973BCD1C1CEB403700F10B44 /* SnapshotAutomation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotAutomation.swift; path = "Kiwix-iOSUITests/SnapshotAutomation.swift"; sourceTree = SOURCE_ROOT; };
|
||||
973C8D5B1C25F945007272F9 /* Preference.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Preference.swift; path = Kiwix/Preference.swift; sourceTree = "<group>"; };
|
||||
973DD4041D343F2F009D45DB /* libicudata.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicudata.a; path = Kiwix/libkiwix/iOS/libicudata.a; sourceTree = "<group>"; };
|
||||
973DD4051D343F2F009D45DB /* libicui18n.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicui18n.a; path = Kiwix/libkiwix/iOS/libicui18n.a; sourceTree = "<group>"; };
|
||||
@ -396,7 +393,6 @@
|
||||
975334CA1CEB6A43007ED50B /* Preference.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Preference.storyboard; path = "Kiwix-OSX/StoryBoards/Preference.storyboard"; sourceTree = SOURCE_ROOT; };
|
||||
975334CF1CEB6AE3007ED50B /* PreferenceGeneralController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PreferenceGeneralController.swift; path = "Kiwix-OSX/Controllers/PreferenceGeneralController.swift"; sourceTree = SOURCE_ROOT; };
|
||||
975334D11CEB6B01007ED50B /* LibraryController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibraryController.swift; path = "Kiwix-OSX/Controllers/LibraryController.swift"; sourceTree = SOURCE_ROOT; };
|
||||
97587A951D1061C0006EE1AA /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotHelper.swift; path = "Kiwix-iOSUITests/SnapshotHelper.swift"; sourceTree = SOURCE_ROOT; };
|
||||
975B90F81CEB75CB00D13906 /* ZimFilesController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ZimFilesController.swift; path = "Kiwix-OSX/Controllers/ZimFilesController.swift"; sourceTree = SOURCE_ROOT; };
|
||||
975B90FD1CEB909100D13906 /* iOSExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iOSExtensions.swift; path = "Kiwix-iOS/iOSExtensions.swift"; sourceTree = SOURCE_ROOT; };
|
||||
9763275D1D64FE0F0034F120 /* BookDetailController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookDetailController.swift; sourceTree = "<group>"; };
|
||||
@ -1041,8 +1037,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
973BCD1B1CEB403700F10B44 /* Info.plist */,
|
||||
973BCD1C1CEB403700F10B44 /* SnapshotAutomation.swift */,
|
||||
97587A951D1061C0006EE1AA /* SnapshotHelper.swift */,
|
||||
);
|
||||
name = "Kiwix-iOSUITests";
|
||||
path = KiwixUITests;
|
||||
@ -1305,6 +1299,7 @@
|
||||
9779C3121D4575AD0064CC8E = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
DevelopmentTeam = L7HWM3SP3L;
|
||||
LastSwiftMigration = 0800;
|
||||
SystemCapabilities = {
|
||||
com.apple.ApplicationGroups.iOS = {
|
||||
enabled = 1;
|
||||
@ -1314,6 +1309,7 @@
|
||||
97A2AB871C1B80FF00052E74 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
DevelopmentTeam = L7HWM3SP3L;
|
||||
LastSwiftMigration = 0800;
|
||||
SystemCapabilities = {
|
||||
com.apple.ApplicationGroups.iOS = {
|
||||
enabled = 1;
|
||||
@ -1328,10 +1324,12 @@
|
||||
};
|
||||
97A2AB9E1C1B80FF00052E74 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
TestTargetID = 97A2AB871C1B80FF00052E74;
|
||||
};
|
||||
97A2ABA91C1B810000052E74 = {
|
||||
CreatedOnToolsVersion = 7.2;
|
||||
LastSwiftMigration = 0800;
|
||||
TestTargetID = 97A2AB871C1B80FF00052E74;
|
||||
};
|
||||
};
|
||||
@ -1735,8 +1733,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
973BCD1E1CEB403700F10B44 /* SnapshotAutomation.swift in Sources */,
|
||||
97587A961D1061C0006EE1AA /* SnapshotHelper.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -1931,6 +1927,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.Kiwix.Bookmarks;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -1947,6 +1944,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.Kiwix.Bookmarks;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@ -2066,6 +2064,7 @@
|
||||
PROVISIONING_PROFILE = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Kiwix/Kiwix-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -2102,6 +2101,7 @@
|
||||
PROVISIONING_PROFILE = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Kiwix/Kiwix-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 2.3;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@ -2115,6 +2115,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.KiwixTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 2.3;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Kiwix.app/Kiwix";
|
||||
};
|
||||
name = Debug;
|
||||
@ -2128,6 +2129,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.KiwixTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 2.3;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Kiwix.app/Kiwix";
|
||||
};
|
||||
name = Release;
|
||||
@ -2142,6 +2144,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 2.3;
|
||||
TEST_TARGET_NAME = "Kiwix-iOS";
|
||||
USES_XCTRUNNER = YES;
|
||||
};
|
||||
@ -2156,6 +2159,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = self.KiwixUITests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
SWIFT_VERSION = 2.3;
|
||||
TEST_TARGET_NAME = "Kiwix-iOS";
|
||||
USES_XCTRUNNER = YES;
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ class Article: NSManagedObject {
|
||||
|
||||
class func addOrUpdate(title: String? = nil, url: NSURL, book: Book, context: NSManagedObjectContext) -> Article? {
|
||||
let fetchRequest = NSFetchRequest(entityName: "Article")
|
||||
fetchRequest.predicate = NSPredicate(format: "urlString = %@", url.absoluteString)
|
||||
fetchRequest.predicate = NSPredicate(format: "urlString = %@", url.absoluteString!)
|
||||
let article = Article.fetch(fetchRequest, type: Article.self, context: context)?.first ?? insert(Article.self, context: context)
|
||||
|
||||
article?.title = title
|
||||
@ -58,7 +58,7 @@ class Article: NSManagedObject {
|
||||
return [
|
||||
"title": title,
|
||||
"thumbImageData": data,
|
||||
"url": url.absoluteString,
|
||||
"url": url.absoluteString!,
|
||||
"isMainPage": NSNumber(bool: isMainPage)
|
||||
]
|
||||
}
|
||||
|
@ -19,21 +19,21 @@ class FileManager {
|
||||
let directory = NSFileManager.docDirURL
|
||||
createDirectory(directory, includeInICloudBackup: false)
|
||||
let destination = directory.URLByAppendingPathComponent(fileName)
|
||||
moveOrReplaceFile(from: fromURL, to: destination)
|
||||
moveOrReplaceFile(from: fromURL, to: destination!)
|
||||
}
|
||||
|
||||
// MARK: - Book Resume Data
|
||||
|
||||
private class func resumeDataURL(book: Book) -> NSURL {
|
||||
let tempDownloadLocation = NSURL(fileURLWithPath: NSFileManager.libDirURL.path!).URLByAppendingPathComponent("DownloadTemp", isDirectory: true)
|
||||
return tempDownloadLocation.URLByAppendingPathComponent(book.id ?? NSDate().description, isDirectory: false)
|
||||
return tempDownloadLocation!.URLByAppendingPathComponent(book.id ?? NSDate().description, isDirectory: false)!
|
||||
}
|
||||
|
||||
class func saveResumeData(data: NSData, book: Book) {
|
||||
let tempDownloadLocation = NSURL(fileURLWithPath: NSFileManager.libDirURL.path!).URLByAppendingPathComponent("DownloadTemp", isDirectory: true)
|
||||
if !NSFileManager.defaultManager().fileExistsAtPath(tempDownloadLocation.path!) {
|
||||
if !NSFileManager.defaultManager().fileExistsAtPath(tempDownloadLocation!.path!) {
|
||||
do {
|
||||
try NSFileManager.defaultManager().createDirectoryAtURL(tempDownloadLocation, withIntermediateDirectories: true, attributes: [NSURLIsExcludedFromBackupKey: true])
|
||||
try NSFileManager.defaultManager().createDirectoryAtURL(tempDownloadLocation!, withIntermediateDirectories: true, attributes: [NSURLIsExcludedFromBackupKey: true])
|
||||
} catch let error as NSError {
|
||||
print("Create temp download folder failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class ScanLocalBookOperation: Operation {
|
||||
}()
|
||||
book?.isLocal = true
|
||||
book?.hasIndex = reader.hasIndex()
|
||||
book?.hasPic = !reader.fileURL.absoluteString.containsString("nopic")
|
||||
book?.hasPic = !reader.fileURL.absoluteString!.containsString("nopic")
|
||||
}
|
||||
|
||||
for (id, book) in localBooks {
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
class KiwixURLProtocol: NSURLProtocol {
|
||||
override class func canInitWithRequest(request: NSURLRequest) -> Bool {
|
||||
return request.URL?.scheme.caseInsensitiveCompare("Kiwix") == .OrderedSame ? true : false
|
||||
return request.URL?.scheme!.caseInsensitiveCompare("Kiwix") == .OrderedSame ? true : false
|
||||
}
|
||||
|
||||
override class func canonicalRequestForRequest(request: NSURLRequest) -> NSURLRequest {
|
||||
|
@ -157,7 +157,7 @@ class DirectoryMonitor {
|
||||
}
|
||||
|
||||
private func fileSize(fileName: String) -> Int64? {
|
||||
if let path = self.URL.URLByAppendingPathComponent(fileName).path {
|
||||
if let path = self.URL.URLByAppendingPathComponent(fileName)!.path {
|
||||
if NSFileManager.defaultManager().fileExistsAtPath(path) {
|
||||
do {
|
||||
let attributes = try NSFileManager.defaultManager().attributesOfItemAtPath(path)
|
||||
@ -171,4 +171,4 @@ class DirectoryMonitor {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
Podfile
5
Podfile
@ -8,8 +8,7 @@ platform :ios, '9.0'
|
||||
pod 'DateTools'
|
||||
pod 'DZNEmptyDataSet'
|
||||
pod 'SwiftyUserDefaults'
|
||||
pod 'Operations'
|
||||
pod 'Charts'
|
||||
pod 'Operations', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'swift/2.3'
|
||||
|
||||
end
|
||||
|
||||
@ -18,6 +17,6 @@ target 'Kiwix-OSX' do
|
||||
platform :osx, '10.10'
|
||||
|
||||
pod 'DateTools'
|
||||
pod 'Operations'
|
||||
pod 'Operations', :git => 'https://github.com/ProcedureKit/ProcedureKit.git', :branch => 'swift/2.3'
|
||||
|
||||
end
|
||||
|
27
Podfile.lock
27
Podfile.lock
@ -1,28 +1,33 @@
|
||||
PODS:
|
||||
- Charts (2.2.5):
|
||||
- Charts/Core (= 2.2.5)
|
||||
- Charts/Core (2.2.5)
|
||||
- DateTools (1.7.0)
|
||||
- DZNEmptyDataSet (1.8.1)
|
||||
- Operations (3.0.0):
|
||||
- Operations/Standard (= 3.0.0)
|
||||
- Operations/Standard (3.0.0)
|
||||
- Operations (3.3.1):
|
||||
- Operations/Standard (= 3.3.1)
|
||||
- Operations/Standard (3.3.1)
|
||||
- SwiftyUserDefaults (2.2.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Charts
|
||||
- DateTools
|
||||
- DZNEmptyDataSet
|
||||
- Operations
|
||||
- Operations (from `https://github.com/ProcedureKit/ProcedureKit.git`, branch `swift/2.3`)
|
||||
- SwiftyUserDefaults
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Operations:
|
||||
:branch: swift/2.3
|
||||
:git: https://github.com/ProcedureKit/ProcedureKit.git
|
||||
|
||||
CHECKOUT OPTIONS:
|
||||
Operations:
|
||||
:commit: e79d22bc32e2e4faad6cdcde31c71187357b1154
|
||||
:git: https://github.com/ProcedureKit/ProcedureKit.git
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Charts: b48fcc8d7190de910ff9e9748f5360c8ea7856e5
|
||||
DateTools: 53288ee8b905fdc75897a1e6b5cc0144b14cba60
|
||||
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
|
||||
Operations: c05cc4b2ad060201ab98cbacd5217876658b5f2c
|
||||
Operations: 6a33d325dae88de21b8edc69b9884fce01aea22b
|
||||
SwiftyUserDefaults: e7c8197a9d4068702e7f2406a968cae413b8de27
|
||||
|
||||
PODFILE CHECKSUM: 817a8fbec5912cc9123925b4d431b45fcc87901e
|
||||
PODFILE CHECKSUM: dafe7442de9229d78c81ec09646e9230caf12c71
|
||||
|
||||
COCOAPODS: 1.0.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user