From e24148e2e59c1d1f3cd0a2cdbdb59bad0b07992e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 12 Dec 2018 23:19:05 +0800 Subject: [PATCH] Initial commit --- .gitignore | 78 +++ PlaceholderKit.xcodeproj/project.pbxproj | 511 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Source/NSImage+Placeholder.swift | 22 + Source/PlaceholderKit.swift | 46 ++ Source/UIImage+Placeholder.swift | 26 + .../Deployment-Targets.xcconfig | 4 + .../Universal-Framework-Target.xcconfig | 25 + .../Universal-Target-Base.xcconfig | 18 + Supporting Files/Framework-Info.plist | 24 + Supporting Files/FrameworkTests-Info.plist | 22 + Supporting Files/PlaceholderKit.h | 19 + 13 files changed, 810 insertions(+) create mode 100644 .gitignore create mode 100644 PlaceholderKit.xcodeproj/project.pbxproj create mode 100644 PlaceholderKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 PlaceholderKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Source/NSImage+Placeholder.swift create mode 100644 Source/PlaceholderKit.swift create mode 100644 Source/UIImage+Placeholder.swift create mode 100755 Supporting Files/Configurations/Deployment-Targets.xcconfig create mode 100755 Supporting Files/Configurations/Universal-Framework-Target.xcconfig create mode 100755 Supporting Files/Configurations/Universal-Target-Base.xcconfig create mode 100644 Supporting Files/Framework-Info.plist create mode 100644 Supporting Files/FrameworkTests-Info.plist create mode 100644 Supporting Files/PlaceholderKit.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fce96a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,78 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ \ No newline at end of file diff --git a/PlaceholderKit.xcodeproj/project.pbxproj b/PlaceholderKit.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f4eedfe --- /dev/null +++ b/PlaceholderKit.xcodeproj/project.pbxproj @@ -0,0 +1,511 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + F444B67A21C104460042E6F2 /* PlaceholderKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F444B67021C104460042E6F2 /* PlaceholderKit.framework */; }; + F444B68121C104460042E6F2 /* PlaceholderKit.h in Headers */ = {isa = PBXBuildFile; fileRef = F444B67321C104460042E6F2 /* PlaceholderKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F444B69021C104900042E6F2 /* Universal-Framework-Target.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = F444B68D21C104900042E6F2 /* Universal-Framework-Target.xcconfig */; }; + F444B69121C104900042E6F2 /* Universal-Target-Base.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = F444B68E21C104900042E6F2 /* Universal-Target-Base.xcconfig */; }; + F444B69221C104900042E6F2 /* Deployment-Targets.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = F444B68F21C104900042E6F2 /* Deployment-Targets.xcconfig */; }; + F444B69B21C10B3C0042E6F2 /* PlaceholderKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F444B69A21C10B3C0042E6F2 /* PlaceholderKit.swift */; }; + F444B69D21C115C00042E6F2 /* UIImage+Placeholder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F444B69C21C115C00042E6F2 /* UIImage+Placeholder.swift */; }; + F444B69F21C115C60042E6F2 /* NSImage+Placeholder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F444B69E21C115C60042E6F2 /* NSImage+Placeholder.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + F444B67B21C104460042E6F2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = F444B66721C104460042E6F2 /* Project object */; + proxyType = 1; + remoteGlobalIDString = F444B66F21C104460042E6F2; + remoteInfo = PlaceholderKit; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + F444B67021C104460042E6F2 /* PlaceholderKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PlaceholderKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F444B67321C104460042E6F2 /* PlaceholderKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlaceholderKit.h; sourceTree = ""; }; + F444B67421C104460042E6F2 /* Framework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Framework-Info.plist"; sourceTree = ""; }; + F444B67921C104460042E6F2 /* PlaceholderKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlaceholderKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + F444B68021C104460042E6F2 /* FrameworkTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "FrameworkTests-Info.plist"; sourceTree = ""; }; + F444B68D21C104900042E6F2 /* Universal-Framework-Target.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Universal-Framework-Target.xcconfig"; sourceTree = ""; }; + F444B68E21C104900042E6F2 /* Universal-Target-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Universal-Target-Base.xcconfig"; sourceTree = ""; }; + F444B68F21C104900042E6F2 /* Deployment-Targets.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Deployment-Targets.xcconfig"; sourceTree = ""; }; + F444B69A21C10B3C0042E6F2 /* PlaceholderKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceholderKit.swift; sourceTree = ""; }; + F444B69C21C115C00042E6F2 /* UIImage+Placeholder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Placeholder.swift"; sourceTree = ""; }; + F444B69E21C115C60042E6F2 /* NSImage+Placeholder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSImage+Placeholder.swift"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F444B66D21C104460042E6F2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F444B67621C104460042E6F2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F444B67A21C104460042E6F2 /* PlaceholderKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F444B66621C104460042E6F2 = { + isa = PBXGroup; + children = ( + F444B69321C105EB0042E6F2 /* Source */, + F444B69721C106420042E6F2 /* Tests */, + F444B68B21C1046F0042E6F2 /* Supporting Files */, + F444B67121C104460042E6F2 /* Products */, + ); + sourceTree = ""; + }; + F444B67121C104460042E6F2 /* Products */ = { + isa = PBXGroup; + children = ( + F444B67021C104460042E6F2 /* PlaceholderKit.framework */, + F444B67921C104460042E6F2 /* PlaceholderKitTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + F444B68B21C1046F0042E6F2 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + F444B67321C104460042E6F2 /* PlaceholderKit.h */, + F444B67421C104460042E6F2 /* Framework-Info.plist */, + F444B68021C104460042E6F2 /* FrameworkTests-Info.plist */, + F444B68C21C104790042E6F2 /* Configurations */, + ); + path = "Supporting Files"; + sourceTree = ""; + }; + F444B68C21C104790042E6F2 /* Configurations */ = { + isa = PBXGroup; + children = ( + F444B68F21C104900042E6F2 /* Deployment-Targets.xcconfig */, + F444B68D21C104900042E6F2 /* Universal-Framework-Target.xcconfig */, + F444B68E21C104900042E6F2 /* Universal-Target-Base.xcconfig */, + ); + path = Configurations; + sourceTree = ""; + }; + F444B69321C105EB0042E6F2 /* Source */ = { + isa = PBXGroup; + children = ( + F444B69A21C10B3C0042E6F2 /* PlaceholderKit.swift */, + F444B69C21C115C00042E6F2 /* UIImage+Placeholder.swift */, + F444B69E21C115C60042E6F2 /* NSImage+Placeholder.swift */, + ); + path = Source; + sourceTree = ""; + }; + F444B69721C106420042E6F2 /* Tests */ = { + isa = PBXGroup; + children = ( + ); + path = Tests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + F444B66B21C104460042E6F2 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + F444B68121C104460042E6F2 /* PlaceholderKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + F444B66F21C104460042E6F2 /* PlaceholderKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = F444B68421C104460042E6F2 /* Build configuration list for PBXNativeTarget "PlaceholderKit" */; + buildPhases = ( + F444B66B21C104460042E6F2 /* Headers */, + F444B66C21C104460042E6F2 /* Sources */, + F444B66D21C104460042E6F2 /* Frameworks */, + F444B66E21C104460042E6F2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PlaceholderKit; + productName = PlaceholderKit; + productReference = F444B67021C104460042E6F2 /* PlaceholderKit.framework */; + productType = "com.apple.product-type.framework"; + }; + F444B67821C104460042E6F2 /* PlaceholderKitTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = F444B68721C104460042E6F2 /* Build configuration list for PBXNativeTarget "PlaceholderKitTests" */; + buildPhases = ( + F444B67521C104460042E6F2 /* Sources */, + F444B67621C104460042E6F2 /* Frameworks */, + F444B67721C104460042E6F2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + F444B67C21C104460042E6F2 /* PBXTargetDependency */, + ); + name = PlaceholderKitTests; + productName = PlaceholderKitTests; + productReference = F444B67921C104460042E6F2 /* PlaceholderKitTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F444B66721C104460042E6F2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1010; + LastUpgradeCheck = 1010; + ORGANIZATIONNAME = "Shao Ping Lee"; + TargetAttributes = { + F444B66F21C104460042E6F2 = { + CreatedOnToolsVersion = 10.1; + LastSwiftMigration = 1010; + }; + F444B67821C104460042E6F2 = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = F444B66A21C104460042E6F2 /* Build configuration list for PBXProject "PlaceholderKit" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = F444B66621C104460042E6F2; + productRefGroup = F444B67121C104460042E6F2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F444B66F21C104460042E6F2 /* PlaceholderKit */, + F444B67821C104460042E6F2 /* PlaceholderKitTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F444B66E21C104460042E6F2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F444B69121C104900042E6F2 /* Universal-Target-Base.xcconfig in Resources */, + F444B69221C104900042E6F2 /* Deployment-Targets.xcconfig in Resources */, + F444B69021C104900042E6F2 /* Universal-Framework-Target.xcconfig in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F444B67721C104460042E6F2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F444B66C21C104460042E6F2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F444B69B21C10B3C0042E6F2 /* PlaceholderKit.swift in Sources */, + F444B69D21C115C00042E6F2 /* UIImage+Placeholder.swift in Sources */, + F444B69F21C115C60042E6F2 /* NSImage+Placeholder.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F444B67521C104460042E6F2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + F444B67C21C104460042E6F2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = F444B66F21C104460042E6F2 /* PlaceholderKit */; + targetProxy = F444B67B21C104460042E6F2 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + F444B68221C104460042E6F2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F444B68F21C104900042E6F2 /* Deployment-Targets.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + 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_DOCUMENTATION_COMMENTS = YES; + 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + F444B68321C104460042E6F2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F444B68F21C104900042E6F2 /* Deployment-Targets.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + 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_DOCUMENTATION_COMMENTS = YES; + 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + F444B68521C104460042E6F2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F444B68D21C104900042E6F2 /* Universal-Framework-Target.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = T3LQ95726F; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Framework-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.shaopinglee.PlaceholderKit; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = ""; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; + }; + name = Debug; + }; + F444B68621C104460042E6F2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F444B68D21C104900042E6F2 /* Universal-Framework-Target.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = T3LQ95726F; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Framework-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.shaopinglee.PlaceholderKit; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = ""; + SKIP_INSTALL = YES; + SWIFT_VERSION = 4.2; + }; + name = Release; + }; + F444B68821C104460042E6F2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F444B68E21C104900042E6F2 /* Universal-Target-Base.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = T3LQ95726F; + INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/FrameworkTests-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.shaopinglee.PlaceholderKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + }; + name = Debug; + }; + F444B68921C104460042E6F2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F444B68E21C104900042E6F2 /* Universal-Target-Base.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = T3LQ95726F; + INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/FrameworkTests-Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.shaopinglee.PlaceholderKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F444B66A21C104460042E6F2 /* Build configuration list for PBXProject "PlaceholderKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F444B68221C104460042E6F2 /* Debug */, + F444B68321C104460042E6F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F444B68421C104460042E6F2 /* Build configuration list for PBXNativeTarget "PlaceholderKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F444B68521C104460042E6F2 /* Debug */, + F444B68621C104460042E6F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F444B68721C104460042E6F2 /* Build configuration list for PBXNativeTarget "PlaceholderKitTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F444B68821C104460042E6F2 /* Debug */, + F444B68921C104460042E6F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F444B66721C104460042E6F2 /* Project object */; +} diff --git a/PlaceholderKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PlaceholderKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..2ece07f --- /dev/null +++ b/PlaceholderKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/PlaceholderKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PlaceholderKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/PlaceholderKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Source/NSImage+Placeholder.swift b/Source/NSImage+Placeholder.swift new file mode 100644 index 0000000..ab620d3 --- /dev/null +++ b/Source/NSImage+Placeholder.swift @@ -0,0 +1,22 @@ +// +// NSImage+Placeholder.swift +// PlaceholderKit +// +// Created by Simon Lee on 12/12/18. +// Copyright © 2018 Shao Ping Lee. All rights reserved. +// + +#if canImport(AppKit) +import AppKit + +extension NSImage { + static func createPlaceholder(withColor color: NSColor, size: CGSize) -> NSImage? { + let image = NSImage(size: size) + image.lockFocus() + color.drawSwatch(in: NSMakeRect(0, 0, size.width, size.height)) + image.unlockFocus() + return image + } +} + +#endif diff --git a/Source/PlaceholderKit.swift b/Source/PlaceholderKit.swift new file mode 100644 index 0000000..3fb5319 --- /dev/null +++ b/Source/PlaceholderKit.swift @@ -0,0 +1,46 @@ +// +// PlaceholderKit.swift +// PlaceholderKit +// +// Created by Simon Lee on 12/12/18. +// Copyright © 2018 Shao Ping Lee. All rights reserved. +// + +#if os(OSX) +import AppKit +typealias Color = NSColor +typealias Image = NSImage +#else +import UIKit +typealias Color = UIColor +typealias Image = UIImage +#endif + +public struct PlaceholderKit { + +} + +public struct PlaceholderFactory { + let settings: PlaceholderSettings + + func createPlaceholder() -> Image? { + switch settings.background { + case .solidColor(let color): + return Image.createPlaceholder(withColor: color, size: settings.size) + case .image(let image): + return nil + } + } +} + +public struct PlaceholderSettings { + let size: CGSize + let background: PlaceholderBackground + let showDimensionAsText: Bool + let convertDimensionToAspectRatio: Bool +} + +enum PlaceholderBackground { + case solidColor(Color) + case image(Image) +} diff --git a/Source/UIImage+Placeholder.swift b/Source/UIImage+Placeholder.swift new file mode 100644 index 0000000..ff775a2 --- /dev/null +++ b/Source/UIImage+Placeholder.swift @@ -0,0 +1,26 @@ +// +// UIImage+Placeholder.swift +// PlaceholderKit +// +// Created by Simon Lee on 12/12/18. +// Copyright © 2018 Shao Ping Lee. All rights reserved. +// + +#if canImport(UIKit) +import UIKit + +extension UIImage { + static func createPlaceholder(withColor color: UIColor, size: CGSize) -> UIImage? { + let rect = CGRect(origin: .zero, size: size) + UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) + color.setFill() + UIRectFill(rect) + let image = UIGraphicsGetImageFromCurrentImageContext() + UIGraphicsEndImageContext() + + guard let cgImage = image?.cgImage else { return nil } + return UIImage(cgImage: cgImage) + } +} + +#endif diff --git a/Supporting Files/Configurations/Deployment-Targets.xcconfig b/Supporting Files/Configurations/Deployment-Targets.xcconfig new file mode 100755 index 0000000..fdd89a3 --- /dev/null +++ b/Supporting Files/Configurations/Deployment-Targets.xcconfig @@ -0,0 +1,4 @@ +IPHONEOS_DEPLOYMENT_TARGET = 8.0 +MACOSX_DEPLOYMENT_TARGET = 10.11 +TVOS_DEPLOYMENT_TARGET = 9.0 +WATCHOS_DEPLOYMENT_TARGET = 3.0 diff --git a/Supporting Files/Configurations/Universal-Framework-Target.xcconfig b/Supporting Files/Configurations/Universal-Framework-Target.xcconfig new file mode 100755 index 0000000..d9926cd --- /dev/null +++ b/Supporting Files/Configurations/Universal-Framework-Target.xcconfig @@ -0,0 +1,25 @@ +#include "Universal-Target-Base.xcconfig" + +// OSX-specific default settings +FRAMEWORK_VERSION[sdk=macosx*] = A +COMBINE_HIDPI_IMAGES[sdk=macosx*] = YES + +// iOS-specific default settings +TARGETED_DEVICE_FAMILY[sdk=iphonesimulator*] = 1,2 +TARGETED_DEVICE_FAMILY[sdk=iphone*] = 1,2 + +// TV-specific default settings +TARGETED_DEVICE_FAMILY[sdk=appletvsimulator*] = 3 +TARGETED_DEVICE_FAMILY[sdk=appletv*] = 3 + +// Watch-specific default settings +TARGETED_DEVICE_FAMILY[sdk=watchsimulator*] = 4 +TARGETED_DEVICE_FAMILY[sdk=watch*] = 4 + +ENABLE_BITCODE[sdk=macosx*] = NO +ENABLE_BITCODE[sdk=watchsimulator*] = YES +ENABLE_BITCODE[sdk=watch*] = YES +ENABLE_BITCODE[sdk=iphonesimulator*] = NO +ENABLE_BITCODE[sdk=iphone*] = YES +ENABLE_BITCODE[sdk=appletvsimulator*] = YES +ENABLE_BITCODE[sdk=appletv*] = YES diff --git a/Supporting Files/Configurations/Universal-Target-Base.xcconfig b/Supporting Files/Configurations/Universal-Target-Base.xcconfig new file mode 100755 index 0000000..226b59f --- /dev/null +++ b/Supporting Files/Configurations/Universal-Target-Base.xcconfig @@ -0,0 +1,18 @@ +SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos watchos watchsimulator appletvos appletvsimulator +VALID_ARCHS[sdk=macosx*] = i386 x86_64 +VALID_ARCHS[sdk=iphoneos*] = arm64 armv7 armv7s +VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 +VALID_ARCHS[sdk=watchos*] = armv7k +VALID_ARCHS[sdk=watchsimulator*] = i386 +VALID_ARCHS[sdk=appletv*] = arm64 +VALID_ARCHS[sdk=appletvsimulator*] = x86_64 + +// Dynamic linking uses different default copy paths +LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) '@executable_path/../Frameworks' '@loader_path/../Frameworks' +LD_RUNPATH_SEARCH_PATHS[sdk=iphoneos*] = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +LD_RUNPATH_SEARCH_PATHS[sdk=iphonesimulator*] = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +LD_RUNPATH_SEARCH_PATHS[sdk=watchos*] = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +LD_RUNPATH_SEARCH_PATHS[sdk=watchsimulator*] = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +LD_RUNPATH_SEARCH_PATHS[sdk=appletvos*] = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +LD_RUNPATH_SEARCH_PATHS[sdk=appletvsimulator*] = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' + diff --git a/Supporting Files/Framework-Info.plist b/Supporting Files/Framework-Info.plist new file mode 100644 index 0000000..ca74b89 --- /dev/null +++ b/Supporting Files/Framework-Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2018 Shao Ping Lee. All rights reserved. + + diff --git a/Supporting Files/FrameworkTests-Info.plist b/Supporting Files/FrameworkTests-Info.plist new file mode 100644 index 0000000..6c40a6c --- /dev/null +++ b/Supporting Files/FrameworkTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Supporting Files/PlaceholderKit.h b/Supporting Files/PlaceholderKit.h new file mode 100644 index 0000000..9cd90a7 --- /dev/null +++ b/Supporting Files/PlaceholderKit.h @@ -0,0 +1,19 @@ +// +// PlaceholderKit.h +// PlaceholderKit +// +// Created by Simon Lee on 12/12/18. +// Copyright © 2018 Shao Ping Lee. All rights reserved. +// + +@import Foundation; + +//! Project version number for PlaceholderKit. +FOUNDATION_EXPORT double PlaceholderKitVersionNumber; + +//! Project version string for PlaceholderKit. +FOUNDATION_EXPORT const unsigned char PlaceholderKitVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + +