class Pod::Bazel::Target

Attributes

default_xcconfigs[R]
file_accessors[R]
installer[R]
label[R]
non_library_spec[R]
package[R]
pod_target[R]
resolved_xconfig_by_config[R]

Public Class Methods

new(installer, pod_target, non_library_spec = nil, default_xcconfigs = {}) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 33
def initialize(installer, pod_target, non_library_spec = nil, default_xcconfigs = {})
  @installer = installer
  @pod_target = pod_target
  @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? }
  @non_library_spec = non_library_spec
  @label = (non_library_spec ? pod_target.non_library_spec_label(non_library_spec) : pod_target.label)
  @package_dir = installer.sandbox.pod_dir(pod_target.pod_name)
  @package = installer.sandbox.pod_dir(pod_target.pod_name).relative_path_from(installer.config.installation_root).to_s
  @default_xcconfigs = default_xcconfigs
  @resolved_xconfig_by_config = {}
end

Public Instance Methods

app_kwargs() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 563
def app_kwargs
  # maps to kwargs listed for https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-ios.md#ios_application
  {
    app_icons: [],
    bundle_id: resolved_value_by_build_setting('PRODUCT_BUNDLE_IDENTIFIER') || "org.cocoapods.#{label}",
    bundle_name: nil,
    entitlements: resolved_value_by_build_setting('CODE_SIGN_ENTITLEMENTS', is_label_argument: true),
    entitlements_validation: nil,
    extensions: [],
    families: app_targeted_device_families,
    frameworks: [],
    infoplists_by_build_setting: pod_target_infoplists_by_build_setting,
    infoplists: common_pod_target_infoplists(additional_plist: nil_if_empty(non_library_spec.consumer(pod_target.platform).info_plist)),
    ipa_post_processor: nil,
    launch_images: [],
    launch_storyboard: nil,
    minimum_os_version: pod_target.deployment_target_for_non_library_spec(non_library_spec),
    provisioning_profile: nil,
    resources: [],
    settings_bundle: [],
    strings: [],
    version: [],
    watch_application: []
  }
end
app_targeted_device_families() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 589
def app_targeted_device_families
  # Reads the targeted device families from xconfig TARGETED_DEVICE_FAMILY. Supports both iphone and ipad by default.
  device_families = resolved_value_by_build_setting('TARGETED_DEVICE_FAMILY') || '1,2'
  raise 'TARGETED_DEVICE_FAMILY must be the same for both debug and release.' unless device_families.is_a? String

  device_families.split(',').map do |device_family|
    case device_family
    when '1' then 'iphone'
    when '2' then 'ipad'
    else raise "Unsupported device family: #{device_family}"
    end
  end
end
bazel_label(relative_to: nil) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 45
def bazel_label(relative_to: nil)
  package_basename = File.basename(package)
  if package == relative_to
    ":#{label}"
  elsif package_basename == label
    "//#{package}"
  else
    "//#{package}:#{label}"
  end
end
build_settings_label(config) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 56
def build_settings_label(config)
  relative_sandbox_root = @installer.sandbox.root.relative_path_from(@installer.config.installation_root).to_s
  cocoapods_bazel_path = File.join(relative_sandbox_root, 'cocoapods-bazel')

  "//#{cocoapods_bazel_path}:#{config}"
end
common_pod_target_infoplists(additional_plist: nil) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 268
def common_pod_target_infoplists(additional_plist: nil)
  debug_plist = resolved_build_setting_value('INFOPLIST_FILE', settings: pod_target_xcconfig(configuration: :debug))
  release_plist = resolved_build_setting_value('INFOPLIST_FILE', settings: pod_target_xcconfig(configuration: :release))
  if debug_plist == release_plist
    [debug_plist, additional_plist].compact
  else
    [additional_plist].compact
  end
end
common_pod_target_xcconfig() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 135
def common_pod_target_xcconfig
  debug_xcconfig = resolved_xcconfig(configuration: :debug)
  release_xcconfig = resolved_xcconfig(configuration: :release)
  common_xcconfig = debug_xcconfig.select { |k, v| release_xcconfig[k] == v }
  # If the value is an array, merge it into a string.
  common_xcconfig.map do |k, v|
    [k, v.is_a?(Array) ? v.shelljoin : v]
  end.to_h
