Browse Source

Basic watchOS support

onevcat 10 years ago
parent
commit
57e842f55c

+ 144 - 4
Kingfisher.xcodeproj/project.pbxproj

@@ -95,6 +95,16 @@
 		D12E0CB61C47F9C100AC98AD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C941C47F91800AC98AD /* ViewController.swift */; };
 		D13F49E91BEDA82000CE335D /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D13F49D61BEDA67C00CE335D /* Kingfisher.framework */; };
 		D13F49EA1BEDA82000CE335D /* Kingfisher.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D13F49D61BEDA67C00CE335D /* Kingfisher.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+		D16799F71C4E74D10020FD12 /* Kingfisher-watchOS.h in Headers */ = {isa = PBXBuildFile; fileRef = D16799F51C4E74D10020FD12 /* Kingfisher-watchOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		D1679A081C4E76410020FD12 /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C1F1C47F1DF00AC98AD /* Image.swift */; };
+		D1679A091C4E76410020FD12 /* ImageCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C201C47F1DF00AC98AD /* ImageCache.swift */; };
+		D1679A0A1C4E76410020FD12 /* ImageDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C211C47F1DF00AC98AD /* ImageDownloader.swift */; };
+		D1679A0B1C4E76410020FD12 /* KingfisherManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C261C47F1DF00AC98AD /* KingfisherManager.swift */; };
+		D1679A0C1C4E76410020FD12 /* KingfisherOptionsInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C271C47F1DF00AC98AD /* KingfisherOptionsInfo.swift */; };
+		D1679A0D1C4E76410020FD12 /* Resource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C281C47F1DF00AC98AD /* Resource.swift */; };
+		D1679A0E1C4E76410020FD12 /* String+MD5.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C291C47F1DF00AC98AD /* String+MD5.swift */; };
+		D1679A0F1C4E76410020FD12 /* ThreadHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C2A1C47F1DF00AC98AD /* ThreadHelper.swift */; };
+		D1679A101C4E76550020FD12 /* ImageTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12E0C221C47F1DF00AC98AD /* ImageTransition.swift */; };
 		D1ED2D401AD2D09F00CFC3EB /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1ED2D351AD2D09F00CFC3EB /* Kingfisher.framework */; };
 		D1ED2D4C1AD2D09F00CFC3EB /* Kingfisher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1ED2D351AD2D09F00CFC3EB /* Kingfisher.framework */; };
 		D1ED2D4D1AD2D09F00CFC3EB /* Kingfisher.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D1ED2D351AD2D09F00CFC3EB /* Kingfisher.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -238,6 +248,9 @@
 		D12E0CAD1C47F92C00AC98AD /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
 		D13F49C21BEDA53F00CE335D /* Kingfisher-tvOS-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Kingfisher-tvOS-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		D13F49D61BEDA67C00CE335D /* Kingfisher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Kingfisher.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		D16799EB1C4E74460020FD12 /* Kingfisher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Kingfisher.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		D16799F41C4E74D10020FD12 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		D16799F51C4E74D10020FD12 /* Kingfisher-watchOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Kingfisher-watchOS.h"; sourceTree = "<group>"; };
 		D1ED2D0B1AD2CFA600CFC3EB /* Kingfisher-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Kingfisher-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		D1ED2D351AD2D09F00CFC3EB /* Kingfisher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Kingfisher.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		D1ED2D3F1AD2D09F00CFC3EB /* KingfisherTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KingfisherTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -296,6 +309,13 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D16799E71C4E74460020FD12 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		D1ED2D081AD2CFA600CFC3EB /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
@@ -342,6 +362,7 @@
 			children = (
 				D12E0C1E1C47F1DF00AC98AD /* Kingfisher */,
 				D12E0C3E1C47F1F300AC98AD /* Kingfisher-tvOS */,
+				D16799F31C4E74D10020FD12 /* Kingfisher-watchOS */,
 				D12E0C391C47F1EB00AC98AD /* Kingfisher-OSX */,
 			);
 			name = Sources;
@@ -486,6 +507,16 @@
 			path = "Demo/Kingfisher-OSX-Demo";
 			sourceTree = "<group>";
 		};
