Skip to content

Commit

Permalink
CMOB-1594: Update iOS 11 (#31)
Browse files Browse the repository at this point in the history
* CMOB-1594: Update iOS 11

* CMOB-1594: Update Swift 4.2 + fix tests

* CMOB-1594: Update demo app

* CMOB-1594: Update for release
  • Loading branch information
kerr-marinmiller-hs authored Nov 27, 2018
1 parent c1bcd9b commit 9318f4f
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 58 deletions.
22 changes: 1 addition & 21 deletions Demo/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}

func applicationWillResignActive(_ application: UIApplication) {

}

func applicationDidEnterBackground(_ application: UIApplication) {

}

func applicationWillEnterForeground(_ application: UIApplication) {

}

func applicationDidBecomeActive(_ application: UIApplication) {

}

func applicationWillTerminate(_ application: UIApplication) {

}

}
6 changes: 3 additions & 3 deletions Demo/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class ViewController: UIViewController {
super.viewDidLoad()
tokenTextVC = TokenTextViewController()
tokenTextVC.delegate = self
addChildViewController(tokenTextVC)
addChild(tokenTextVC)
textInputContainer.addSubview(tokenTextVC.view)
tokenTextVC.view.frame = textInputContainer.bounds
tokenTextVC.didMove(toParentViewController: self)
tokenTextVC.didMove(toParent: self)
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -63,7 +63,7 @@ extension ViewController: TokenTextViewControllerDelegate {
present(alert, animated: true, completion: nil)
}

func tokenTextViewTextStorageIsUpdatingFormatting(_ sender: TokenTextViewController, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedStringKey: Any], forRange: NSRange)] {
func tokenTextViewTextStorageIsUpdatingFormatting(_ sender: TokenTextViewController, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedString.Key: Any], forRange: NSRange)] {
return []
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ TokenUI has been developed for use in the Hootsuite iOS app.

## Requirements

- iOS 10.0+
- Xcode 8.0+
- iOS 11.0+
- Xcode 10.0+

## Demo Projects

Expand Down
2 changes: 1 addition & 1 deletion Sources/PasteMediaTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class PasteMediaTextView: UITextView {
var results: [PasteboardItem] = []
for (index, item) in UIPasteboard.general.items.enumerated() {
if let type = acceptedTypes.filter({ item[$0.rawValue] != nil }).first,
let data = UIPasteboard.general.data(forPasteboardType: type.rawValue, inItemSet: IndexSet([index]))?.first as? Data {
let data = UIPasteboard.general.data(forPasteboardType: type.rawValue, inItemSet: IndexSet([index]))?.first {
results.append(PasteboardItem(type: type, data: data))
}
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/TokenTextViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public protocol TokenTextViewControllerDelegate: class {
func tokenTextViewDidAddToken(_ sender: TokenTextViewController, tokenRef: TokenReference)

/// Called when the formatting is being updated.
func tokenTextViewTextStorageIsUpdatingFormatting(_ sender: TokenTextViewController, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedStringKey: Any], forRange: NSRange)]
func tokenTextViewTextStorageIsUpdatingFormatting(_ sender: TokenTextViewController, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedString.Key: Any], forRange: NSRange)]

/// Allows to customize the background color for a token.
func tokenTextViewBackgroundColourForTokenRef(_ sender: TokenTextViewController, tokenRef: TokenReference) -> UIColor?
Expand Down Expand Up @@ -92,8 +92,8 @@ public enum TokenTextInputCancellationReason {
/// A data structure to hold constants for the `TokenTextViewController`.
public struct TokenTextViewControllerConstants {

public static let tokenAttributeName = NSAttributedStringKey(rawValue: "com.hootsuite.token")
static let inputTextAttributeName = NSAttributedStringKey(rawValue: "com.hootsuite.input")
public static let tokenAttributeName = NSAttributedString.Key(rawValue: "com.hootsuite.token")
static let inputTextAttributeName = NSAttributedString.Key(rawValue: "com.hootsuite.input")
static let inputTextAttributeAnchorValue = "anchor"
static let inputTextAttributeTextValue = "text"

Expand Down Expand Up @@ -193,13 +193,13 @@ open class TokenTextViewController: UIViewController, UITextViewDelegate, NSLayo
NotificationCenter.default.addObserver(
self,
selector: #selector(TokenTextViewController.preferredContentSizeChanged(_:)),
name: NSNotification.Name.UIContentSizeCategoryDidChange,
name: UIContentSizeCategory.didChangeNotification,
object: nil)
}

override open func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIContentSizeCategoryDidChange, object: nil)
NotificationCenter.default.removeObserver(self, name: UIContentSizeCategory.didChangeNotification, object: nil)
}

@objc func preferredContentSizeChanged(_ notification: Notification) {
Expand Down Expand Up @@ -414,7 +414,7 @@ open class TokenTextViewController: UIViewController, UITextViewDelegate, NSLayo
tokenTextStorage.updateFormatting()
}