end
copts_for_search_paths_by_config(type, configuration) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 232
def copts_for_search_paths_by_config(type, configuration)
  additional_flag =
    case type
    when :swift then '-Xcc'
    when :objc then nil
    else raise "#Unsupported type #{type}"
    end

  copts = []
  pod_target_xcconfig_header_search_paths(configuration).each do |path|
    iquote = "-I#{path}"
    copts << additional_flag if additional_flag
    copts << iquote
  end

  pod_target_xcconfig_user_header_search_paths(configuration).each do |path|
    iquote = "-iquote#{path}"
    copts << additional_flag if additional_flag
    copts << iquote
  end
  copts
end
defaults() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 400
def defaults
  {
    module_name: label,
    module_map: nil,
    srcs: [],
    non_arc_srcs: [],
    hdrs: [],
    pch: nil,
    data: [],
    resource_bundles: {},

    swift_copts: [],
    objc_copts: [],
    cc_copts: [],
    defines: [],
    linkopts: [],
    other_inputs: [],
    linking_style: nil,
    runtime_deps: [],
    sdk_dylibs: [],
    sdk_frameworks: [],
    sdk_includes: [],
    weak_sdk_frameworks: [],

    bundle_id: nil,
    env: {},
    infoplists_by_build_setting: [],
    infoplists: [],
    minimum_os_version: nil,
    test_host: nil,
    platforms: {},

    app_icons: [],
    bundle_name: nil,
    entitlements: nil,
    entitlements_validation: nil,
    extensions: [],
    frameworks: [],
    ipa_post_processor: nil,
    launch_images: [],
    launch_storyboard: nil,
    provisioning_profile: nil,
    resources: [],
    settings_bundle: [],
    strings: [],
    version: [],
    watch_application: [],

    vendored_static_frameworks: [],
    vendored_dynamic_frameworks: [],
    vendored_static_libraries: [],
    vendored_dynamic_libraries: [],
    vendored_xcframeworks: [],

    deps: []
  }
end
dependent_targets_by_config() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 86
def dependent_targets_by_config
  targets =
    case non_library_spec&.spec_type
    when nil
      pod_target.dependent_targets_by_config
    when :app
      pod_target.app_dependent_targets_by_spec_name_by_config[non_library_spec.name].transform_values { |v| v + [pod_target] }
    when :test
      pod_target.test_dependent_targets_by_spec_name_by_config[non_library_spec.name].transform_values { |v| v + [pod_target] }
    else
      raise "Unhandled: #{non_library_spec.spec_type}"
    end

  targets.transform_values { |v| v.uniq.map { |target| self.class.new(installer, target) } }
end
deps_by_config() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 458
def deps_by_config
  debug_targets = dependent_targets_by_config[:debug]
  release_targets = dependent_targets_by_config[:release]

  debug_labels = debug_targets.map { |dt| dt.bazel_label(relative_to: package) }
  release_labels = release_targets.map { |dt| dt.bazel_label(relative_to: package) }
  shared_labels = (debug_labels & release_labels).uniq

  debug_only_labels = debug_labels - shared_labels
  release_only_labels = release_labels - shared_labels

  sorted_debug_labels = Pod::Bazel::Util.sort_labels(debug_only_labels)
  sorted_release_labels = Pod::Bazel::Util.sort_labels(release_only_labels)
  sorted_shared_labels = Pod::Bazel::Util.sort_labels(shared_labels)

  labels_by_config = {}

  if !sorted_debug_labels.empty? || !sorted_release_labels.empty?
    labels_by_config[build_settings_label(:debug)] = sorted_debug_labels
    labels_by_config[build_settings_label(:release)] = sorted_release_labels
  end

  if labels_by_config.empty? # no per-config dependency
    sorted_shared_labels
  elsif sorted_shared_labels.empty? # per-config dependencies exist, avoiding adding an empty array
    StarlarkCompiler::AST::FunctionCall.new('select', labels_by_config)
  else # both per-config and shared dependencies exist
    starlark { StarlarkCompiler::AST::FunctionCall.new('select', labels_by_config) + sorted_shared_labels }
  end