+		D16799F31C4E74D10020FD12 /* Kingfisher-watchOS */ = {
+			isa = PBXGroup;
+			children = (
+				D16799F41C4E74D10020FD12 /* Info.plist */,
+				D16799F51C4E74D10020FD12 /* Kingfisher-watchOS.h */,
+			);
+			name = "Kingfisher-watchOS";
+			path = "Sources/Kingfisher-watchOS";
+			sourceTree = "<group>";
+		};
 		D1ED2D021AD2CFA600CFC3EB = {
 			isa = PBXGroup;
 			children = (
@@ -510,6 +541,7 @@
 				4B2944551C3D03880088C3E7 /* Kingfisher-OSX-Demo.app */,
 				D10EC2311C3D632300A4211C /* KingfisherTests-OSX.xctest */,
 				4B37667F1C478F940001443F /* KingfisherTests-tvOS.xctest */,
+				D16799EB1C4E74460020FD12 /* Kingfisher.framework */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -547,6 +579,14 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D16799E81C4E74460020FD12 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				D16799F71C4E74D10020FD12 /* Kingfisher-watchOS.h in Headers */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		D1ED2D321AD2D09F00CFC3EB /* Headers */ = {
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
@@ -674,6 +714,24 @@
 			productReference = D13F49D61BEDA67C00CE335D /* Kingfisher.framework */;
 			productType = "com.apple.product-type.framework";
 		};
+		D16799EA1C4E74460020FD12 /* Kingfisher-watchOS */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = D16799F21C4E74460020FD12 /* Build configuration list for PBXNativeTarget "Kingfisher-watchOS" */;
+			buildPhases = (
+				D16799E61C4E74460020FD12 /* Sources */,
+				D16799E71C4E74460020FD12 /* Frameworks */,
+				D16799E81C4E74460020FD12 /* Headers */,
+				D16799E91C4E74460020FD12 /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = "Kingfisher-watchOS";
+			productName = "Kingfisher-watchOS";
+			productReference = D16799EB1C4E74460020FD12 /* Kingfisher.framework */;
+			productType = "com.apple.product-type.framework";
+		};
 		D1ED2D0A1AD2CFA600CFC3EB /* Kingfisher-Demo */ = {
 			isa = PBXNativeTarget;
 			buildConfigurationList = D1ED2D2A1AD2CFA600CFC3EB /* Build configuration list for PBXNativeTarget "Kingfisher-Demo" */;
@@ -762,6 +820,9 @@
 					D13F49D51BEDA67C00CE335D = {
 						CreatedOnToolsVersion = 7.1;
 					};
+					D16799EA1C4E74460020FD12 = {
+						CreatedOnToolsVersion = 7.2;
+					};
 					D1ED2D0A1AD2CFA600CFC3EB = {
 						CreatedOnToolsVersion = 6.2;
 					};
@@ -789,6 +850,7 @@
 				D1ED2D341AD2D09F00CFC3EB /* Kingfisher-iOS */,
 				D13F49D51BEDA67C00CE335D /* Kingfisher-tvOS */,
 				4B2944471C3D01B20088C3E7 /* Kingfisher-OSX */,
+				D16799EA1C4E74460020FD12 /* Kingfisher-watchOS */,
 				D1ED2D0A1AD2CFA600CFC3EB /* Kingfisher-Demo */,
 				D13F49C11BEDA53F00CE335D /* Kingfisher-tvOS-Demo */,
 				4B2944541C3D03880088C3E7 /* Kingfisher-OSX-Demo */,
@@ -849,6 +911,13 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D16799E91C4E74460020FD12 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		D1ED2D091AD2CFA600CFC3EB /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -1137,6 +1206,22 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
+		D16799E61C4E74460020FD12 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				D1679A101C4E76550020FD12 /* ImageTransition.swift in Sources */,
+				D1679A081C4E76410020FD12 /* Image.swift in Sources */,
+				D1679A091C4E76410020FD12 /* ImageCache.swift in Sources */,
+				D1679A0A1C4E76410020FD12 /* ImageDownloader.swift in Sources */,
+				D1679A0B1C4E76410020FD12 /* KingfisherManager.swift in Sources */,
+				D1679A0C1C4E76410020FD12 /* KingfisherOptionsInfo.swift in Sources */,
+				D1679A0D1C4E76410020FD12 /* Resource.swift in Sources */,
+				D1679A0E1C4E76410020FD12 /* String+MD5.swift in Sources */,
+				D1679A0F1C4E76410020FD12 /* ThreadHelper.swift in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		D1ED2D071AD2CFA600CFC3EB /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -1491,6 +1576,56 @@
 			};
 			name = Release;
 		};
+		D16799F01C4E74460020FD12 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				APPLICATION_EXTENSION_API_ONLY = YES;
+				CURRENT_PROJECT_VERSION = 1;
+				DEBUG_INFORMATION_FORMAT = dwarf;
+				DEFINES_MODULE = YES;
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				DYLIB_INSTALL_NAME_BASE = "@rpath";
+				GCC_NO_COMMON_BLOCKS = YES;
+				INFOPLIST_FILE = "Sources/Kingfisher-watchOS/Info.plist";
+				INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.Kingfisher-watchOS";
+				PRODUCT_NAME = Kingfisher;
+				SDKROOT = watchos;
+				SKIP_INSTALL = YES;
+				TARGETED_DEVICE_FAMILY = 4;
+				VERSIONING_SYSTEM = "apple-generic";
+				VERSION_INFO_PREFIX = "";
+				WATCHOS_DEPLOYMENT_TARGET = 2.0;
+			};
+			name = Debug;
+		};
+		D16799F11C4E74460020FD12 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				APPLICATION_EXTENSION_API_ONLY = YES;
+				CURRENT_PROJECT_VERSION = 1;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				DEFINES_MODULE = YES;
+				DYLIB_COMPATIBILITY_VERSION = 1;
+				DYLIB_CURRENT_VERSION = 1;
+				DYLIB_INSTALL_NAME_BASE = "@rpath";
+				GCC_NO_COMMON_BLOCKS = YES;
+				INFOPLIST_FILE = "Sources/Kingfisher-watchOS/Info.plist";
+				INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.Kingfisher-watchOS";
+				PRODUCT_NAME = Kingfisher;
+				SDKROOT = watchos;
+				SKIP_INSTALL = YES;
+				TARGETED_DEVICE_FAMILY = 4;
+				VERSIONING_SYSTEM = "apple-generic";
+				VERSION_INFO_PREFIX = "";
+				WATCHOS_DEPLOYMENT_TARGET = 2.0;
+			};
+			name = Release;
+		};
 		D1ED2D281AD2CFA600CFC3EB /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -1610,10 +1745,6 @@
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_CURRENT_VERSION = 418;
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
-				GCC_PREPROCESSOR_DEFINITIONS = (
-					"DEBUG=1",
-					"$(inherited)",
-				);
 				INFOPLIST_FILE = Sources/Kingfisher/Info.plist;
 				INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
 				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -1740,6 +1871,15 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
+		D16799F21C4E74460020FD12 /* Build configuration list for PBXNativeTarget "Kingfisher-watchOS" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				D16799F01C4E74460020FD12 /* Debug */,
+				D16799F11C4E74460020FD12 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		D1ED2D061AD2CFA600CFC3EB /* Build configuration list for PBXProject "Kingfisher" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (

+ 26 - 0
Sources/Kingfisher-watchOS/Info.plist

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>FMWK</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>$(CURRENT_PROJECT_VERSION)</string>
+	<key>NSPrincipalClass</key>
+	<string></string>
+</dict>
+</plist>

+ 19 - 0
Sources/Kingfisher-watchOS/Kingfisher-watchOS.h

@@ -0,0 +1,19 @@
+//
+//  Kingfisher-watchOS.h
+//  Kingfisher-watchOS
+//
+//  Created by Wei Wang on 16/1/19.
+//  Copyright © 2016年 Wei Wang. All rights reserved.
+//
+
+#import <WatchKit/WatchKit.h>
+
+//! Project version number for Kingfisher-watchOS.
+FOUNDATION_EXPORT double Kingfisher_watchOSVersionNumber;
+
+//! Project version string for Kingfisher-watchOS.
+FOUNDATION_EXPORT const unsigned char Kingfisher_watchOSVersionString[];
+
+// In this header, you should import all the public headers of your framework using statements like #import <Kingfisher_watchOS/PublicHeader.h>
+
+

+ 2 - 2
Sources/Kingfisher/ImageCache.swift

@@ -129,7 +129,7 @@ public class ImageCache {
             self.fileManager = NSFileManager()
         })
         
-#if !os(OSX)
+#if !os(OSX) && !os(watchOS)
         NSNotificationCenter.defaultCenter().addObserver(self, selector: "clearMemoryCache", name: UIApplicationDidReceiveMemoryWarningNotification, object: nil)
         NSNotificationCenter.defaultCenter().addObserver(self, selector: "cleanExpiredDiskCache", name: UIApplicationWillTerminateNotification, object: nil)
         NSNotificationCenter.defaultCenter().addObserver(self, selector: "backgroundCleanExpiredDiskCache", name: UIApplicationDidEnterBackgroundNotification, object: nil)
@@ -500,7 +500,7 @@ extension ImageCache {
         })
     }
     
-#if !os(OSX)
+#if !os(OSX) && !os(watchOS)
     /**
     Clean expired disk cache when app in background. This is an async operation.
     In most cases, you should not call this method explicitly. 

+ 10 - 1
Sources/Kingfisher/ImageTransition.swift

@@ -25,10 +25,19 @@
 //  THE SOFTWARE.
 
 #if os(OSX)
-// Not implemented for OSX yet.
+// Not implemented for OSX and watchOS yet.
     
 import AppKit
     
+public enum ImageTransition {
+    case None
+    var duration: NSTimeInterval {
+        return 0
+    }
+}
+
+#elseif os(watchOS)
+import UIKit
 public enum ImageTransition {
     case None
     var duration: NSTimeInterval {