From b6d5bfb53cac16de15c75d6571da5e15cdea4884 Mon Sep 17 00:00:00 2001 From: Will Larche Date: Wed, 25 Oct 2017 19:03:15 -0400 Subject: [PATCH 1/8] [RTL] Comment corrections and clarifications. (#26) --- Sources/UIView+MaterialRTL.h | 3 ++- Sources/UIView+MaterialRTL.m | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/UIView+MaterialRTL.h b/Sources/UIView+MaterialRTL.h index 8e21957..fbf1155 100644 --- a/Sources/UIView+MaterialRTL.h +++ b/Sources/UIView+MaterialRTL.h @@ -60,7 +60,8 @@ /** Returns the layout direction implied by the provided semantic content attribute relative to the application-wide layout direction (as returned by - UIApplication.sharedApplication.userInterfaceLayoutDirection). + UIApplication.sharedApplication.userInterfaceLayoutDirection). However, if it's being called from + an iOS 8 extension, it will return left-to-right every time. @param semanticContentAttribute The semantic content attribute. @return The layout direction. diff --git a/Sources/UIView+MaterialRTL.m b/Sources/UIView+MaterialRTL.m index ca0394a..0e14c79 100644 --- a/Sources/UIView+MaterialRTL.m +++ b/Sources/UIView+MaterialRTL.m @@ -105,8 +105,7 @@ + (UIUserInterfaceLayoutDirection)mdf_userInterfaceLayoutDirectionForSemanticCon #endif // MDF_BASE_SDK_EQUAL_OR_ABOVE(9_0) { // If we are running in the context of an app, we query [UIApplication sharedApplication]. - // Otherwise use a default of Left-to-Right, as UIKit in iOS 8 and below doesn't support native - // RTL layout. + // Otherwise use a default of Left-to-Right. UIUserInterfaceLayoutDirection applicationLayoutDirection = UIUserInterfaceLayoutDirectionLeftToRight; NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; From 5630a566396477ce6df5fd48b885aefdf40826d6 Mon Sep 17 00:00:00 2001 From: ianegordon Date: Thu, 26 Oct 2017 13:24:17 -0400 Subject: [PATCH 2/8] Silence NSNumber to BOOL conversion analyzer warning (#28) --- Sources/UIView+MaterialRTL.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/UIView+MaterialRTL.m b/Sources/UIView+MaterialRTL.m index 0e14c79..95126f7 100644 --- a/Sources/UIView+MaterialRTL.m +++ b/Sources/UIView+MaterialRTL.m @@ -150,7 +150,7 @@ @implementation UIView (MaterialRTLPrivate) - (UISemanticContentAttribute)mdf_associatedSemanticContentAttribute { NSNumber *semanticContentAttributeNumber = objc_getAssociatedObject(self, @selector(mdf_semanticContentAttribute)); - if (semanticContentAttributeNumber) { + if (semanticContentAttributeNumber != nil) { return [semanticContentAttributeNumber integerValue]; } return UISemanticContentAttributeUnspecified; From 42a9bdf739a8de112fbcf8d395640f3477306fae Mon Sep 17 00:00:00 2001 From: featherless Date: Fri, 27 Oct 2017 12:50:42 -0400 Subject: [PATCH 3/8] Add support for bazel and kokoro. (#27) * Add support for bazel and kokoro. * Fix copyright. * Use stable version of build_bazel_rules_apple. --- .gitignore | 3 +++ .kokoro | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ BUILD | 53 ++++++++++++++++++++++++++++++++++++++++++++ WORKSPACE | 25 +++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100755 .kokoro create mode 100644 BUILD create mode 100644 WORKSPACE diff --git a/.gitignore b/.gitignore index 2faf68e..81a3fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +bazel-* +.kokoro-ios-runner + # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore diff --git a/.kokoro b/.kokoro new file mode 100755 index 0000000..ca1c4bd --- /dev/null +++ b/.kokoro @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Copyright 2017-present The Material Foundation Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Fail on any error. +set -e + +# Display commands to stderr. +set -x + +KOKORO_RUNNER_VERSION="v3.*" + +fix_bazel_imports() { + if [ -z "$KOKORO_BUILD_NUMBER" ]; then + tests_dir_prefix="" + else + tests_dir_prefix="github/repo/" + fi + + rewrite_source() { + find "${stashed_dir}${tests_dir_prefix}Sources" -type f -name '*.h' -exec sed -i '' -E "$1" {} + || true + find "${stashed_dir}${tests_dir_prefix}Tests" -type f -name '*.h' -exec sed -i '' -E "$1" {} + || true + find "${stashed_dir}${tests_dir_prefix}Tests" -type f -name '*.m' -exec sed -i '' -E "$1" {} + || true + } + + # CocoaPods requires that public headers of dependent pods be implemented using framework import + # notation, while bazel requires that dependency headers be imported with quoted notation. + stashed_dir="" + rewrite_source "s/import /import \"\1.h\"/" + stashed_dir="$(pwd)/" + reset_imports() { + # Undoes our source changes from above. + rewrite_source "s/import \"MDF(.+).h\"/import /" + rewrite_source "s/import \"(.+)\+MaterialRTL\.h\"/import /" + } + trap reset_imports EXIT +} + +if [ ! -d .kokoro-ios-runner ]; then + git clone https://github.com/material-foundation/kokoro-ios-runner.git .kokoro-ios-runner +fi + +pushd .kokoro-ios-runner +git fetch > /dev/null +TAG=$(git tag --sort=v:refname -l "$KOKORO_RUNNER_VERSION" | tail -n1) +git checkout "$TAG" > /dev/null +popd + +fix_bazel_imports + +./.kokoro-ios-runner/bazel.sh test //:UnitTests 8.1.0 + +echo "Success!" diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..f2809dd --- /dev/null +++ b/BUILD @@ -0,0 +1,53 @@ +# Copyright 2017-present The Material Foundation Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@bazel_ios_warnings//:strict_warnings_objc_library.bzl", "strict_warnings_objc_library") +load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library") +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") + +licenses(["notice"]) # Apache 2.0 + +exports_files(["LICENSE"]) + +strict_warnings_objc_library( + name = "MDFInternationalization", + srcs = glob([ + "Sources/*.m", + ]), + hdrs = glob([ + "Sources/*.h", + ]), + enable_modules = 1, + includes = ["Sources"], + visibility = ["//visibility:public"], +) + +objc_library( + name = "UnitTestsLib", + srcs = glob([ + "Tests/*.m", + ]), + deps = [":MDFInternationalization"], + visibility = ["//visibility:private"], +) + +ios_unit_test( + name = "UnitTests", + deps = [ + ":UnitTestsLib", + ], + minimum_os_version = "8.0", + timeout = "short", + visibility = ["//visibility:private"], +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..69c79a3 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,25 @@ +# Copyright 2017-present The Material Foundation Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +git_repository( + name = "build_bazel_rules_apple", + remote = "https://github.com/bazelbuild/rules_apple.git", + commit = "7ea0557", +) + +git_repository( + name = "bazel_ios_warnings", + remote = "https://github.com/material-foundation/bazel_ios_warnings.git", + tag = "v1.0.1", +) From fef1a31313a4a8aa0234cce416e1615c7054cf9d Mon Sep 17 00:00:00 2001 From: featherless Date: Tue, 31 Oct 2017 21:37:32 -0400 Subject: [PATCH 4/8] Remove framework-style headers from the umbrella header. (#30) This will allow downstream dependencies to build the library with bazel without having to modify the source. --- .kokoro | 1 - Sources/MDFInternationalization.h | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.kokoro b/.kokoro index ca1c4bd..3ad57df 100755 --- a/.kokoro +++ b/.kokoro @@ -30,7 +30,6 @@ fix_bazel_imports() { fi rewrite_source() { - find "${stashed_dir}${tests_dir_prefix}Sources" -type f -name '*.h' -exec sed -i '' -E "$1" {} + || true find "${stashed_dir}${tests_dir_prefix}Tests" -type f -name '*.h' -exec sed -i '' -E "$1" {} + || true find "${stashed_dir}${tests_dir_prefix}Tests" -type f -name '*.m' -exec sed -i '' -E "$1" {} + || true } diff --git a/Sources/MDFInternationalization.h b/Sources/MDFInternationalization.h index 2446234..ca89bae 100644 --- a/Sources/MDFInternationalization.h +++ b/Sources/MDFInternationalization.h @@ -16,9 +16,9 @@ #import -#import -#import -#import +#import "MDFRTL.h" +#import "UIImage+MaterialRTL.h" +#import "UIView+MaterialRTL.h" //! Project version number for MDFInternationalization. FOUNDATION_EXPORT double MDFInternationalizationVersionNumber; From 5060976bcf45947d1176f8e060d13d4447b60a10 Mon Sep 17 00:00:00 2001 From: Adrian Secord Date: Wed, 8 Nov 2017 16:33:27 -0500 Subject: [PATCH 5/8] Add C++ guards so the compiler does not mangle symbol names. (#31) * Added C++ guards so the compiler does not mangle symbol names. * Switch to FOUNDATION_EXPORT to match other MDC usage. * Remove vestigial #ifdef. --- Sources/MDFRTL.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/MDFRTL.h b/Sources/MDFRTL.h index 568fa5b..595dc94 100644 --- a/Sources/MDFRTL.h +++ b/Sources/MDFRTL.h @@ -23,7 +23,7 @@ @param layoutDirection The layout direction to consider when computing the autoresizing mask. @return The leading margin part of an autoresizing mask. */ -UIViewAutoresizing MDFLeadingMarginAutoresizingMaskForLayoutDirection( +FOUNDATION_EXPORT UIViewAutoresizing MDFLeadingMarginAutoresizingMaskForLayoutDirection( UIUserInterfaceLayoutDirection layoutDirection); /** @@ -33,7 +33,7 @@ UIViewAutoresizing MDFLeadingMarginAutoresizingMaskForLayoutDirection( @param layoutDirection The layout direction to consider to compute the autoresizing mask. @return The trailing margin part of an autoresizing mask. */ -UIViewAutoresizing MDFTrailingMarginAutoresizingMaskForLayoutDirection( +FOUNDATION_EXPORT UIViewAutoresizing MDFTrailingMarginAutoresizingMaskForLayoutDirection( UIUserInterfaceLayoutDirection layoutDirection); /** @@ -75,7 +75,7 @@ UIViewAutoresizing MDFTrailingMarginAutoresizingMaskForLayoutDirection( @param containerWidth The superview's bounds's width. @return The frame mirrored around the vertical axis. */ -CGRect MDFRectFlippedHorizontally(CGRect frame, CGFloat containerWidth); +FOUNDATION_EXPORT CGRect MDFRectFlippedHorizontally(CGRect frame, CGFloat containerWidth); /** @@ -84,7 +84,7 @@ CGRect MDFRectFlippedHorizontally(CGRect frame, CGFloat containerWidth); @param insets The insets we are intending to flip horizontally. @return Insets with the right and left values exchanged. */ -UIEdgeInsets MDFInsetsFlippedHorizontally(UIEdgeInsets insets); +FOUNDATION_EXPORT UIEdgeInsets MDFInsetsFlippedHorizontally(UIEdgeInsets insets); /** Creates a UIEdgeInsets instance from the parameters while obeying layoutDirection. @@ -98,8 +98,8 @@ UIEdgeInsets MDFInsetsFlippedHorizontally(UIEdgeInsets insets); @param trailing The trailing inset. @return Insets in terms of left/right, already internationalized based on the layout direction. */ -UIEdgeInsets MDFInsetsMakeWithLayoutDirection(CGFloat top, - CGFloat leading, - CGFloat bottom, - CGFloat trailing, - UIUserInterfaceLayoutDirection layoutDirection); +FOUNDATION_EXPORT UIEdgeInsets MDFInsetsMakeWithLayoutDirection(CGFloat top, + CGFloat leading, + CGFloat bottom, + CGFloat trailing, + UIUserInterfaceLayoutDirection layoutDirection); From 88af44b587cb03408a827b97aa82234f6a7abc23 Mon Sep 17 00:00:00 2001 From: ianegordon Date: Mon, 13 Nov 2017 08:19:49 -0500 Subject: [PATCH 6/8] Add compile time flag for import style (#34) --- BUILD | 1 + Sources/MDFInternationalization.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/BUILD b/BUILD index f2809dd..4a680a5 100644 --- a/BUILD +++ b/BUILD @@ -28,6 +28,7 @@ strict_warnings_objc_library( hdrs = glob([ "Sources/*.h", ]), + defines = ["IS_BAZEL_BUILD"], enable_modules = 1, includes = ["Sources"], visibility = ["//visibility:public"], diff --git a/Sources/MDFInternationalization.h b/Sources/MDFInternationalization.h index ca89bae..12adde8 100644 --- a/Sources/MDFInternationalization.h +++ b/Sources/MDFInternationalization.h @@ -16,9 +16,16 @@ #import +// TODO(#33): Always use import <> once Bazel supports it. +#ifdef IS_BAZEL_BUILD #import "MDFRTL.h" #import "UIImage+MaterialRTL.h" #import "UIView+MaterialRTL.h" +#else +#import +#import +#import +#endif // IS_BAZEL_BUILD //! Project version number for MDFInternationalization. FOUNDATION_EXPORT double MDFInternationalizationVersionNumber; From 2394b8805f8306eda150f04d6ed51335e23c7434 Mon Sep 17 00:00:00 2001 From: Ian Gordon Date: Mon, 13 Nov 2017 18:25:14 -0500 Subject: [PATCH 7/8] Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ed156c..c1abc25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 1.0.3 + +* [Add compile time flag for import style (#34)](https://github.com/material-foundation/material-internationalization-ios/88af44b587cb03408a827b97aa82234f6a7abc23) (ianegordon) +* [Add C++ guards so the compiler does not mangle symbol names. (#31)](https://github.com/material-foundation/material-internationalization-ios/5060976bcf45947d1176f8e060d13d4447b60a10) (Adrian Secord) +* [Remove framework-style headers from the umbrella header. (#30)](https://github.com/material-foundation/material-internationalization-ios/fef1a31313a4a8aa0234cce416e1615c7054cf9d) (featherless) +* [Add support for bazel and kokoro. (#27)](https://github.com/material-foundation/material-internationalization-ios/42a9bdf739a8de112fbcf8d395640f3477306fae) (featherless) +* [Silence NSNumber to BOOL conversion analyzer warning (#28)](https://github.com/material-foundation/material-internationalization-ios/5630a566396477ce6df5fd48b885aefdf40826d6) (ianegordon) +* [[RTL] Comment corrections and clarifications. (#26)](https://github.com/material-foundation/material-internationalization-ios/b6d5bfb53cac16de15c75d6571da5e15cdea4884) (Will Larche) + # 1.0.2 * [Update Project and Scheme to latest recommended settings](https://github.com/material-foundation/material-internationalization-ios/8a0317501403463fab8c1d541eddf0f649df2fc6) (Ian Gordon) From 6c0a638df823f7fc83b674fed0785daa660a878c Mon Sep 17 00:00:00 2001 From: Ian Gordon Date: Mon, 13 Nov 2017 18:26:02 -0500 Subject: [PATCH 8/8] Bump Version --- MDFInternationalization.podspec | 2 +- Sources/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MDFInternationalization.podspec b/MDFInternationalization.podspec index 2bfa04a..7501d05 100644 --- a/MDFInternationalization.podspec +++ b/MDFInternationalization.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MDFInternationalization" - s.version = "1.0.2" + s.version = "1.0.3" s.authors = "The Material Foundation Authors" s.summary = "Internationalization tools." s.homepage = "https://github.com/material-foundation/material-internationalization-ios" diff --git a/Sources/Info.plist b/Sources/Info.plist index 9645e5d..e2ecf82 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.2 + 1.0.3 CFBundleSignature ???? CFBundleVersion