-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add support for test target creation in the pods project generator #6703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Gemfile
Outdated
@@ -25,7 +25,7 @@ gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be reverted.
Gemfile.lock
Outdated
@@ -6,16 +6,6 @@ GIT | |||
claide (1.0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be reverted.
@@ -176,40 +177,6 @@ def generate_settings_to_import_pod_targets | |||
end | |||
end | |||
|
|||
# Add custom build settings and required build settings to link to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those moved to xcconfig_helper
no changes here and specs pass for this class.
@@ -66,6 +70,11 @@ def generate | |||
end | |||
XCConfigHelper.add_target_specific_settings(target, @xcconfig) | |||
@xcconfig.merge! XCConfigHelper.settings_for_dependent_targets(target, target.recursive_dependent_targets) | |||
if @test_xcconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For test xcconfigs
we ensure that linker flags are added for their dependencies.
ld_flags = '' | ||
ld_flags << '-ObjC' if includes_static_libraries | ||
ld_flags << '-ObjC' if include_objc_flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just rename of the flag here no real changes.
@@ -296,6 +298,55 @@ def self.settings_for_dependent_targets(target, dependent_targets) | |||
build_settings | |||
end | |||
|
|||
# Add custom build settings and required build settings to link to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied pasted from aggregate_xcconfig.rb
, almost zero changes except passing parameters.
@@ -86,6 +86,11 @@ def share_development_pod_schemes | |||
development_pod_targets.select(&:should_build?).each do |pod_target| | |||
next unless share_scheme_for_development_pod?(pod_target.pod_name) | |||
Xcodeproj::XCScheme.share_scheme(project.path, pod_target.label) | |||
if pod_target.contains_test_specifications? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shares the xcscheme
for tests :D
end | ||
end | ||
end | ||
end | ||
|
||
# TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will take care of this
if target.requires_frameworks? | ||
create_info_plist_file | ||
create_module_map | ||
create_umbrella_header do |generator| | ||
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents adding test specification headers as part of the generated umbrella header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want to gate the reject on contains_test_specification - might be expensive to do this for larger projects that do not have test specs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice thanks for the tip will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dantoml done, also added a test case to ensure test header files never make it into umbrella header :)
end | ||
end | ||
|
||
# TODO: doc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix
@@ -234,7 +267,7 @@ def include_in_build_config?(target_definition, configuration_name) | |||
|
|||
if whitelists.empty? | |||
@build_config_cache[key] = true | |||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just warning fix
@@ -258,7 +291,7 @@ def inhibit_warnings? | |||
|
|||
if whitelists.empty? | |||
@inhibit_warnings = false | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just warning fix
@@ -268,7 +301,7 @@ def inhibit_warnings? | |||
'settings to inhibit warnings. CocoaPods does not currently ' \ | |||
'support different settings and will fall back to your preference ' \ | |||
'set in the root target definition.' | |||
return podfile.root_target_definitions.first.inhibits_warnings_for_pod?(root_spec.name) | |||
podfile.root_target_definitions.first.inhibits_warnings_for_pod?(root_spec.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just warning fix
@@ -0,0 +1,20 @@ | |||
Pod::Spec.new do |s| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New library that helps with test_spec
support
@benasher44, @dantoml, @orta (and maybe @segiddins?) would love for you to review this PR at your time. I need to add a few more specs but overall its 95% complete. |
@@ -203,16 +208,10 @@ def set_target_dependencies | |||
aggregate_target.native_target.add_dependency(pod_target.native_target) | |||
configure_app_extension_api_only_for_target(pod_target) if is_app_extension | |||
|
|||
pod_target.dependent_targets.each do |pod_dependency_target| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method extracted. No logical changes. Helps support wiring up test dependencies to the native targets
@dnkoutso any chance you can upload a zip of an example project with this? |
@orta will upload one today |
@orta there you go. Please keep in mind I am still using a You will also need to ensure you setup cocoapods to point to my repo and branch so the integration works. It's pretty awesome to see it in action :) |
Added a few more specs! |
1c1f5e9
to
1ddb50e
Compare
Should go green! |
c83133d
to
aa060c8
Compare
Green! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work so far - this is actually looking to be pretty solid.
We'll definitely need guides for this - and potentially a separate project generation command for working on and testing pods outside of a host application project.
@@ -400,7 +489,7 @@ def header_mappings_dir | |||
end | |||
end | |||
|
|||
def add_header(build_file, public_headers, private_headers) | |||
def add_header(build_file, public_headers, private_headers, native_target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this added param is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, the method uses native_target
which is a property but now the parameter takes over so no real method changes were required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh - lol shadowing
if target.requires_frameworks? | ||
create_info_plist_file | ||
create_module_map | ||
create_umbrella_header do |generator| | ||
file_accessors = target.file_accessors.reject { |f| f.spec.test_specification? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may want to gate the reject on contains_test_specification - might be expensive to do this for larger projects that do not have test specs
da8af81
to
58cb912
Compare
All set. |
I wonder if we can do something about making I wonder if we can make it work both for the library: Ideally |
@orta Yeah it would be pretty nice if we added the testable to the main scheme |
Yes! So CMD+U works today on the test scheme but only if you decide to have Second, Xcodeproj has a method called I think we should expose a block in the Xcodeproj method and allow us to perform various customization on the schemes before we save them, so we don't have to do a post-process step and save them twice which can be slow for multiple files. Is this a blocker in this PR? |
IMO, ideally that gets looked at before the RC releases, but I don't consider it a blocker on this PR which is "get it in" vs "make it perfect" |
With your blessing we can get this merged and start a bit the process of polishing it! I got an upcoming branch with validator changes for running tests during |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets get this on master and we can polish it as we go.
<3! |
🍾 well done, @dnkoutso ! |
No description provided.