Skip to content

Commit

Permalink
[Icons] Correct icons scripts and integration. (material-components#8501
Browse files Browse the repository at this point in the history
)

Icons were not fully integrated into the catalog project and the relevant
scripts were out of date. This PR addressed the following issues:

*   The Icons source files had been hand-modified and did not match the
    script outputs.
*   The Icons unit tests were not included in the Catalog or Dragons
    projects.

It addresses these issues through the following:

*   Updates `scripts/sync_icons.sh` to:
    -   Match the copyright header format used by the project.
    -   Run clang-format on each generated source file.
    -   Add Icons unit tests to the MaterialComponents podspec.
    -   Remove duplicate import of `MaterialIcons.h` in the source
        implementation files.
*   Adds the Icons unit test targets to the Catalog and Dragons Xcode schemes.

Discovered while working on material-components#8498
  • Loading branch information
Robert Moore authored Sep 25, 2019
1 parent e1c4832 commit c3ad8fb
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FA36F5CABC29BF4F91DA44204B9C3260"
BuildableName = "MaterialComponents-Unit-private-Icons-UnitTests.xctest"
BlueprintName = "MaterialComponents-Unit-private-Icons-UnitTests"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down Expand Up @@ -839,6 +853,16 @@
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FA36F5CABC29BF4F91DA44204B9C3260"
BuildableName = "MaterialComponents-Unit-private-Icons-UnitTests.xctest"
BlueprintName = "MaterialComponents-Unit-private-Icons-UnitTests"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FA36F5CABC29BF4F91DA44204B9C3260"
BuildableName = "MaterialComponents-Unit-private-Icons-UnitTests.xctest"
BlueprintName = "MaterialComponents-Unit-private-Icons-UnitTests"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down Expand Up @@ -810,6 +824,16 @@
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FA36F5CABC29BF4F91DA44204B9C3260"
BuildableName = "MaterialComponents-Unit-private-Icons-UnitTests.xctest"
BlueprintName = "MaterialComponents-Unit-private-Icons-UnitTests"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
1 change: 1 addition & 0 deletions catalog/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ target "MDCCatalog" do
'Palettes/UnitTests',
'private/Application/UnitTests',
'private/Color/UnitTests',
'private/Icons/UnitTests',
'private/KeyboardWatcher/UnitTests',
'private/Math/UnitTests',
'private/Overlay/UnitTests',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand All @@ -17,8 +17,6 @@

#import "MaterialIcons+ic_color_lens.h"

#import "MaterialIcons.h"

static NSString *const kBundleName = @"MaterialIcons_ic_color_lens";
static NSString *const kIconName = @"ic_color_lens";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand All @@ -17,8 +17,6 @@

#import "MaterialIcons+ic_help_outline.h"

#import "MaterialIcons.h"

static NSString *const kBundleName = @"MaterialIcons_ic_help_outline";
static NSString *const kIconName = @"ic_help_outline";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand All @@ -17,8 +17,6 @@

#import "MaterialIcons+ic_more_horiz.h"

#import "MaterialIcons.h"

static NSString *const kBundleName = @"MaterialIcons_ic_more_horiz";
static NSString *const kIconName = @"ic_more_horiz";

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
// Copyright 2016-present the Material Components for iOS 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.
Expand All @@ -17,8 +17,6 @@

#import "MaterialIcons+ic_settings.h"

#import "MaterialIcons.h"

static NSString *const kBundleName = @"MaterialIcons_ic_settings";
static NSString *const kIconName = @"ic_settings";

Expand Down
6 changes: 6 additions & 0 deletions scripts/generated/icons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def registerIcons(s)
ss.source_files = "components/private/Icons/src/*.{h,m}"
end

iss.test_spec 'UnitTests' do |unit_tests|
unit_tests.source_files = [
"components/private/Icons/tests/unit/*.{h,m,swift}"
]
end

iss.subspec "ic_arrow_back" do |ss|
ss.public_header_files = "components/private/Icons/icons/ic_arrow_back/src/*.h"
ss.source_files = "components/private/Icons/icons/ic_arrow_back/src/*.{h,m}"
Expand Down
76 changes: 38 additions & 38 deletions scripts/sync_icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ def registerIcons(s)
ss.public_header_files = "$ICONS_COMPONENT_RELATIVE_PATH/src/*.h"
ss.source_files = "$ICONS_COMPONENT_RELATIVE_PATH/src/*.{h,m}"
end
iss.test_spec 'UnitTests' do |unit_tests|
unit_tests.source_files = [
"components/private/Icons/tests/unit/*.{h,m,swift}"
]
end
EOL

# Enumerate all desired icons...
Expand Down Expand Up @@ -159,21 +165,19 @@ EOL
# TODO(featherless): Find a more scalable way to inject these license headers. Possibly store the
# license in a separate file and inject it here.
cat > "$header_file" <<EOL
/*
Copyright 2016-present the Material Components for iOS 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.
*/
// Copyright 2016-present the Material Components for iOS 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.
#import <UIKit/UIKit.h>
Expand All @@ -200,35 +204,31 @@ EOL
EOL

cat > "$src_path/$file.m" <<EOL
/*
Copyright 2016-present the Material Components for iOS 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.
*/
// Copyright 2016-present the Material Components for iOS 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.
// This file was automatically generated by running $0
// Do not modify directly.
#import "$file.h"
#import "MaterialIcons.h"
static NSString *const kBundleName = @"MaterialIcons_$icon_name";
static NSString *const kIconName = @"$icon_name";
// Export a nonsense symbol to suppress a libtool warning when this is linked alone in a static lib.
__attribute__((visibility("default")))
char MDCIconsExportToSuppressLibToolWarning_$icon_name = 0;
__attribute__((
visibility("default"))) char MDCIconsExportToSuppressLibToolWarning_$icon_name = 0;
@implementation MDCIcons ($icon_name)
Expand All @@ -238,14 +238,14 @@ __attribute__((visibility("default")))
+ (nullable UIImage *)imageFor_$icon_name {
NSBundle *bundle = [self bundleNamed:kBundleName];
return [UIImage imageNamed:kIconName
inBundle:bundle
compatibleWithTraitCollection:nil];
return [UIImage imageNamed:kIconName inBundle:bundle compatibleWithTraitCollection:nil];
}
@end
EOL

echo -n "formatting source..."
hash clang-format && clang-format -i "$src_path/$file.h"
hash clang-format && clang-format -i "$src_path/$file.m"
echo -n "done!"
done

Expand Down

0 comments on commit c3ad8fb

Please sign in to comment.