Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Update minimum iOS version to 9.0. #27

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
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
17 changes: 2 additions & 15 deletions .kokoro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set -e
# Display commands to stderr.
set -x

KOKORO_RUNNER_VERSION="v3.*"
KOKORO_RUNNER_VERSION="v4.*"
BAZEL_VERSION="0.20.0"

fix_bazel_imports() {
Expand All @@ -29,19 +29,6 @@ fix_bazel_imports() {
else
tests_dir_prefix="github/repo/"
fi

rewrite_source() {
find "${stashed_dir}${tests_dir_prefix}tests/unit" -type f -name '*.swift' -exec sed -i '' -E "$1" {} + || true
}

stashed_dir=""
rewrite_source "s/import MDFTextAccessibility/import _MDFTextAccessibility/"
stashed_dir="$(pwd)/"
reset_imports() {
# Undoes our source changes from above.
rewrite_source "s/import _MDFTextAccessibility/import MDFTextAccessibility/"
}
trap reset_imports EXIT
}

if [ ! -d .kokoro-ios-runner ]; then
Expand All @@ -62,6 +49,6 @@ if [ -n "$KOKORO_BUILD_NUMBER" ]; then
bazel version
fi

./.kokoro-ios-runner/bazel.sh test //:UnitTests 9.0.0
./.kokoro-ios-runner/bazel.sh test //:UnitTests --min-xcode-version 9.0.0

echo "Success!"
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.2
osx_image: xcode9
sudo: false
# Only fire off builds for specific branches.
branches:
Expand Down
5 changes: 3 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports_files(["LICENSE"])

strict_warnings_objc_library(
name = "MDFTextAccessibility",
module_name = "MDFTextAccessibility",
srcs = glob([
"src/*.m",
"src/private/*.m",
Expand All @@ -43,15 +44,15 @@ swift_library(
resources = glob(["tests/resources/*"]),
deps = [":MDFTextAccessibility"],
visibility = ["//visibility:private"],
copts = ["-swift-version", "3"],
copts = ["-swift-version", "4"],
)

ios_unit_test(
name = "UnitTests",
deps = [
":UnitTestsSwiftLib"
],
minimum_os_version = "8.2",
minimum_os_version = "9.0",
timeout = "short",
visibility = ["//visibility:private"],
)
2 changes: 1 addition & 1 deletion MDFTextAccessibility.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Pod::Spec.new do |spec|
spec.public_header_files = "src/MDFTextAccessibility.h"
spec.private_header_files = "src/private/*.h"
spec.header_dir = "MDFTextAccessibility"
spec.ios.deployment_target = '8.0'
spec.ios.deployment_target = '9.0'
spec.tvos.deployment_target = '9.0'
end
24 changes: 12 additions & 12 deletions MDFTextAccessibility.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@
};
0BDAE3DF1CECD3A6003323B9 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 1120;
};
};
};
buildConfigurationList = 0B2890D61CE27291009E605A /* Build configuration list for PBXProject "MDFTextAccessibility" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -293,7 +293,7 @@
buildSettings = {
ENABLE_TESTABILITY = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
ONLY_ACTIVE_ARCH = YES;
WARNING_CFLAGS = "-Wall";
};
Expand All @@ -304,7 +304,7 @@
baseConfigurationReference = 0B96D67A1D5CD06100491BDC /* MDFTextAccessibility.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
WARNING_CFLAGS = "-Wall";
};
name = Release;
Expand Down Expand Up @@ -349,7 +349,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = src/module.modulemap;
MTL_ENABLE_DEBUG_INFO = YES;
Expand All @@ -363,7 +363,7 @@
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "tests/unit/MDFTextAccessibility-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -400,7 +400,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = src/module.modulemap;
MTL_ENABLE_DEBUG_INFO = NO;
Expand All @@ -412,7 +412,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "tests/unit/MDFTextAccessibility-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down Expand Up @@ -456,7 +456,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = tests/unit/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks /usr/lib/swift";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
Expand All @@ -469,7 +469,7 @@
SWIFT_INCLUDE_PATHS = src;
SWIFT_OBJC_BRIDGING_HEADER = "src/MDFTextAccessibility-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -506,7 +506,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = tests/unit/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks /usr/lib/swift";
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = (
"$(inherited)",
Expand All @@ -517,7 +517,7 @@
SDKROOT = iphoneos;
SWIFT_INCLUDE_PATHS = src;
SWIFT_OBJC_BRIDGING_HEADER = "src/MDFTextAccessibility-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ For more advanced usage, such as selecting from a set of colors other than white
and black, see MDFTextAccessibility's
`textColorFromChoices:onBackgroundColor:options:`.

## Requirements

- Xcode 9 or higher
- Minimum iOS deployment target of 9.0 or higher
- CocoaPods 1.5 or higher

## License

MDFTextAccessiblity is licensed under the [Apache License Version 2.0](LICENSE).
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ swift_rules_dependencies()
git_repository(
name = "bazel_ios_warnings",
remote = "https://github.com/material-foundation/bazel_ios_warnings.git",
tag = "v2.0.0",
tag = "v3.0.0",
)

http_file(
name = "xctestrunner",
executable = 1,
urls = ["https://github.com/google/xctestrunner/releases/download/0.2.5/ios_test_runner.par"],
urls = ["https://github.com/google/xctestrunner/releases/download/0.2.10/ios_test_runner.par"],
)
24 changes: 12 additions & 12 deletions tests/unit/MDFTextAccessibilityUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
let minAlpha = MDFTextAccessibility.minAlpha(ofTextColor: textColor,
onBackgroundColor:backgroundColor,
options:MDFTextAccessibilityOptions())
XCTAssertEqualWithAccuracy(minAlpha, 0.54, accuracy: alphaEpsilon)
XCTAssertEqual(minAlpha, 0.54, accuracy: alphaEpsilon)
}

func testLargeTextBlackOnWhiteMinAlpha() {
Expand All @@ -92,7 +92,7 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
let minAlpha = MDFTextAccessibility.minAlpha(ofTextColor: textColor,
onBackgroundColor:backgroundColor,
options:MDFTextAccessibilityOptions.largeFont)
XCTAssertEqualWithAccuracy(minAlpha, 0.42, accuracy: alphaEpsilon)
XCTAssertEqual(minAlpha, 0.42, accuracy: alphaEpsilon)
}

func testMinAlphaIgnoresColorAlpha() {
Expand All @@ -107,7 +107,7 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
onBackgroundColor:backgroundColor,
options:MDFTextAccessibilityOptions())

XCTAssertEqualWithAccuracy(minAlpha, minAlphaWithColorWithAlpha, accuracy: alphaEpsilon)
XCTAssertEqual(minAlpha, minAlphaWithColorWithAlpha, accuracy: alphaEpsilon)
}

// MARK: Accessibility standard tests
Expand Down Expand Up @@ -225,17 +225,17 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 10)))

// Bold and thicker fonts are considered large at a lower font size than nonbold fonts.
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightBlack)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightHeavy)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightBold)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .black)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .heavy)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .bold)))
// Semibold is considered bold by iOS font-weight APIs: fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold.
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightSemibold)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .semibold)))

// Non-bold fonts are not considered large at the lower font size threshold.
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightMedium)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightRegular)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightLight)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightThin)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightUltraLight)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .medium)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .regular)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .light)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .thin)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .ultraLight)))
}
}