From c2df652e4203c701047adda2ebd2fa7232695e48 Mon Sep 17 00:00:00 2001 From: jkyin Date: Tue, 24 Oct 2017 01:48:21 +0800 Subject: [PATCH 01/17] 4.0 --- Iconic.podspec | 18 +++++----- Samples/Samples.xcodeproj/project.pbxproj | 43 +++++++++++++++++++---- Source/Iconizer.sh | 10 +++--- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/Iconic.podspec b/Iconic.podspec index 71fc034..99545cd 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -1,39 +1,39 @@ @version = '1.3' Pod::Spec.new do |s| - + s.name = 'Iconic' s.version = @version s.summary = 'Auto-generated icon font library for iOS [beta]' s.description = 'Iconic will help you make icon fonts integration on iOS easy and effortless. Its main component is in charge of auto-generating strongly typed code in Swift, fully compatible with Objective-C, allowing the integration of vector icons as image or text in your apps.' - + s.homepage = 'https://github.com/dzenbot/Iconic' s.screenshots = '' s.author = { 'Ignacio Romero Zurbuchen' => 'iromero@dzen.cl' } - + s.license = { :type => 'MIT', :file => 'LICENSE' } - + s.source = { - :git => 'https://github.com/dzenbot/Iconic.git', + :git => 'https://github.com/jkyin/Iconic.git', :tag => @version } - + s.source_files = 'Source/*.{swift}' s.resources = 'Source/**/*.{ttf,otf}' s.preserve_paths = 'Source/Catalog/**/*.*' s.framework = 'UIKit', 'CoreText' - + s.ios.deployment_target = '8.0' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO', - 'SWIFT_VERSION' => '3.0', + 'SWIFT_VERSION' => '4.0', } - + s.prepare_command = "sh Source/Iconizer.sh '#{ENV['FONT_PATH']}' --verbose" end diff --git a/Samples/Samples.xcodeproj/project.pbxproj b/Samples/Samples.xcodeproj/project.pbxproj index d3c6fda..039bd3f 100644 --- a/Samples/Samples.xcodeproj/project.pbxproj +++ b/Samples/Samples.xcodeproj/project.pbxproj @@ -588,13 +588,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-tvOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 0F1636CC8BBFF46B28293083 /* [CP] Check Pods Manifest.lock */ = { @@ -603,13 +606,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 2FE47DC5D0C4319209558F1E /* [CP] Copy Pods Resources */ = { @@ -633,9 +639,12 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-watchOS Extension/Pods-watchOS Extension-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-watchOS2.0/Iconic.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -663,9 +672,12 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-tvOS/Pods-tvOS-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-tvOS9.0/Iconic.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -678,9 +690,12 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-iOS/Pods-iOS-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-iOS8.0/Iconic.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -693,13 +708,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Tests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 7DFCE678A53C4566F95D47F2 /* [CP] Copy Pods Resources */ = { @@ -753,13 +771,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS Extension-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; B72B7A6B427AB1106382AE87 /* [CP] Embed Pods Frameworks */ = { @@ -768,9 +789,14 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-iOS9.3/Iconic.framework", + "${BUILT_PRODUCTS_DIR}/FBSnapshotTestCase/FBSnapshotTestCase.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSnapshotTestCase.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -825,13 +851,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-iOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -1119,7 +1148,7 @@ PRODUCT_NAME = iOS; SWIFT_OBJC_BRIDGING_HEADER = "iOS/Classes/iOS-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1137,7 +1166,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-ios"; PRODUCT_NAME = iOS; SWIFT_OBJC_BRIDGING_HEADER = "iOS/Classes/iOS-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Source/Iconizer.sh b/Source/Iconizer.sh index bc986bb..f912b3f 100755 --- a/Source/Iconizer.sh +++ b/Source/Iconizer.sh @@ -22,7 +22,7 @@ CATALOG_PATH=Source/Catalog STENCIL_PATH=Source/iconic-default.stencil # The path of SwiftGen exec -EXEC_PATH=Vendor/SwiftGen/build/swiftgen/bin/swiftgen +EXEC_PATH=/usr/local/bin/swiftgen function getFileTitle() @@ -32,16 +32,16 @@ function getFileTitle() # Removes the file extension name="${FILE_NAME%.*}" - + # Splits and removes all substrings with the separator characters in the file name # like whitespaces, dash, underscore, etc. title="${name%%[" -_–"]*}" - + # Specially, we want to strip the string starting from the word "Icon", and append it manually, # so a string like 'MaterialIconsFont' would look like 'MaterialIcon'. title="${title%%"icon"*}" title="${title%%"Icon"*}Icon" - + # Upper case the first character title="$(tr '[:lower:]' '[:upper:]' <<< ${title:0:1})${title:1}" @@ -68,7 +68,7 @@ function iconize() # Moves and renames the JSON output to the HTML directory mv ${OUTPUT_PATH}/${OUTPUT_NAME}.json ${CATALOG_PATH}/data.json echo "Iconizer: Moving catalog's json to '${CATALOG_PATH}/data.json'" - + # Copies the font file to the HTML directory cp -r ${FONT_PATH} ${CATALOG_PATH}/${FONT_NAME} echo "Iconizer: Moving catalog's font to '${CATALOG_PATH}/${FONT_NAME}'" From 4f1cd387ac476a411c9e1321b1b31f30f0042e52 Mon Sep 17 00:00:00 2001 From: jkyin Date: Tue, 24 Oct 2017 02:19:29 +0800 Subject: [PATCH 02/17] update to 4.0 --- Iconic.podspec | 2 +- Samples/Podfile | 8 -- Samples/Samples.xcodeproj/project.pbxproj | 10 +-- .../contents.xcworkspacedata | 75 ------------------- 4 files changed, 3 insertions(+), 92 deletions(-) diff --git a/Iconic.podspec b/Iconic.podspec index 99545cd..b92e265 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -1,4 +1,4 @@ -@version = '1.3' +@version = '1.4' Pod::Spec.new do |s| diff --git a/Samples/Podfile b/Samples/Podfile index 6a1bffa..06db699 100644 --- a/Samples/Podfile +++ b/Samples/Podfile @@ -33,11 +33,3 @@ target 'Tests' do pod 'FBSnapshotTestCase/Core' iconic end - -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['SWIFT_VERSION'] = '3.0' - end - end -end diff --git a/Samples/Samples.xcodeproj/project.pbxproj b/Samples/Samples.xcodeproj/project.pbxproj index 039bd3f..3965a52 100644 --- a/Samples/Samples.xcodeproj/project.pbxproj +++ b/Samples/Samples.xcodeproj/project.pbxproj @@ -983,7 +983,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-tvos"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1003,7 +1002,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-tvos"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1024,7 +1022,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Supporting Files/Tests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -1042,7 +1039,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.Iconic-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Supporting Files/Tests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; }; name = Release; }; @@ -1090,6 +1086,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1130,6 +1127,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -1188,7 +1186,6 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1210,7 +1207,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1233,7 +1229,6 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1255,7 +1250,6 @@ PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; diff --git a/Samples/Samples.xcworkspace/contents.xcworkspacedata b/Samples/Samples.xcworkspace/contents.xcworkspacedata index 6f0a135..3e99cce 100644 --- a/Samples/Samples.xcworkspace/contents.xcworkspacedata +++ b/Samples/Samples.xcworkspace/contents.xcworkspacedata @@ -1,81 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 88dbdacee90eec47b874147b3f7b91c70f43fe4b Mon Sep 17 00:00:00 2001 From: jkyin Date: Tue, 24 Oct 2017 02:54:11 +0800 Subject: [PATCH 03/17] 4.0 --- Samples/watchOS Extension/InterfaceController.swift | 8 ++++++-- Source/IconDrawable.swift | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Samples/watchOS Extension/InterfaceController.swift b/Samples/watchOS Extension/InterfaceController.swift index 625574e..0d4597d 100644 --- a/Samples/watchOS Extension/InterfaceController.swift +++ b/Samples/watchOS Extension/InterfaceController.swift @@ -25,8 +25,7 @@ class InterfaceController: WKInterfaceController { let upArrowIcon = FontAwesomeIcon.angleUpIcon let downArrowIcon = FontAwesomeIcon.angleDownIcon - override class func initialize() { - + func initialize(){ // It is important to register the icon font as soon as possible, // and make the resources available right after launching the app. // @@ -36,6 +35,11 @@ class InterfaceController: WKInterfaceController { FontAwesomeIcon.register() } + static let shared : InterfaceController = { + $0.initialize() + return $0 + }(InterfaceController()) + override func awake(withContext context: Any?) { super.awake(withContext: context) diff --git a/Source/IconDrawable.swift b/Source/IconDrawable.swift index 0b610ce..dc71a3c 100644 --- a/Source/IconDrawable.swift +++ b/Source/IconDrawable.swift @@ -94,10 +94,11 @@ extension IconDrawable { public func attributedString(ofSize pointSize: CGFloat, color: UIColor?) -> NSAttributedString { let font = Self.font(ofSize: pointSize) - var attributes = [NSFontAttributeName : font] as [String : AnyObject] + var attributes = [NSAttributedStringKey : Any]() + attributes[.font] = font if let color = color { - attributes[NSForegroundColorAttributeName] = color + attributes[.foregroundColor] = color } return NSAttributedString(string: unicode, attributes: attributes) @@ -110,10 +111,10 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSBaselineOffsetAttributeName, value: edgeInsets.bottom-edgeInsets.top, range: range) + mString.addAttribute(.baselineOffset, value: edgeInsets.bottom-edgeInsets.top, range: range) - let leftSpace = NSAttributedString(string: " ", attributes: [NSKernAttributeName: edgeInsets.left]) - let rightSpace = NSAttributedString(string: " ", attributes: [NSKernAttributeName: edgeInsets.right]) + let leftSpace = NSAttributedString(string: " ", attributes: [.kern: edgeInsets.left]) + let rightSpace = NSAttributedString(string: " ", attributes: [.kern: edgeInsets.right]) mString.insert(rightSpace, at: mString.length) mString.insert(leftSpace, at: 0) @@ -142,7 +143,7 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: range) + mString.addAttribute(.paragraphStyle, value: paragraphStyle, range: range) // Renders the attributed string as image using Text Kit UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) From 321e53711a656b123d9e9664f4931cac96830bd9 Mon Sep 17 00:00:00 2001 From: jkyin Date: Tue, 24 Oct 2017 17:03:38 +0800 Subject: [PATCH 04/17] 1.5 --- Source/Iconizer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Iconizer.sh b/Source/Iconizer.sh index f912b3f..d4470ca 100755 --- a/Source/Iconizer.sh +++ b/Source/Iconizer.sh @@ -22,7 +22,7 @@ CATALOG_PATH=Source/Catalog STENCIL_PATH=Source/iconic-default.stencil # The path of SwiftGen exec -EXEC_PATH=/usr/local/bin/swiftgen +EXEC_PATH=Vendor/SwiftGen/build/swiftgen/bin/swiftgen function getFileTitle() From 204c87b81dcca9d5699659ce8b2c3117d2e382fc Mon Sep 17 00:00:00 2001 From: jkyin Date: Tue, 24 Oct 2017 17:09:13 +0800 Subject: [PATCH 05/17] 1.5 --- .swift-version | 2 +- Iconic.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.swift-version b/.swift-version index 9f55b2c..5186d07 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 diff --git a/Iconic.podspec b/Iconic.podspec index b92e265..464a095 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -1,4 +1,4 @@ -@version = '1.4' +@version = '1.5' Pod::Spec.new do |s| From 72b3738d16565c4bb31f8d34921180dd1caa2781 Mon Sep 17 00:00:00 2001 From: Steven Peterson Date: Sat, 28 Oct 2017 19:10:40 +0900 Subject: [PATCH 06/17] Fix @objc inference for Swift 4 --- Source/iconic-default.stencil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/iconic-default.stencil b/Source/iconic-default.stencil index cb38cea..6ff6405 100644 --- a/Source/iconic-default.stencil +++ b/Source/iconic-default.stencil @@ -4,7 +4,7 @@ import UIKit {% if icons %} /** A wrapper class for Objective-C compatibility. */ -public extension Iconic { +@objc public extension Iconic { /** The icon font's family name. */ class var {{enumName|lowerFirstWord}}FamilyName: NSString { From 9e9be59f4b84c0eadbd312282c35043cd9530aae Mon Sep 17 00:00:00 2001 From: zvving Date: Thu, 1 Feb 2018 14:49:20 +0800 Subject: [PATCH 07/17] Update podspec config for swift version --- Iconic.podspec | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Iconic.podspec b/Iconic.podspec index 71fc034..a4f1cbe 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -30,10 +30,7 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' - s.pod_target_xcconfig = { - 'ENABLE_BITCODE' => 'NO', - 'SWIFT_VERSION' => '3.0', - } + s.swift_version = '3.0' s.prepare_command = "sh Source/Iconizer.sh '#{ENV['FONT_PATH']}' --verbose" end From c104b30e89146e71655c6e9c3091764694d82ce6 Mon Sep 17 00:00:00 2001 From: zvving Date: Thu, 1 Feb 2018 16:45:34 +0800 Subject: [PATCH 08/17] Update to swift4 --- Iconic.podspec | 2 - Source/IconDrawable.swift | 19 ++++----- Source/IconImageView.swift | 81 +++++++++++++++++++------------------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Iconic.podspec b/Iconic.podspec index a4f1cbe..dd0bb2e 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -29,8 +29,6 @@ Pod::Spec.new do |s| s.ios.deployment_target = '8.0' s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' - - s.swift_version = '3.0' s.prepare_command = "sh Source/Iconizer.sh '#{ENV['FONT_PATH']}' --verbose" end diff --git a/Source/IconDrawable.swift b/Source/IconDrawable.swift index 0b610ce..12cf90f 100644 --- a/Source/IconDrawable.swift +++ b/Source/IconDrawable.swift @@ -51,7 +51,7 @@ public protocol IconDrawable { - parameter edgeInsets: The edge insets to be used as horizontal and vertical padding. */ func attributedString(ofSize pointSize: CGFloat, color: UIColor?, edgeInsets: UIEdgeInsets) -> NSAttributedString - + /** Returns the icon as an image with the given size and color. @@ -94,10 +94,10 @@ extension IconDrawable { public func attributedString(ofSize pointSize: CGFloat, color: UIColor?) -> NSAttributedString { let font = Self.font(ofSize: pointSize) - var attributes = [NSFontAttributeName : font] as [String : AnyObject] + var attributes: [NSAttributedStringKey: Any] = [NSAttributedStringKey.font : font] if let color = color { - attributes[NSForegroundColorAttributeName] = color + attributes[NSAttributedStringKey.foregroundColor] = color } return NSAttributedString(string: unicode, attributes: attributes) @@ -109,11 +109,11 @@ extension IconDrawable { let mString = NSMutableAttributedString(attributedString: aString) let range = NSRange(location: 0, length: mString.length) - - mString.addAttribute(NSBaselineOffsetAttributeName, value: edgeInsets.bottom-edgeInsets.top, range: range) - let leftSpace = NSAttributedString(string: " ", attributes: [NSKernAttributeName: edgeInsets.left]) - let rightSpace = NSAttributedString(string: " ", attributes: [NSKernAttributeName: edgeInsets.right]) + mString.addAttribute(NSAttributedStringKey.baselineOffset, value: edgeInsets.bottom-edgeInsets.top, range: range) + + let leftSpace = NSAttributedString(string: " ", attributes: [NSAttributedStringKey.kern: edgeInsets.left]) + let rightSpace = NSAttributedString(string: " ", attributes: [NSAttributedStringKey.kern: edgeInsets.right]) mString.insert(rightSpace, at: mString.length) mString.insert(leftSpace, at: 0) @@ -142,7 +142,7 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: range) + mString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: range) // Renders the attributed string as image using Text Kit UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) @@ -152,7 +152,7 @@ extension IconDrawable { return image! } - + public static func font(ofSize fontSize: CGFloat) -> UIFont { // Needs a default size, since zero would return a system font object. @@ -215,3 +215,4 @@ extension IconDrawable { return url as CFURL! } } + diff --git a/Source/IconImageView.swift b/Source/IconImageView.swift index 04f57ab..7a2afcc 100644 --- a/Source/IconImageView.swift +++ b/Source/IconImageView.swift @@ -9,52 +9,53 @@ import UIKit #if os(iOS) || os(tvOS) - -/** An Image View subclass, capable of rendering icons. Only supported for iOS and tvOS. */ -public class IconImageView: UIImageView { - - // MARK: - Public Variables - - /** The icon drawable to be used as image. */ - public var iconDrawable: IconDrawable? { - didSet { - updateIconImage() - } - } - // MARK: - Overrides - - public override var frame: CGRect { - didSet { - updateIconImage() + /** An Image View subclass, capable of rendering icons. Only supported for iOS and tvOS. */ + public class IconImageView: UIImageView { + + // MARK: - Public Variables + + /** The icon drawable to be used as image. */ + public var iconDrawable: IconDrawable? { + didSet { + updateIconImage() + } } - } - - public override func layoutSubviews() { - super.layoutSubviews() - updateIconImage() - } - - // MARK: - Image Constructor - - /** - Updates the icon image, only when the frame is not empty. - */ - fileprivate func updateIconImage() { + // MARK: - Overrides - // No need to update the icon with empty frame - if frame.isEmpty { - return + public override var frame: CGRect { + didSet { + updateIconImage() + } } - if let icon = iconDrawable { - let image = icon.image(ofSize: frame.size, color: nil) - self.image = image.withRenderingMode(.alwaysTemplate) - } else { - self.image = nil + public override func layoutSubviews() { + super.layoutSubviews() + + updateIconImage() + } + + // MARK: - Image Constructor + + /** + Updates the icon image, only when the frame is not empty. + */ + fileprivate func updateIconImage() { + + // No need to update the icon with empty frame + if frame.isEmpty { + return + } + + if let icon = iconDrawable { + let image = icon.image(ofSize: frame.size, color: nil) + self.image = image.withRenderingMode(.alwaysTemplate) + } else { + self.image = nil + } } } -} - + #endif + From a5630443b58f921cb47c2fd0e2b4fcb9ceb20341 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Mon, 26 Mar 2018 19:41:50 -0400 Subject: [PATCH 09/17] Update for Swift 4 * Update .swiftlint.yml to allow enum names --- .swiftlint.yml | 1 + Samples/Samples.xcodeproj/project.pbxproj | 71 ++++++++++++++----- Samples/iOS/Classes/FirstViewController.swift | 7 +- .../InterfaceController.swift | 9 ++- Source/IconDrawable.swift | 12 ++-- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 536c8d8..ba5b3c6 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -7,6 +7,7 @@ disabled_rules: - type_body_length - trailing_whitespace - cyclomatic_complexity + - identifier_name included: - Samples diff --git a/Samples/Samples.xcodeproj/project.pbxproj b/Samples/Samples.xcodeproj/project.pbxproj index d3c6fda..43e7213 100644 --- a/Samples/Samples.xcodeproj/project.pbxproj +++ b/Samples/Samples.xcodeproj/project.pbxproj @@ -493,22 +493,22 @@ }; F529152A1D83B08E006305E4 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0810; + LastSwiftMigration = 0920; ProvisioningStyle = Manual; }; F558DA061CF1AF1A0014717C = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0810; + LastSwiftMigration = 0920; ProvisioningStyle = Manual; }; F569775E1DC9CAE3005EDE73 = { CreatedOnToolsVersion = 8.1; - LastSwiftMigration = 0810; + LastSwiftMigration = 0920; ProvisioningStyle = Manual; }; F569776A1DC9CAE3005EDE73 = { CreatedOnToolsVersion = 8.1; - LastSwiftMigration = 0810; + LastSwiftMigration = 0920; ProvisioningStyle = Manual; }; }; @@ -588,13 +588,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-tvOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 0F1636CC8BBFF46B28293083 /* [CP] Check Pods Manifest.lock */ = { @@ -603,13 +606,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 2FE47DC5D0C4319209558F1E /* [CP] Copy Pods Resources */ = { @@ -633,9 +639,12 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-watchOS Extension/Pods-watchOS Extension-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-watchOS2.0/Iconic.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -663,9 +672,12 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-tvOS/Pods-tvOS-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-tvOS9.0/Iconic.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -678,9 +690,12 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-iOS/Pods-iOS-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-iOS8.0/Iconic.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -693,13 +708,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Tests-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 7DFCE678A53C4566F95D47F2 /* [CP] Copy Pods Resources */ = { @@ -753,13 +771,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-watchOS Extension-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; B72B7A6B427AB1106382AE87 /* [CP] Embed Pods Frameworks */ = { @@ -768,9 +789,14 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Iconic-iOS9.3/Iconic.framework", + "${BUILT_PRODUCTS_DIR}/FBSnapshotTestCase/FBSnapshotTestCase.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Iconic.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSnapshotTestCase.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -825,13 +851,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-iOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -995,7 +1024,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Supporting Files/Tests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1013,7 +1043,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.Iconic-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Supporting Files/Tests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1119,7 +1150,8 @@ PRODUCT_NAME = iOS; SWIFT_OBJC_BRIDGING_HEADER = "iOS/Classes/iOS-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1137,7 +1169,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-ios"; PRODUCT_NAME = iOS; SWIFT_OBJC_BRIDGING_HEADER = "iOS/Classes/iOS-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1159,7 +1192,8 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1181,7 +1215,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1204,7 +1239,8 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1226,7 +1262,8 @@ PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; diff --git a/Samples/iOS/Classes/FirstViewController.swift b/Samples/iOS/Classes/FirstViewController.swift index c590d15..d801cb7 100644 --- a/Samples/iOS/Classes/FirstViewController.swift +++ b/Samples/iOS/Classes/FirstViewController.swift @@ -108,8 +108,7 @@ class FirstViewController: UITableViewController { } extension UIViewController { - - func updateTitleView() { + @objc func updateTitleView() { guard let title = self.title else { return @@ -123,8 +122,8 @@ extension UIViewController { let titleSize = CGFloat(20) let edgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: titleSize/2) - let attributes = [NSForegroundColorAttributeName: color, - NSFontAttributeName: UIFont.systemFont(ofSize: titleSize)] as [String : AnyObject] + let attributes = [NSAttributedStringKey.foregroundColor: color, + NSAttributedStringKey.font: UIFont.systemFont(ofSize: titleSize)] as [NSAttributedStringKey: Any] let mString = NSMutableAttributedString(string: title, attributes: attributes) diff --git a/Samples/watchOS Extension/InterfaceController.swift b/Samples/watchOS Extension/InterfaceController.swift index 625574e..4166d51 100644 --- a/Samples/watchOS Extension/InterfaceController.swift +++ b/Samples/watchOS Extension/InterfaceController.swift @@ -24,17 +24,16 @@ class InterfaceController: WKInterfaceController { let githubIcon = FontAwesomeIcon.githubIcon let upArrowIcon = FontAwesomeIcon.angleUpIcon let downArrowIcon = FontAwesomeIcon.angleDownIcon - - override class func initialize() { - + + private static let runOnce: Void = { // It is important to register the icon font as soon as possible, // and make the resources available right after launching the app. // // This example uses Awesome Font // http://fontawesome.io/cheatsheet/ - + FontAwesomeIcon.register() - } + }() override func awake(withContext context: Any?) { super.awake(withContext: context) diff --git a/Source/IconDrawable.swift b/Source/IconDrawable.swift index 0b610ce..c4d49e4 100644 --- a/Source/IconDrawable.swift +++ b/Source/IconDrawable.swift @@ -94,10 +94,10 @@ extension IconDrawable { public func attributedString(ofSize pointSize: CGFloat, color: UIColor?) -> NSAttributedString { let font = Self.font(ofSize: pointSize) - var attributes = [NSFontAttributeName : font] as [String : AnyObject] + var attributes = [NSAttributedStringKey.font : font] as [NSAttributedStringKey : Any] if let color = color { - attributes[NSForegroundColorAttributeName] = color + attributes[NSAttributedStringKey.foregroundColor] = color } return NSAttributedString(string: unicode, attributes: attributes) @@ -110,10 +110,10 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSBaselineOffsetAttributeName, value: edgeInsets.bottom-edgeInsets.top, range: range) + mString.addAttribute(NSAttributedStringKey.baselineOffset, value: edgeInsets.bottom-edgeInsets.top, range: range) - let leftSpace = NSAttributedString(string: " ", attributes: [NSKernAttributeName: edgeInsets.left]) - let rightSpace = NSAttributedString(string: " ", attributes: [NSKernAttributeName: edgeInsets.right]) + let leftSpace = NSAttributedString(string: " ", attributes: [NSAttributedStringKey.kern: edgeInsets.left]) + let rightSpace = NSAttributedString(string: " ", attributes: [NSAttributedStringKey.kern: edgeInsets.right]) mString.insert(rightSpace, at: mString.length) mString.insert(leftSpace, at: 0) @@ -142,7 +142,7 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: range) + mString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: range) // Renders the attributed string as image using Text Kit UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) From 592eda0475093344d7ad2e58125acc8bbc3f390d Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 26 Sep 2018 22:13:17 -0700 Subject: [PATCH 10/17] Update for Swift 4.2 --- Source/IconDrawable.swift | 39 +++++++++++++++++++---------------- Source/iconic-default.stencil | 10 ++++----- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Source/IconDrawable.swift b/Source/IconDrawable.swift index 6b6be9c..762271f 100644 --- a/Source/IconDrawable.swift +++ b/Source/IconDrawable.swift @@ -95,10 +95,10 @@ extension IconDrawable { let font = Self.font(ofSize: pointSize) - var attributes: [NSAttributedStringKey: Any] = [NSAttributedStringKey.font : font] + var attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font : font] if let color = color { - attributes[NSAttributedStringKey.foregroundColor] = color + attributes[NSAttributedString.Key.foregroundColor] = color } return NSAttributedString(string: unicode, attributes: attributes) @@ -111,10 +111,10 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSAttributedStringKey.baselineOffset, value: edgeInsets.bottom-edgeInsets.top, range: range) + mString.addAttribute(NSAttributedString.Key.baselineOffset, value: edgeInsets.bottom-edgeInsets.top, range: range) - let leftSpace = NSAttributedString(string: " ", attributes: [NSAttributedStringKey.kern: edgeInsets.left]) - let rightSpace = NSAttributedString(string: " ", attributes: [NSAttributedStringKey.kern: edgeInsets.right]) + let leftSpace = NSAttributedString(string: " ", attributes: [NSAttributedString.Key.kern: edgeInsets.left]) + let rightSpace = NSAttributedString(string: " ", attributes: [NSAttributedString.Key.kern: edgeInsets.right]) mString.insert(rightSpace, at: mString.length) mString.insert(leftSpace, at: 0) @@ -143,7 +143,7 @@ extension IconDrawable { let range = NSRange(location: 0, length: mString.length) - mString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: range) + mString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: range) // Renders the attributed string as image using Text Kit UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0) @@ -169,9 +169,12 @@ extension IconDrawable { return } - let url = resourceUrl() + guard let url = resourceUrl() else { + print("Unable to register font '\(familyName)' beacuse URL was nil!") + return + } var error: Unmanaged? = nil - let descriptors = CTFontManagerCreateFontDescriptorsFromURL(url) as NSArray? + let descriptors = CTFontManagerCreateFontDescriptorsFromURL(url as CFURL) as NSArray? guard let descriptor = (descriptors as? [CTFontDescriptor])?.first else { assertionFailure("Could not retrieve font descriptors of font at path '\(url)',") @@ -182,8 +185,8 @@ extension IconDrawable { let fontName = CTFontCopyPostScriptName(font) as String // Registers font dynamically - if CTFontManagerRegisterFontsForURL(url, .none, &error) == false || error != nil { - assertionFailure("Failed registering font with the postscript name '\(fontName)' at path '\(url)' with error: \(error).") + if CTFontManagerRegisterFontsForURL(url as CFURL, .none, &error) == false || error != nil { + assertionFailure("Failed registering font with the postscript name '\(fontName)' at path '\(url)' with error: \(String(describing: error)).") } print("Font '\(familyName)' registered successfully!") @@ -196,24 +199,24 @@ extension IconDrawable { return } - let url = resourceUrl() + guard let url = resourceUrl() else { + print("Unable to unregister font '\(familyName)' beacuse URL was nil!") + return + } var error: Unmanaged? = nil - if CTFontManagerUnregisterFontsForURL(url, .none, &error) == false || error != nil { - assertionFailure("Failed unregistering font with name '\(familyName)' at path '\(url)' with error: \(error).") + if CTFontManagerUnregisterFontsForURL(url as CFURL, .none, &error) == false || error != nil { + assertionFailure("Failed unregistering font with name '\(familyName)' at path '\(url)' with error: \(String(describing: error)).") } print("Font '\(familyName)' unregistered successfully!") } - fileprivate static func resourceUrl() -> CFURL { - + fileprivate static func resourceUrl() -> URL? { let extensions = ["otf", "ttf"] let bundle = Bundle(for: Iconic.self) - let url = extensions.flatMap { bundle.url(forResource: familyName, withExtension: $0) }.first - - return url as CFURL! + return extensions.compactMap { bundle.url(forResource: familyName, withExtension: $0) }.first } } diff --git a/Source/iconic-default.stencil b/Source/iconic-default.stencil index 6ff6405..e115082 100644 --- a/Source/iconic-default.stencil +++ b/Source/iconic-default.stencil @@ -122,7 +122,7 @@ public extension UIBarButtonItem { - parameter action: The action to send to target when this item is selected. */ convenience init(withIcon icon: {{enumName}}, size: CGSize, target: AnyObject?, action: Selector) { - + let image = icon.image(ofSize: size, color: .black) self.init(image: image, style: .plain, target: target, action: action) } @@ -139,7 +139,7 @@ public extension UITabBarItem { - parameter title: The item's title. If nil, a title is not displayed. */ convenience init(withIcon icon: {{enumName}}, size: CGSize, title: String?) { - + let image = icon.image(ofSize: size, color: .black) self.init(title: title, image: image, tag: icon.rawValue) } @@ -153,10 +153,10 @@ public extension UIButton { - parameter icon: The icon to be used as image. - parameter size: The size of the image, in points. - parameter color: The color of the image. - - parameter state: The state that uses the specified title. The values are described in UIControlState. + - parameter state: The state that uses the specified title. The values are described in UIControl.State. */ - func setIconImage(withIcon icon: {{enumName}}, size: CGSize, color: UIColor?, forState state: UIControlState) { - + func setIconImage(withIcon icon: {{enumName}}, size: CGSize, color: UIColor?, forState state: UIControl.State) { + let image = icon.image(ofSize: size, color: color ?? .black) setImage(image, for: state) } From 1b8cb442ce4dc5e0a1461f531ce4329f16cb0afa Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 26 Sep 2018 22:13:33 -0700 Subject: [PATCH 11/17] Support passing in a custom name to use for the font --- Source/Iconizer.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Source/Iconizer.sh b/Source/Iconizer.sh index d4470ca..a49e51c 100755 --- a/Source/Iconizer.sh +++ b/Source/Iconizer.sh @@ -6,12 +6,15 @@ # Created by Ignacio Romero on 5/28/16. # Copyright © 2016 DZN Labs All rights reserved. # -# Script in charge of executing SwitfGen, passing the icon font file path, the enum name and the custom stencil as arguments. +# Script in charge of executing SwiftGen, passing the icon font file path, the enum name and the custom stencil as arguments. # # The optional font file path passed as arg INPUT_PATH=$1 +# The optional custom name to use instead of deriving one via file name +CUSTOM_NAME=$2 + # The root path for the generated files OUTPUT_PATH=Source @@ -53,10 +56,8 @@ function iconize() # Input variables FONT_PATH=$1 FONT_NAME=$2 + OUTPUT_NAME=$3 - # Capitalized first word of the file name, with the 'Icon' suffix. - # ie: FontAwesomeIcon out of a string like 'FontAwesome' - OUTPUT_NAME=$( getFileTitle "${FONT_NAME}" ) echo "Iconizer: Generating API name '${OUTPUT_NAME}'" # Creates the output folder (no error if existing) @@ -78,17 +79,25 @@ function init() { # Input variables FONT_PATH=$1 + CUSTOM_NAME=$2 echo "Iconizer: Initializing with font at path '${FONT_PATH}'" # Input's file name and extension FONT_NAME=$(basename "${FONT_PATH}") INPUT_EXTENSION="${FONT_NAME##*.}" + + if [ -z "$CUSTOM_NAME" ]; then + # Capitalized first word of the file name, with the 'Icon' suffix. + # ie: FontAwesomeIcon out of a string like 'FontAwesome' + CUSTOM_NAME=$( getFileTitle "${FONT_NAME}" ) + fi + echo "Iconizer: Processing file '${FONT_NAME}' with extension '${INPUT_EXTENSION}'" # Only TTF and OTF are supported font files if [ ${INPUT_EXTENSION} = 'ttf' ] || [ ${INPUT_EXTENSION} = 'otf' ]; then - iconize ${FONT_PATH} ${FONT_NAME} + iconize ${FONT_PATH} ${FONT_NAME} ${CUSTOM_NAME} else echo "Iconizer: Unsupported '${INPUT_EXTENSION}' file. Please provide a TTF or OTF file path." fi @@ -102,5 +111,5 @@ if [ -z ${INPUT_PATH} ]; then # Uses FontAwesome as default init 'Fonts/FontAwesome/FontAwesome.otf' else - init ${INPUT_PATH} + init ${INPUT_PATH} ${CUSTOM_NAME} fi From 96ccae984ae48aa986b53f0e30a54eda64c76a00 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 26 Sep 2018 22:19:01 -0700 Subject: [PATCH 12/17] Support custom font names during pod install --- Iconic.podspec | 2 +- Source/Iconizer.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Iconic.podspec b/Iconic.podspec index 2cc9857..d0d6a6a 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -30,5 +30,5 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.watchos.deployment_target = '2.0' - s.prepare_command = "sh Source/Iconizer.sh '#{ENV['FONT_PATH']}' --verbose" + s.prepare_command = "sh Source/Iconizer.sh '#{ENV['FONT_PATH']}' '#{ENV['CUSTOM_FONT_NAME']}'" end diff --git a/Source/Iconizer.sh b/Source/Iconizer.sh index a49e51c..489b4f7 100755 --- a/Source/Iconizer.sh +++ b/Source/Iconizer.sh @@ -110,6 +110,8 @@ if [ -z ${INPUT_PATH} ]; then # Uses FontAwesome as default init 'Fonts/FontAwesome/FontAwesome.otf' +elif [ -z ${CUSTOM_NAME} ]; then + init ${INPUT_PATH} else init ${INPUT_PATH} ${CUSTOM_NAME} fi From c5bdf5b849be60fdf05852e7a51f99569da52976 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 26 Sep 2018 22:36:53 -0700 Subject: [PATCH 13/17] Add an initializer with a fallback value --- Source/iconic-default.stencil | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/iconic-default.stencil b/Source/iconic-default.stencil index e115082..bb4320b 100644 --- a/Source/iconic-default.stencil +++ b/Source/iconic-default.stencil @@ -183,7 +183,7 @@ extension {{enumName}} : IconDrawable { /** Creates a new instance with the specified icon name. - If there is no valid name is recognised, this initializer falls back to the first available icon. + If there is no valid name recognised, this initializer falls back to the first available icon. - parameter iconName: The icon name to use for the new instance. */ @@ -196,6 +196,23 @@ extension {{enumName}} : IconDrawable { } } + /** + Creates a new instance with the specified icon name. + If there is no valid name recognised, the given fallback value will be used. + If the fallback value is not recognised, this initializer falls back to the first available icon. + + - parameter iconName: The icon name to use for the new instance. + - parameter fallbackIconName: The fallback icon name to use for the new instance if the iconName doesn't exist. + */ + public init(named iconName: String, fallbackIconName: String) { + switch iconName.lowercased() { + {% for icon in icons %} + case "{{icon.name|swiftIdentifier|lowercase}}": self = .{{icon.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord}}Icon + {% endfor %} + default: self = {{enumName}}(named: fallbackIconName) + } + } + /** The icon's name. */ public var name: String { switch self { From f984e1e7e0ded870a09f79d980e498b24427af9c Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 26 Sep 2018 22:37:16 -0700 Subject: [PATCH 14/17] Add CaseIterable to generated enums so that a dictionary of all values can be easily generated --- Source/iconic-default.stencil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/iconic-default.stencil b/Source/iconic-default.stencil index bb4320b..40d17b8 100644 --- a/Source/iconic-default.stencil +++ b/Source/iconic-default.stencil @@ -165,7 +165,7 @@ public extension UIButton { #endif /** A list with available icon glyphs from the icon font. */ -@objc public enum {{enumName}}: Int { +@objc public enum {{enumName}}: Int, CaseIterable { {% for icon in icons %} case {{icon.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord}}Icon {% endfor %} From 0f2da5e5b9577f4bba526d917303820e5a543305 Mon Sep 17 00:00:00 2001 From: jkyin Date: Fri, 9 Nov 2018 23:07:18 +0800 Subject: [PATCH 15/17] Fix swift 4.2 compile error --- Iconic.podspec | 4 +- Samples/Samples.xcodeproj/project.pbxproj | 98 ++----------------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ Samples/iOS/Classes/AppDelegate.swift | 4 +- Samples/iOS/Classes/FirstViewController.swift | 6 +- .../iOS/Classes/SecondViewController.swift | 4 +- .../InterfaceController.swift | 5 +- Source/iconic-default.stencil | 6 +- 8 files changed, 31 insertions(+), 104 deletions(-) create mode 100644 Samples/Samples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Iconic.podspec b/Iconic.podspec index d0d6a6a..eea54ef 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -1,4 +1,4 @@ -@version = '1.5' +@version = '1.5.1' Pod::Spec.new do |s| @@ -17,7 +17,7 @@ Pod::Spec.new do |s| } s.source = { - :git => 'https://github.com/jkyin/Iconic.git', + :git => 'https://github.com/dzenbot/Iconic.git', :tag => @version } diff --git a/Samples/Samples.xcodeproj/project.pbxproj b/Samples/Samples.xcodeproj/project.pbxproj index 4994a64..1a10dd8 100644 --- a/Samples/Samples.xcodeproj/project.pbxproj +++ b/Samples/Samples.xcodeproj/project.pbxproj @@ -380,7 +380,6 @@ F50ADBFC1D112CDA004A5A4C /* Resources */, F51590BA1DEB811500C23C25 /* Run SwiftLint */, 66899069AA8DB41CAA16348F /* [CP] Embed Pods Frameworks */, - 4F8B2FA0AB7958800E8CA04A /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -400,7 +399,6 @@ F52915291D83B08E006305E4 /* Resources */, F52915281D83B08E006305E4 /* Frameworks */, B72B7A6B427AB1106382AE87 /* [CP] Embed Pods Frameworks */, - 2FE47DC5D0C4319209558F1E /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -423,7 +421,6 @@ F56977811DC9CAE3005EDE73 /* Embed Watch Content */, F51590B91DEB80E200C23C25 /* Run SwiftLint */, 66EF12CCF24C41A99ED12DFB /* [CP] Embed Pods Frameworks */, - 7DFCE678A53C4566F95D47F2 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -443,7 +440,6 @@ F569775D1DC9CAE3005EDE73 /* Resources */, F569777F1DC9CAE3005EDE73 /* Embed App Extensions */, 4227694CE5B908A8E2312F7C /* Frameworks */, - 890D74CD09505F4756B3B136 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -465,7 +461,6 @@ F56977691DC9CAE3005EDE73 /* Resources */, F51590BB1DEB812700C23C25 /* Run SwiftLint */, 4615DB9C948EDC46C04C07FD /* [CP] Embed Pods Frameworks */, - 97629D2F95B3544A817EE61C /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -618,21 +613,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 2FE47DC5D0C4319209558F1E /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 4615DB9C948EDC46C04C07FD /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -651,21 +631,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS Extension/Pods-watchOS Extension-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 4F8B2FA0AB7958800E8CA04A /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-tvOS/Pods-tvOS-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 66899069AA8DB41CAA16348F /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -720,51 +685,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 7DFCE678A53C4566F95D47F2 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-iOS/Pods-iOS-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 890D74CD09505F4756B3B136 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS/Pods-watchOS-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 97629D2F95B3544A817EE61C /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-watchOS Extension/Pods-watchOS Extension-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; B31DA642B1C54052FDD0ACF8 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -983,6 +903,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-tvos"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1002,6 +923,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-tvos"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1022,7 +944,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Supporting Files/Tests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -1040,7 +962,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.Iconic-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Supporting Files/Tests-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -1148,7 +1070,7 @@ PRODUCT_NAME = iOS; SWIFT_OBJC_BRIDGING_HEADER = "iOS/Classes/iOS-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -1166,7 +1088,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.dzn.iconic-ios"; PRODUCT_NAME = iOS; SWIFT_OBJC_BRIDGING_HEADER = "iOS/Classes/iOS-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1188,7 +1110,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1210,7 +1132,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1233,7 +1155,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1255,7 +1177,7 @@ PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; diff --git a/Samples/Samples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Samples/Samples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Samples/Samples.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Samples/iOS/Classes/AppDelegate.swift b/Samples/iOS/Classes/AppDelegate.swift index c18b68b..5a61b47 100644 --- a/Samples/iOS/Classes/AppDelegate.swift +++ b/Samples/iOS/Classes/AppDelegate.swift @@ -27,11 +27,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { FontAwesomeIcon.register() } - func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + private func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } } diff --git a/Samples/iOS/Classes/FirstViewController.swift b/Samples/iOS/Classes/FirstViewController.swift index d801cb7..0c1cbae 100644 --- a/Samples/iOS/Classes/FirstViewController.swift +++ b/Samples/iOS/Classes/FirstViewController.swift @@ -44,7 +44,7 @@ class FirstViewController: UITableViewController { super.viewWillAppear(animated) } - func didTapRightItem() { + @objc func didTapRightItem() { // Do something } @@ -122,8 +122,8 @@ extension UIViewController { let titleSize = CGFloat(20) let edgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: titleSize/2) - let attributes = [NSAttributedStringKey.foregroundColor: color, - NSAttributedStringKey.font: UIFont.systemFont(ofSize: titleSize)] as [NSAttributedStringKey: Any] + let attributes = [NSAttributedString.Key.foregroundColor: color, + NSAttributedString.Key.font: UIFont.systemFont(ofSize: titleSize)] as [NSAttributedString.Key: Any] let mString = NSMutableAttributedString(string: title, attributes: attributes) diff --git a/Samples/iOS/Classes/SecondViewController.swift b/Samples/iOS/Classes/SecondViewController.swift index a8c7910..8ef7908 100644 --- a/Samples/iOS/Classes/SecondViewController.swift +++ b/Samples/iOS/Classes/SecondViewController.swift @@ -46,7 +46,7 @@ class SecondViewController: UIViewController { super.viewWillAppear(animated) } - func didTapRightItem() { + @objc func didTapRightItem() { navigationController?.navigationBar.isHidden = true tabBarController?.tabBar.isHidden = true } @@ -89,7 +89,7 @@ class StepSlider: UISlider { self.addGestureRecognizer(tapGesture) } - func didTapSlider(_ gesture: UIGestureRecognizer) { + @objc func didTapSlider(_ gesture: UIGestureRecognizer) { let location = gesture.location(in: gesture.view) diff --git a/Samples/watchOS Extension/InterfaceController.swift b/Samples/watchOS Extension/InterfaceController.swift index e2cd24b..3f2efcb 100644 --- a/Samples/watchOS Extension/InterfaceController.swift +++ b/Samples/watchOS Extension/InterfaceController.swift @@ -35,10 +35,7 @@ class InterfaceController: WKInterfaceController { FontAwesomeIcon.register() }() - static let shared : InterfaceController = { - $0.initialize() - return $0 - }(InterfaceController()) + static let shared = InterfaceController() override func awake(withContext context: Any?) { super.awake(withContext: context) diff --git a/Source/iconic-default.stencil b/Source/iconic-default.stencil index 40d17b8..47e216f 100644 --- a/Source/iconic-default.stencil +++ b/Source/iconic-default.stencil @@ -111,7 +111,7 @@ public final class {{enumName}}View: IconImageView { } } -public extension UIBarButtonItem { +@objc public extension UIBarButtonItem { /** Initializes a new item using the specified icon and other properties. @@ -128,7 +128,7 @@ public extension UIBarButtonItem { } } -public extension UITabBarItem { +@objc public extension UITabBarItem { /** Initializes a new item using the specified icon and other properties. @@ -145,7 +145,7 @@ public extension UITabBarItem { } } -public extension UIButton { +@objc public extension UIButton { /** Sets the icon to use for the specified state. From de2aa7f2ceec7f5ba9e0236c9acf1502ca50e3f1 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 1 May 2019 20:12:14 -0700 Subject: [PATCH 16/17] Preserve all of source --- Iconic.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Iconic.podspec b/Iconic.podspec index eea54ef..bd019c6 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.source_files = 'Source/*.{swift}' s.resources = 'Source/**/*.{ttf,otf}' - s.preserve_paths = 'Source/Catalog/**/*.*' + s.preserve_paths = 'Source/' s.framework = 'UIKit', 'CoreText' s.ios.deployment_target = '8.0' From 662ba7521ca288e9619aebf2addddaaeabd31261 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 15 May 2019 19:30:45 -0700 Subject: [PATCH 17/17] Minor odds and ends --- Iconic.podspec | 2 +- Source/IconImageView.swift | 84 +++++++++++++++++------------------ Source/iconic-default.stencil | 8 ---- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/Iconic.podspec b/Iconic.podspec index bd019c6..7c463ee 100644 --- a/Iconic.podspec +++ b/Iconic.podspec @@ -1,4 +1,4 @@ -@version = '1.5.1' +@version = '1.4' Pod::Spec.new do |s| diff --git a/Source/IconImageView.swift b/Source/IconImageView.swift index 7a2afcc..0f99e36 100644 --- a/Source/IconImageView.swift +++ b/Source/IconImageView.swift @@ -9,53 +9,51 @@ import UIKit #if os(iOS) || os(tvOS) - - /** An Image View subclass, capable of rendering icons. Only supported for iOS and tvOS. */ - public class IconImageView: UIImageView { - - // MARK: - Public Variables - - /** The icon drawable to be used as image. */ - public var iconDrawable: IconDrawable? { - didSet { - updateIconImage() - } - } - - // MARK: - Overrides - - public override var frame: CGRect { - didSet { - updateIconImage() - } +/** An Image View subclass, capable of rendering icons. Only supported for iOS and tvOS. */ +public class IconImageView: UIImageView { + + // MARK: - Public Variables + + /** The icon drawable to be used as image. */ + public var iconDrawable: IconDrawable? { + didSet { + updateIconImage() } - - public override func layoutSubviews() { - super.layoutSubviews() - + } + + // MARK: - Overrides + + public override var frame: CGRect { + didSet { updateIconImage() } - - // MARK: - Image Constructor - - /** - Updates the icon image, only when the frame is not empty. - */ - fileprivate func updateIconImage() { - - // No need to update the icon with empty frame - if frame.isEmpty { - return - } - - if let icon = iconDrawable { - let image = icon.image(ofSize: frame.size, color: nil) - self.image = image.withRenderingMode(.alwaysTemplate) - } else { - self.image = nil - } + } + + public override func layoutSubviews() { + super.layoutSubviews() + + updateIconImage() + } + + // MARK: - Image Constructor + + /** + Updates the icon image, only when the frame is not empty. + */ + fileprivate func updateIconImage() { + + // No need to update the icon with empty frame + if frame.isEmpty { + return + } + + if let icon = iconDrawable { + let image = icon.image(ofSize: frame.size, color: nil) + self.image = image.withRenderingMode(.alwaysTemplate) + } else { + self.image = nil } } - +} #endif diff --git a/Source/iconic-default.stencil b/Source/iconic-default.stencil index 47e216f..c6f896f 100644 --- a/Source/iconic-default.stencil +++ b/Source/iconic-default.stencil @@ -11,11 +11,6 @@ import UIKit return {{enumName}}.familyName as NSString } - /** The icon font's total count of available icons. */ - class var {{enumName|lowerFirstWord}}Count: Int { - return {{enumName}}.count - } - /** Returns the icon font object for the specified size. @@ -169,9 +164,6 @@ public final class {{enumName}}View: IconImageView { {% for icon in icons %} case {{icon.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord}}Icon {% endfor %} - - /** The icon font's total count of available icons. */ - public static var count: Int { return {{ icons.count }} } } extension {{enumName}} : IconDrawable {