diff --git a/lib/cocoapods/installer/analyzer.rb b/lib/cocoapods/installer/analyzer.rb index bf73f24477..1adf594e1c 100644 --- a/lib/cocoapods/installer/analyzer.rb +++ b/lib/cocoapods/installer/analyzer.rb @@ -438,6 +438,20 @@ def generate_targets(resolver_specs_by_target, target_inspections) end target.search_paths_aggregate_targets.concat(search_paths_aggregate_targets).freeze end + + aggregate_targets.each do |aggregate_target| + is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) & + [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty? + is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' } + + next unless is_app_extension + + aggregate_target.application_extension_api_only = true + aggregate_target.pod_targets.each do |pod_target| + pod_target.application_extension_api_only = true + end + end + if installation_options.integrate_targets? # Copy embedded target pods that cannot have their pods embedded as frameworks to # their host targets, and ensure we properly link library pods to their host targets diff --git a/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb b/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb index 600e403974..7e26e9ee6b 100644 --- a/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb +++ b/lib/cocoapods/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb @@ -41,10 +41,6 @@ def install! aggregate_target = aggregate_target_installation_result.target aggregate_native_target = aggregate_target_installation_result.native_target project = aggregate_native_target.project - is_app_extension = !(aggregate_target.user_targets.map(&:symbol_type) & - [:app_extension, :watch_extension, :watch2_extension, :tv_extension, :messages_extension]).empty? - is_app_extension ||= aggregate_target.user_targets.any? { |ut| ut.common_resolved_build_setting('APPLICATION_EXTENSION_API_ONLY') == 'YES' } - configure_app_extension_api_only_to_native_target(aggregate_native_target) if is_app_extension # Wire up dependencies that are part of inherit search paths for this aggregate target. aggregate_target.search_paths_aggregate_targets.each do |search_paths_target| aggregate_native_target.add_dependency(aggregate_target_installation_results[search_paths_target.name].native_target) @@ -54,7 +50,6 @@ def install! if pod_target_installation_result = pod_target_installation_results[pod_target.name] pod_target_native_target = pod_target_installation_result.native_target aggregate_native_target.add_dependency(pod_target_native_target) - configure_app_extension_api_only_to_native_target(pod_target_native_target) if is_app_extension else # Hit the cache is_local = sandbox.local?(pod_target.pod_name) @@ -65,17 +60,6 @@ def install! end end end - - private - - # Sets the APPLICATION_EXTENSION_API_ONLY build setting to YES for all - # configurations of the given native target. - # - def configure_app_extension_api_only_to_native_target(native_target) - native_target.build_configurations.each do |config| - config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'YES' - end - end end end end diff --git a/lib/cocoapods/target.rb b/lib/cocoapods/target.rb index 9273c70b59..ed565e2c98 100644 --- a/lib/cocoapods/target.rb +++ b/lib/cocoapods/target.rb @@ -46,6 +46,10 @@ class Target attr_reader :build_type private :build_type + # @return [Boolean] whether the target . + # + attr_accessor :application_extension_api_only + # Initialize a new target # # @param [Sandbox] sandbox @see #sandbox diff --git a/lib/cocoapods/target/build_settings.rb b/lib/cocoapods/target/build_settings.rb index 8c151bd2d5..f9cb5c3174 100644 --- a/lib/cocoapods/target/build_settings.rb +++ b/lib/cocoapods/target/build_settings.rb @@ -856,6 +856,11 @@ def requires_objc_linker_flag? target.configuration_build_dir(CONFIGURATION_BUILD_DIR_VARIABLE) end + # @return [String] + define_build_settings_method :application_extension_api_only, :build_setting => true, :memoized => true do + target.application_extension_api_only.present? ? 'YES' : nil + end + #-------------------------------------------------------------------------# # @!group Target Properties