mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
See docs for test_spec here: https://blog.cocoapods.org/CocoaPods-1.3.0/ test_spec is an official CocoaPods mechanism for associating tests with a component. tests_spec has several advantages over our prior "tests as a podspec" hack: - We can finally run individual tests from Xcode's inline green "test" button that shows up alongside each test in the editor. - Tests can import private header files from components from .h files in the test target (because tests are no longer treated as frameworks). We were not previously able to do this, making it impossible to create .h/.m files that were shared across multiple test .m files. - We no longer need MDCUnitTests - everything lives in the MDCCatalog target. - The tests/ folder now appears as a sub-group for each component in the MaterialComponents development pod group. This will have a big impact on day-to-day workflow. Previously our tests lived in a sibling group to our components, making it somewhat difficult to navigate back-and-forth in Xcode. - pod lib lint is now able to run our unit tests. - Our tests can now explicitly declare their dependencies. Some caveats: - Each component now needs a test_spec subspec definition. This is a minor detail and one that doesn't add much extra work when creating a new component (we continue to just copy the existing templates). - When adding a new test_spec, we also need to add the test_spec to our MDCCatalog Podfile under the `:testspecs` list. This is a bit annoying, but only happens when new components are created (very infrequent). This is a good case of the cost here being outweighed by the benefits above (which affect our daily workflow). ## Screenshot <img width="405" alt="screen shot 2018-09-22 at 9 40 17 pm" src="https://user-images.githubusercontent.com/45670/45920647-33f4c180-beb0-11e8-94bc-88f3450c9e0a.png">
70 lines
3.2 KiB
Ruby
70 lines
3.2 KiB
Ruby
Pod::Spec.new do |mdc|
|
|
mdc.name = "MaterialComponentsAlpha"
|
|
mdc.version = "64.0.0"
|
|
mdc.authors = "The Material Components authors."
|
|
mdc.summary = "A collection of stand-alone alpha UI libraries that are not yet guaranteed to be ready for general production use. Use with caution."
|
|
mdc.homepage = "https://github.com/material-components/material-components-ios"
|
|
mdc.license = "Apache 2.0"
|
|
mdc.source = { :git => "https://github.com/material-components/material-components-ios.git", :tag => "v#{mdc.version}" }
|
|
mdc.platform = :ios
|
|
mdc.requires_arc = true
|
|
mdc.ios.deployment_target = '8.0'
|
|
|
|
# See MaterialComponents.podspec for the subspec structure and template.
|
|
|
|
|
|
# ActionSheet
|
|
|
|
mdc.subspec "ActionSheet" do |component|
|
|
component.ios.deployment_target = '8.0'
|
|
component.public_header_files = "components/#{component.base_name}/src/*.h"
|
|
component.source_files = "components/#{component.base_name}/src/*.{h,m}", "components/#{component.base_name}/src/private/*.{h,m}"
|
|
|
|
component.dependency "MaterialComponents/BottomSheet"
|
|
component.dependency "MaterialComponents/Ink"
|
|
component.dependency "MaterialComponents/Typography"
|
|
|
|
component.test_spec 'tests' do |tests|
|
|
tests.test_spec 'unit' do |unit_tests|
|
|
unit_tests.source_files = "components/#{component.base_name}/tests/unit/*.{h,m,swift}", "components/#{component.base_name}/tests/unit/supplemental/*.{h,m,swift}"
|
|
end
|
|
end
|
|
end
|
|
|
|
mdc.subspec "ActionSheet+TypographyThemer" do |extension|
|
|
extension.ios.deployment_target = '8.0'
|
|
extension.public_header_files = "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h"
|
|
extension.source_files = "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}", "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/private/*.{h,m}"
|
|
extension.dependency "MaterialComponentsAlpha/#{extension.base_name.split('+')[0]}"
|
|
extension.dependency "MaterialComponents/schemes/Typography"
|
|
end
|
|
|
|
# NavigationDrawer
|
|
|
|
mdc.subspec "NavigationDrawer" do |component|
|
|
component.ios.deployment_target = '8.0'
|
|
component.public_header_files = "components/#{component.base_name}/src/*.h"
|
|
component.source_files = "components/#{component.base_name}/src/*.{h,m}", "components/#{component.base_name}/src/private/*.{h,m}"
|
|
|
|
component.dependency "MaterialComponents/ShadowLayer"
|
|
component.dependency "MaterialComponents/private/UIMetrics"
|
|
|
|
component.test_spec 'tests' do |tests|
|
|
tests.test_spec 'unit' do |unit_tests|
|
|
unit_tests.source_files = "components/#{component.base_name}/tests/unit/*.{h,m,swift}", "components/#{component.base_name}/tests/unit/supplemental/*.{h,m,swift}"
|
|
end
|
|
end
|
|
end
|
|
|
|
mdc.subspec "private" do |private_spec|
|
|
# CocoaPods requires at least one file to show up in a subspec, so we depend on the fake
|
|
# "Alpha" component as a baseline.
|
|
private_spec.subspec "Alpha" do |component|
|
|
component.ios.deployment_target = '8.0'
|
|
component.public_header_files = "components/private/#{component.base_name}/src/*.h"
|
|
component.source_files = "components/private/#{component.base_name}/src/*.{h,m}"
|
|
end
|
|
end
|
|
|
|
end
|