fileprivate func createNewTokenAttributes() -> [NSAttributedStringKey: Any] {
fileprivate func createNewTokenAttributes() -> [NSAttributedString.Key: Any] {
return [
TokenTextViewControllerConstants.tokenAttributeName: UUID().uuidString as TokenReference
]
Expand Down Expand Up @@ -737,7 +737,7 @@ open class TokenTextViewController: UIViewController, UITextViewDelegate, NSLayo

// MARK: TokenTextViewTextStorageDelegate

func textStorageIsUpdatingFormatting(_ sender: TokenTextViewTextStorage, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedStringKey: Any], forRange: NSRange)]? {
func textStorageIsUpdatingFormatting(_ sender: TokenTextViewTextStorage, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedString.Key: Any], forRange: NSRange)]? {
return delegate?.tokenTextViewTextStorageIsUpdatingFormatting(self, text: text, searchRange: searchRange)
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/TokenTextViewTextStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import UIKit

protocol TokenTextViewTextStorageDelegate: class {

func textStorageIsUpdatingFormatting(_ sender: TokenTextViewTextStorage, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedStringKey: Any], forRange: NSRange)]?
func textStorageIsUpdatingFormatting(_ sender: TokenTextViewTextStorage, text: String, searchRange: NSRange) -> [(attributes: [NSAttributedString.Key: Any], forRange: NSRange)]?
func textStorageBackgroundColourForTokenRef(_ sender: TokenTextViewTextStorage, tokenRef: TokenReference) -> UIColor?
func textStorageForegroundColourForTokenRef(_ sender: TokenTextViewTextStorage, tokenRef: TokenReference) -> UIColor?

Expand Down Expand Up @@ -33,7 +33,7 @@ class TokenTextViewTextStorage: NSTextStorage {
return backingStore.string
}

override func attributes(at index: Int, effectiveRange range: NSRangePointer?) -> [NSAttributedStringKey: Any] {
override func attributes(at index: Int, effectiveRange range: NSRangePointer?) -> [NSAttributedString.Key: Any] {
return backingStore.attributes(at: index, effectiveRange: range)
}

Expand All @@ -47,7 +47,7 @@ class TokenTextViewTextStorage: NSTextStorage {
endEditing()
}

override func setAttributes(_ attrs: [NSAttributedStringKey: Any]?, range: NSRange) {
override func setAttributes(_ attrs: [NSAttributedString.Key: Any]?, range: NSRange) {
beginEditing()
backingStore.setAttributes(attrs, range: range)
edited(.editedAttributes, range: range, changeInLength: 0)
Expand Down Expand Up @@ -95,7 +95,7 @@ class TokenTextViewTextStorage: NSTextStorage {
}

enumerateTokens(inRange: searchRange) { (tokenRef, tokenRange) -> ObjCBool in
var tokenFormattingAttributes = [NSAttributedStringKey: Any]()
var tokenFormattingAttributes = [NSAttributedString.Key: Any]()
if let backgroundColor = self.formattingDelegate?.textStorageBackgroundColourForTokenRef(self, tokenRef: tokenRef) {
tokenFormattingAttributes[.backgroundColor] = backgroundColor
}
Expand Down Expand Up @@ -243,7 +243,7 @@ class TokenTextViewTextStorage: NSTextStorage {
return attributeTextAndRange(TokenTextViewControllerConstants.inputTextAttributeName, attributeValue: TokenTextViewControllerConstants.inputTextAttributeTextValue)
}

fileprivate func attributeTextAndRange(_ attributeName: NSAttributedStringKey, attributeValue: String) -> (String, NSRange)? {
fileprivate func attributeTextAndRange(_ attributeName: NSAttributedString.Key, attributeValue: String) -> (String, NSRange)? {
var result: (String, NSRange)?
enumerateAttribute(attributeName,
in: NSRange(location: 0, length: length),
Expand Down
2 changes: 1 addition & 1 deletion Tests/TokenTextViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TokenTextViewControllerTests: XCTestCase {

func testSetGetFont() {
let tokenVC = TokenTextViewController()
let font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.body)
let font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
tokenVC.font = font
XCTAssertEqual(tokenVC.font, font, "Font should be as set")
}
Expand Down
4 changes: 2 additions & 2 deletions TokenUI.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "TokenUI"
s.version = "4.0"
s.ios.deployment_target = "10.0"
s.version = "5.0"
s.ios.deployment_target = "11.0"
s.summary = "TokenUI is a swift Framework for creating and managing a text input component that allows to add 'tokens' rendered as pills."
s.homepage = "https://github.com/hootsuite/TokenUI"
s.license = { :type => "Apache", :file => "LICENSE.md" }
Expand Down
24 changes: 8 additions & 16 deletions TokenUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -509,20 +509,22 @@
"DEBUG=1",
"$(inherited)",
);
GCC_TREAT_WARNINGS_AS_ERRORS = 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;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -567,18 +569,20 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = 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;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -598,13 +602,11 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Resources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hootsuite.TokenUI;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -620,13 +622,11 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Resources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hootsuite.TokenUI;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -636,12 +636,10 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = QZQ96LVQ9C;
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hootsuite.TokenUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -651,12 +649,10 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = QZQ96LVQ9C;
INFOPLIST_FILE = Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hootsuite.TokenUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -667,12 +663,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = QZQ96LVQ9C;
INFOPLIST_FILE = Demo/Resources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hootsuite.TokenUIDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -683,12 +677,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = QZQ96LVQ9C;
INFOPLIST_FILE = Demo/Resources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.hootsuite.TokenUIDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down

0 comments on commit 9318f4f

Please sign in to comment.