end
expand_glob(glob, extensions: nil, expand_directories: false) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 514
def expand_glob(glob, extensions: nil, expand_directories: false)
  if (m = glob.match(/\{([^\{\}]+)\}/))
    m[1].split(',').flat_map do |alt|
      expand_glob("#{m.pre_match}#{alt}#{m.post_match}")
    end.uniq
  elsif (m = glob.match(/\[([^\[\]]+)\]/))
    m[1].each_char.flat_map do |alt|
      expand_glob("#{m.pre_match}#{alt}#{m.post_match}")
    end.uniq
  elsif extensions && File.extname(glob).empty?
    glob = glob.chomp('**/*') # If we reach here and the glob ends with **/*, we need to avoid duplicating it (we do not want to end up with **/*/**/*)
    if File.basename(glob) == '*'
      extensions.map { |ext| "#{glob}.#{ext}" }
    else
      extensions.map do |ext|
        File.join(glob, '**', "*.#{ext}")
      end
    end
  elsif expand_directories
    if glob.end_with?('/**/*')
      [glob]
    elsif glob.end_with?('/*')
      [glob.sub(%r{/\*$}, '/**/*')]
    else
      [glob, glob.chomp('/') + '/**/*']
    end
  else
    [glob]
  end
end
framework_kwargs() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 545
def framework_kwargs
  {
    visibility: ['//visibility:public'],
    platforms: { pod_target.platform.string_name.downcase => pod_target.platform.deployment_target.to_s }
  }
end
glob(attr:, return_files: !pod_target.sandbox.local?(pod_target.pod_name), sorted: true, excludes: [], exclude_directories: 1) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 489
def glob(attr:, return_files: !pod_target.sandbox.local?(pod_target.pod_name), sorted: true, excludes: [], exclude_directories: 1)
  if !return_files
    case attr
    when :public_headers then attr = :public_header_files
    when :private_headers then attr = :private_header_files
    end

    globs = file_accessors.map(&:spec_consumer).flat_map(&attr).flat_map { |g| expand_glob(g, expand_directories: exclude_directories != 1) }
    excludes += file_accessors.map(&:spec_consumer).flat_map(&:exclude_files).flat_map { |g| expand_glob(g) }
    excludes = excludes.empty? ? {} : { exclude: excludes }
    excludes[:exclude_directories] = exclude_directories unless exclude_directories == 1
    if globs.empty?
      []
    else
      starlark { function_call(:glob, globs, **excludes) }
    end
  else
    file_accessors.flat_map(&attr)
                  .compact
                  .map { |path| path.relative_path_from(@package_dir).to_s }
                  .yield_self { |paths| sorted ? paths.sort : paths }
                  .uniq
  end
end
nil_if_empty(arr) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 621
def nil_if_empty(arr)
  arr.empty? ? nil : arr
end
pod_target_copts(type) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 192
def pod_target_copts(type)
  setting =
    case type
    when :swift then 'OTHER_SWIFT_FLAGS'
    when :objc then 'OTHER_CFLAGS'
    else raise "#Unsupported type #{type}"
    end
  copts = resolved_value_by_build_setting(setting)
  copts = [copts] if copts&.is_a?(String)

  debug_copts = copts_for_search_paths_by_config(type, :debug)
  release_copts = copts_for_search_paths_by_config(type, :release)
  copts_for_search_paths =
    if debug_copts.sort == release_copts.sort
      debug_copts
    else
      copts_by_build_setting = {
        build_settings_label(:debug) => debug_copts,
        build_settings_label(:release) => release_copts
      }
      StarlarkCompiler::AST::FunctionCall.new('select', copts_by_build_setting)
    end

  if copts
    if copts.is_a?(Array)
      if copts_for_search_paths.is_a?(Array)
        copts + copts_for_search_paths
      else
        starlark { copts_for_search_paths + copts }
      end
    elsif copts_for_search_paths.is_a?(Array) && copts_for_search_paths.empty?
      copts
    else
      starlark { copts + copts_for_search_paths }
    end
  else
    copts_for_search_paths
  end
end
pod_target_infoplists_by_build_setting() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 255
def pod_target_infoplists_by_build_setting
  debug_plist = resolved_build_setting_value('INFOPLIST_FILE', settings: pod_target_xcconfig(configuration: :debug))
  release_plist = resolved_build_setting_value('INFOPLIST_FILE', settings: pod_target_xcconfig(configuration: :release))
  if debug_plist == release_plist
    []
  else
    plist_by_build_setting = {}
    plist_by_build_setting[build_settings_label(:debug)] = [debug_plist] if debug_plist
    plist_by_build_setting[build_settings_label(:release)] = [release_plist] if release_plist
    plist_by_build_setting
  end
