Skip to content
This repository was archived by the owner on May 18, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions AutocompleteTextField.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,34 +227,35 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = Mozilla;
TargetAttributes = {
D31083311EAA7BF500ECF778 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 43AQ936H96;
LastSwiftMigration = 0820;
LastSwiftMigration = 1200;
ProvisioningStyle = Automatic;
};
D310834F1EAA7C3600ECF778 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 43AQ936H96;
LastSwiftMigration = 1200;
ProvisioningStyle = Automatic;
};
D370686F1EAE68B2000D6BA7 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 43AQ936H96;
LastSwiftMigration = 1200;
ProvisioningStyle = Automatic;
TestTargetID = D310834F1EAA7C3600ECF778;
};
};
};
buildConfigurationList = D310832C1EAA7BF500ECF778 /* Build configuration list for PBXProject "AutocompleteTextField" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -364,20 +365,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
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_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
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 All @@ -401,7 +412,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -418,20 +429,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
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_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
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 All @@ -449,7 +470,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -473,12 +494,13 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Source/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.AutocompleteTextField;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -494,11 +516,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Source/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.AutocompleteTextField;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -512,6 +535,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.AutocompleteTextFieldExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -525,6 +549,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.AutocompleteTextFieldExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -536,6 +561,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.AutocompleteTextFieldUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = AutocompleteTextFieldExample;
};
name = Debug;
Expand All @@ -548,6 +574,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.AutocompleteTextFieldUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = AutocompleteTextFieldExample;
};
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 = "0820"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D31083311EAA7BF500ECF778"
BuildableName = "AutocompleteTextField.framework"
BlueprintName = "AutocompleteTextField"
ReferencedContainer = "container:AutocompleteTextField.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D31083311EAA7BF500ECF778"
BuildableName = "AutocompleteTextField.framework"
BlueprintName = "AutocompleteTextField"
ReferencedContainer = "container:AutocompleteTextField.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -70,8 +68,6 @@
ReferencedContainer = "container:AutocompleteTextField.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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
}
}
Expand Down
2 changes: 1 addition & 1 deletion Example/DomainCompletionSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DomainCompletionSource: AutocompleteTextFieldCompletionSource {
// We don't actually want to match the top-level domain ("com", "org", etc.) by itself, so
// so make sure the result includes at least one ".".
let range = domainWithDotPrefix.index(range.lowerBound, offsetBy: 1)
let matchedDomain: String = domainWithDotPrefix.substring(from: range)
let matchedDomain = String(domainWithDotPrefix[range...])
if matchedDomain.contains(".") {
return matchedDomain + "/"
}
Expand Down
2 changes: 1 addition & 1 deletion Source/AutocompleteTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ open class AutocompleteTextField: UITextField, UITextFieldDelegate {
guard !completion.isEmpty, completion.lowercased().hasPrefix(text.lowercased()) else { return }

// Add the completion suffix to the current text and highlight it.
let completion = completion.substring(from: completion.index(completion.startIndex, offsetBy: text.characters.count))
let completion = completion[text.endIndex...]
let attributed = NSMutableAttributedString(string: text + completion)
let range = NSMakeRange((text as NSString).length, (completion as NSString).length)
attributed.addAttribute(NSAttributedString.Key.backgroundColor, value: highlightColor, range: range)
Expand Down
20 changes: 10 additions & 10 deletions Tests/AutocompleteTextFieldUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ class AutocompleteTextFieldUITests: XCTestCase {

field.typeText("w")
XCTAssertEqual(field.value! as! String, "www.google.com/")
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKey.delete.rawValue)
XCTAssertEqual(field.value! as! String, "w")
field.typeText("ww.yah")
XCTAssertEqual(field.value! as! String, "www.yahoo.com/")
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKey.delete.rawValue)
XCTAssertEqual(field.value! as! String, "www.yah")
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKey.delete.rawValue)
XCTAssertEqual(field.value! as! String, "www.ya")
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKey.delete.rawValue)
field.typeText(XCUIKeyboardKey.delete.rawValue)
field.typeText(XCUIKeyboardKey.delete.rawValue)
field.typeText(XCUIKeyboardKey.delete.rawValue)
field.typeText(XCUIKeyboardKey.delete.rawValue)
field.typeText(XCUIKeyboardKey.delete.rawValue)
XCTAssertEqual(field.value! as! String, "")
field.typeText("g")
XCTAssertEqual(field.value! as! String, "google.com/")
field.typeText("z")
XCTAssertEqual(field.value! as! String, "gz")
field.typeText(XCUIKeyboardKeyDelete)
field.typeText(XCUIKeyboardKey.delete.rawValue)
XCTAssertEqual(field.value! as! String, "g")
field.typeText("o")
XCTAssertEqual(field.value! as! String, "google.com/")
Expand Down