Skip to content

Commit

Permalink
#17 update to current swift 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marekmatula committed Mar 9, 2018
1 parent 20368dc commit b70e9f4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 27 deletions.
36 changes: 26 additions & 10 deletions Example/FontIcons.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,18 +300,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = V6SD56ATEW;
LastSwiftMigration = 0800;
DevelopmentTeam = 26UE33584E;
LastSwiftMigration = 0920;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 64ZAN7QS6N;
LastSwiftMigration = 0800;
LastSwiftMigration = 0920;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
Expand Down Expand Up @@ -533,14 +533,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_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_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -581,14 +587,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_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_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -620,13 +632,14 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = V6SD56ATEW;
DEVELOPMENT_TEAM = 26UE33584E;
INFOPLIST_FILE = FontIcons/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -636,13 +649,14 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = V6SD56ATEW;
DEVELOPMENT_TEAM = 26UE33584E;
INFOPLIST_FILE = FontIcons/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -665,7 +679,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FontIcons_Example.app/FontIcons_Example";
};
name = Debug;
Expand All @@ -685,7 +700,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FontIcons_Example.app/FontIcons_Example";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -69,6 +70,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 2 additions & 2 deletions Example/FontIcons/generator/SourceGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GenericGenerator{
}

private func lowercaseFirstLetter(text:String) -> String {
let first = String(text.characters.prefix(1)).lowercased()
let other = String(text.characters.dropFirst())
let first = String(text.prefix(1)).lowercased()
let other = String(text.dropFirst())
return first + other
}

Expand Down
3 changes: 2 additions & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end

6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ EXTERNAL SOURCES:
:path: ../

SPEC CHECKSUMS:
FontIcons: 21cfaf760b251d5ae9439830d3953b53e9750dc2
FontIcons: d24b4b759e678266638d6f973b8621b73a44ce60

PODFILE CHECKSUM: 2aad07d3d6d10ddb5a0f9237472a74846743e25a
PODFILE CHECKSUM: ed146b582b93723cf874940f9b9ddd6dfbdd2815

COCOAPODS: 1.3.1
COCOAPODS: 1.4.0
18 changes: 9 additions & 9 deletions Pod/Classes/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
import Foundation
import UIKit

private let defaultSize:CGFloat = 23.0
public let defaultFontIconSize:CGFloat = 23.0

public extension UIBarButtonItem {

func setFontIcon(_ icon: FontEnum, size: CGFloat = defaultSize) {
func setFontIcon(_ icon: FontEnum, size: CGFloat = defaultFontIconSize) {
setFontIconText(prefix: "", icon: icon, postfix: "", size: size)
}

func setFontIconText(prefix: String, icon: FontEnum, postfix: String, size: CGFloat) {

let font = FontLoader.getFont(icon, iconSize: size)
setTitleTextAttributes([NSFontAttributeName: font], for: .normal)
setTitleTextAttributes([NSFontAttributeName: font], for: .highlighted)
setTitleTextAttributes([NSFontAttributeName: font], for: .disabled)
setTitleTextAttributes([NSAttributedStringKey.font: font], for: .normal)
setTitleTextAttributes([NSAttributedStringKey.font: font], for: .highlighted)
setTitleTextAttributes([NSAttributedStringKey.font: font], for: .disabled)
#if giOS8OrGreater
setTitleTextAttributes([NSFontAttributeName: font], for: .focused)
#endif
Expand Down Expand Up @@ -56,7 +56,7 @@ public extension UIButton {

public extension UILabel {

func setFontIcon(_ icon: FontEnum, size: CGFloat = defaultSize) {
func setFontIcon(_ icon: FontEnum, size: CGFloat = defaultFontIconSize) {
setFontIconText(prefix: "", icon: icon, postfix: "", size: size)
}

Expand Down Expand Up @@ -90,9 +90,9 @@ public extension UISegmentedControl {

public func setFontIcon(_ icon: FontEnum, forSegmentAtIndex segment: Int) {

let font = FontLoader.getFont(icon, iconSize: defaultSize)
let font = FontLoader.getFont(icon, iconSize: defaultFontIconSize)

setTitleTextAttributes([NSFontAttributeName: font], for: UIControlState())
setTitleTextAttributes([NSAttributedStringKey.font: font], for: UIControlState())
setTitle(icon.unicode(), forSegmentAt: segment)
}
}
Expand All @@ -110,7 +110,7 @@ public extension UIImage {
let fontSize = min(size.width / fontAspectRatio, size.height)

let font = FontLoader.getFont(icon, iconSize: fontSize)
let attributes = [NSFontAttributeName: font, NSForegroundColorAttributeName: textColor, NSBackgroundColorAttributeName: backgroundColor, NSParagraphStyleAttributeName: paragraph]
let attributes = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: textColor, NSAttributedStringKey.backgroundColor: backgroundColor, NSAttributedStringKey.paragraphStyle: paragraph]

let attributedString = NSAttributedString(string: icon.unicode(), attributes: attributes)
UIGraphicsBeginImageContextWithOptions(size, false , 0.0)
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/FontIcons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ open class FontLoader {
let font = CGFont(provider!)

var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) {
if !CTFontManagerRegisterGraphicsFont(font!, &error) {

let errorDescription: CFString = CFErrorCopyDescription(error!.takeUnretainedValue())
let nsError = error!.takeUnretainedValue() as AnyObject as! NSError
Expand Down

0 comments on commit b70e9f4

Please sign in to comment.