end
pod_target_xcconfig(configuration:) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 153
def pod_target_xcconfig(configuration:)
  pod_target
    .build_settings_for_spec(non_library_spec || pod_target.root_spec, configuration: configuration)
    .merged_pod_target_xcconfigs
    .to_h
    .merge(
      'CONFIGURATION' => configuration.to_s.capitalize,
      'PODS_TARGET_SRCROOT' => ':',
      'SRCROOT' => ':',
      'SDKROOT' => '__BAZEL_XCODE_SDKROOT__'
    )
end
pod_target_xcconfig_by_build_setting() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 123
def pod_target_xcconfig_by_build_setting
  debug_xcconfig = resolved_xcconfig(configuration: :debug)
  release_xcconfig = resolved_xcconfig(configuration: :release)
  debug_only_xcconfig = debug_xcconfig.reject { |k, v| release_xcconfig[k] == v }
  release_only_xcconfig = release_xcconfig.reject { |k, v| debug_xcconfig[k] == v }

  xconfig_by_build_setting = {}
  xconfig_by_build_setting[build_settings_label(:debug)] = debug_only_xcconfig unless debug_only_xcconfig.empty?
  xconfig_by_build_setting[build_settings_label(:release)] = release_only_xcconfig unless release_only_xcconfig.empty?
  xconfig_by_build_setting
end
pod_target_xcconfig_header_search_paths(configuration) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 182
def pod_target_xcconfig_header_search_paths(configuration)
  settings = pod_target_xcconfig(configuration: configuration).merge('PODS_TARGET_SRCROOT' => @package)
  resolved_build_setting_value('HEADER_SEARCH_PATHS', settings: settings) || []
end
pod_target_xcconfig_user_header_search_paths(configuration) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 187
def pod_target_xcconfig_user_header_search_paths(configuration)
  settings = pod_target_xcconfig(configuration: configuration).merge('PODS_TARGET_SRCROOT' => @package)
  resolved_build_setting_value('USER_HEADER_SEARCH_PATHS', settings: settings) || []
end
product_module_name() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 102
def product_module_name
  name = resolved_value_by_build_setting('PRODUCT_MODULE_NAME') || resolved_value_by_build_setting('PRODUCT_NAME') ||
         if non_library_spec
           label.tr('-', '_')
         else
           pod_target.product_module_name
         end

  raise 'The product module name must be the same for both debug and release.' unless name.is_a? String

  name.gsub(/^([0-9])/, '_\1').gsub(/[^a-zA-Z0-9_]/, '_')
end
resolved_value_by_build_setting(setting, additional_settings: {}, is_label_argument: false) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 166
def resolved_value_by_build_setting(setting, additional_settings: {}, is_label_argument: false)
  debug_settings = pod_target_xcconfig(configuration: :debug).merge(additional_settings)
  debug_value = resolved_build_setting_value(setting, settings: debug_settings)
  release_settings = pod_target_xcconfig(configuration: :release).merge(additional_settings)
  release_value = resolved_build_setting_value(setting, settings: release_settings)
  if debug_value == release_value
    debug_value&.empty? && is_label_argument ? nil : debug_value
  else
    value_by_build_setting = {
      build_settings_label(:debug) => debug_value.empty? && is_label_argument ? nil : debug_value,
      build_settings_label(:release) => release_value.empty? && is_label_argument ? nil : release_value
    }
    StarlarkCompiler::AST::FunctionCall.new('select', value_by_build_setting)
  end
end
resolved_xcconfig(configuration:) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 145
def resolved_xcconfig(configuration:)
  unless resolved_xconfig_by_config[configuration]
    xcconfig = pod_target_xcconfig(configuration: configuration)
    resolved_xconfig_by_config[configuration] = resolve_xcconfig(xcconfig)[1]
  end
  resolved_xconfig_by_config[configuration].clone
end
starlark(&blk) click to toggle source
# File lib/cocoapods/bazel/target.rb, line 625
def starlark(&blk)
  StarlarkCompiler::AST.build(&blk)
end
swift_objc_bridging_header() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 115
def swift_objc_bridging_header
  resolved_value_by_build_setting('SWIFT_OBJC_BRIDGING_HEADER')
