@@ -35,7 +35,8 @@ def add(name, value, defaults: nil)
3535 private :installer , :pod_target , :file_accessors , :non_library_spec , :label , :package , :default_xcconfigs , :resolved_xconfig_by_config , :relative_sandbox_root
3636 # rubocop:enable Style/AccessModifierDeclarations
3737
38- def initialize ( installer , pod_target , non_library_spec = nil , default_xcconfigs = { } , experimental_deps_debug_and_release = false , xcframework_excluded_platforms = [ ] )
38+ def initialize ( installer , pod_target , non_library_spec = nil , default_xcconfigs = { } , experimental_deps_debug_and_release = false ,
39+ xcframework_excluded_platforms = [ ] , enable_add_testonly = false )
3940 @installer = installer
4041 @pod_target = pod_target
4142 @file_accessors = non_library_spec ? pod_target . file_accessors . select { |fa | fa . spec == non_library_spec } : pod_target . file_accessors . select { |fa | fa . spec . library_specification? }
@@ -47,6 +48,7 @@ def initialize(installer, pod_target, non_library_spec = nil, default_xcconfigs
4748 @resolved_xconfig_by_config = { }
4849 @experimental_deps_debug_and_release = experimental_deps_debug_and_release
4950 @xcframework_excluded_platforms = xcframework_excluded_platforms
51+ @enable_add_testonly = enable_add_testonly
5052 @relative_sandbox_root = installer . sandbox . root . relative_path_from ( installer . config . installation_root ) . to_s
5153 end
5254
@@ -378,10 +380,10 @@ def to_rule_kwargs
378380 kwargs [ :runtime_deps ] = [ ]
379381 kwargs [ :sdk_dylibs ] = file_accessors . flat_map { |fa | fa . spec_consumer . libraries } . sort . uniq
380382 kwargs [ :sdk_frameworks ] = file_accessors . flat_map { |fa | fa . spec_consumer . frameworks } . sort . uniq
381- kwargs [ :testonly ] = true if kwargs [ :sdk_frameworks ] . include? 'XCTest'
383+ kwargs [ :testonly ] = true if ( kwargs [ :sdk_frameworks ] . include? 'XCTest' ) && @enable_add_testonly
382384 kwargs [ :sdk_includes ] = [ ]
383385 kwargs [ :weak_sdk_frameworks ] = file_accessors . flat_map { |fa | fa . spec_consumer . weak_frameworks } . sort . uniq
384- kwargs [ :testonly ] = true if kwargs [ :weak_sdk_frameworks ] . include? 'XCTest'
386+ kwargs [ :testonly ] = true if ( kwargs [ :weak_sdk_frameworks ] . include? 'XCTest' ) && @enable_add_testonly
385387
386388 kwargs [ :vendored_static_frameworks ] = glob ( attr : :vendored_static_frameworks , return_files : true )
387389 kwargs [ :vendored_dynamic_frameworks ] = glob ( attr : :vendored_dynamic_frameworks , return_files : true )
0 commit comments