end
test_host() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 63
def test_host
  unless (app_host_info = pod_target.test_app_hosts_by_spec_name[non_library_spec.name])
    return
  end

  app_spec, app_target = *app_host_info
  Target.new(installer, app_target, app_spec)
end
test_kwargs() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 552
def test_kwargs
  {
    bundle_id: resolved_value_by_build_setting('PRODUCT_BUNDLE_IDENTIFIER'),
    env: pod_target.scheme_for_spec(non_library_spec).fetch(:environment_variables, {}),
    infoplists_by_build_setting: pod_target_infoplists_by_build_setting,
    infoplists: common_pod_target_infoplists(additional_plist: nil_if_empty(non_library_spec.consumer(pod_target.platform).info_plist)),
    minimum_os_version: pod_target.deployment_target_for_non_library_spec(non_library_spec),
    test_host: test_host&.bazel_label(relative_to: package) || file_accessors.any? { |fa| fa.spec_consumer.requires_app_host? } || nil
  }
end
to_rule_kwargs() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 278
def to_rule_kwargs
  kwargs = RuleArgs.new do |args|
    args
      .add(:name, label)
      .add(:module_name, product_module_name, defaults: [label])
      .add(:module_map, !non_library_spec && file_accessors.map(&:module_map).find(&:itself)&.relative_path_from(@package_dir)&.to_s, defaults: [nil, false]).

      # public headers
      add(:public_headers, glob(attr: :public_headers, sorted: false).yield_self { |f| case f when Array then f.reject { |path| path.include? '.framework/' } else f end }, defaults: [[]])
      .add(:private_headers, glob(attr: :private_headers).yield_self { |f| case f when Array then f.reject { |path| path.include? '.framework/' } else f end }, defaults: [[]])
      .add(:pch, glob(attr: :prefix_header, return_files: true).first, defaults: [nil])
      .add(:data, glob(attr: :resources, exclude_directories: 0), defaults: [[]])
      .add(:resource_bundles, {}, defaults: [{}])
      .add(:swift_version, uses_swift? && pod_target.swift_version, defaults: [nil, false])
      .add(:swift_objc_bridging_header, swift_objc_bridging_header, defaults: [nil])

    # xcconfigs
    resolve_xcconfig(common_pod_target_xcconfig, default_xcconfigs: default_xcconfigs).tap do |name, xcconfig|
      args
        .add(:default_xcconfig_name, name, defaults: [nil])
        .add(:xcconfig, xcconfig, defaults: [{}])
    end
    # xcconfig_by_build_setting
    args.add(:xcconfig_by_build_setting, pod_target_xcconfig_by_build_setting, defaults: [{}])
  end.kwargs

  file_accessors.group_by { |fa| fa.spec_consumer.requires_arc.class }.tap do |fa_by_arc|
    srcs = Hash.new { |h, k| h[k] = [] }
    non_arc_srcs = Hash.new { |h, k| h[k] = [] }
    expand = ->(g) { expand_glob(g, extensions: %w[h hh m mm swift c cc cpp]) }

    Array(fa_by_arc[TrueClass]).each do |fa|
      srcs[fa.spec_consumer.exclude_files] += fa.spec_consumer.source_files.flat_map(&expand)
    end
    Array(fa_by_arc[FalseClass]).each do |fa|
      non_arc_srcs[fa.spec_consumer.exclude_files] += fa.spec_consumer.source_files.flat_map(&expand)
    end
    (Array(fa_by_arc[Array]) + Array(fa_by_arc[String])).each do |fa|
      arc_globs = Array(fa.spec_consumer.requires_arc).flat_map(&expand)
      globs = fa.spec_consumer.source_files.flat_map(&expand)

      srcs[fa.spec_consumer.exclude_files] += arc_globs
      non_arc_srcs[fa.spec_consumer.exclude_files + arc_globs] += globs
    end

    m = lambda do |h|
      h.delete_if do |_, v|
        v.delete_if { |g| g.include?('.framework/') }
        v.empty?
      end
      return [] if h.empty?

      h.map do |excludes, globs|
        excludes = excludes.empty? ? {} : { exclude: excludes.flat_map(&method(:expand_glob)) }
        starlark { function_call(:glob, globs.uniq, **excludes) }
      end.reduce(&:+)
    end

    kwargs[:srcs] = m[srcs]
    kwargs[:non_arc_srcs] = m[non_arc_srcs]
  end

  file_accessors.each_with_object({}) do |fa, bundles|
    fa.spec_consumer.resource_bundles.each do |name, file_patterns|
      bundle = bundles[name] ||= {}
      patterns_by_exclude = bundle[fa.spec_consumer.exclude_files] ||= []
      patterns_by_exclude.concat(file_patterns.flat_map { |g| expand_glob(g, expand_directories: true) })
    end
  end.tap do |bundles|
    kwargs[:resource_bundles] = bundles.map do |bundle_name, patterns_by_excludes|
      patterns_by_excludes.delete_if { |_, v| v.empty? }
      # resources implicitly have dirs expanded by CocoaPods
      resources = patterns_by_excludes.map do |excludes, globs|
        excludes = excludes.empty? ? {} : { exclude: excludes.flat_map(&method(:expand_glob)) }
        starlark { function_call(:glob, globs.uniq, exclude_directories: 0, **excludes) }
      end.reduce(&:+)
      [bundle_name, resources]
    end.to_h
  end

  # non-propagated stuff for a target that should build.
  if pod_target.should_build?
    kwargs[:swift_copts] = pod_target_copts(:swift)
    kwargs[:objc_copts] = pod_target_copts(:objc)
    linkopts = resolved_value_by_build_setting('OTHER_LDFLAGS')
    linkopts = [linkopts] if linkopts.is_a? String
    kwargs[:linkopts] = linkopts || []
  end

  # propagated
  kwargs[:defines] = []
  kwargs[:other_inputs] = []
  kwargs[:linking_style] = nil
  kwargs[:runtime_deps] = []
  kwargs[:sdk_dylibs] = file_accessors.flat_map { |fa| fa.spec_consumer.libraries }.sort.uniq
  kwargs[:sdk_frameworks] = file_accessors.flat_map { |fa| fa.spec_consumer.frameworks }.sort.uniq
  kwargs[:sdk_includes] = []
  kwargs[:weak_sdk_frameworks] = file_accessors.flat_map { |fa| fa.spec_consumer.weak_frameworks }.sort.uniq

  kwargs[:vendored_static_frameworks] = glob(attr: :vendored_static_frameworks, return_files: true)
  kwargs[:vendored_dynamic_frameworks] = glob(attr: :vendored_dynamic_frameworks, return_files: true)
  kwargs[:vendored_static_libraries] = glob(attr: :vendored_static_libraries, return_files: true)
  kwargs[:vendored_dynamic_libraries] = glob(attr: :vendored_dynamic_libraries, return_files: true)
  kwargs[:vendored_xcframeworks] = vendored_xcframeworks

  # any compatible provider: CCProvider, SwiftInfo, etc
  kwargs[:deps] = deps_by_config

  case non_library_spec&.spec_type
  when :test
    kwargs.merge!(test_kwargs)
  when :app
    kwargs.merge!(app_kwargs)
  when nil
    kwargs.merge!(framework_kwargs)
  end

  defaults = self.defaults
  kwargs.delete_if { |k, v| defaults[k] == v }
  kwargs
end
type() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 72
def type
  platform = pod_target.platform.name
  case non_library_spec&.spec_type
  when nil
    'apple_framework'
  when :app
    "#{platform}_application"
  when :test
    "#{platform}_#{non_library_spec.test_type}_test"
  else
    raise "Unhandled: #{non_library_spec.spec_type}"
  end
end
uses_swift?() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 119
def uses_swift?
  file_accessors.any? { |fa| fa.source_files.any? { |s| s.extname == '.swift' } }
end
vendored_xcframeworks() click to toggle source
# File lib/cocoapods/bazel/target.rb, line 603
def vendored_xcframeworks
  pod_target.xcframeworks.values.flatten(1).uniq.map do |xcframework|
    {
      'name' => xcframework.name,
      'slices' => xcframework.slices.map do |slice|
        {
          'identifier' => slice.identifier,
          'platform' => slice.platform.name.to_s,
          'platform_variant' => slice.platform_variant.to_s,
          'supported_archs' => slice.supported_archs,
          'path' => slice.path.relative_path_from(@package_dir).to_s,
          'build_type' => { 'linkage' => slice.build_type.linkage.to_s, 'packaging' => slice.build_type.packaging.to_s }
        }
      end
    }
  end
end