Class: Xcodeproj::Project::Object::AbstractTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/react_native_util/core_ext/xcodeproj.rb

Constant Summary collapse

PODFILE_TARGET_TEMPLATE_PATH =
File.expand_path '../../assets/templates/Podfile-target.erb', __dir__

Instance Method Summary collapse

Instance Method Details

#podfile_excerpt(commented_out: false) ⇒ Object



9
10
11
12
13
# File 'lib/react_native_util/core_ext/xcodeproj.rb', line 9

def podfile_excerpt(commented_out: false)
  text = ERB.new(File.read(PODFILE_TARGET_TEMPLATE_PATH), nil, '-').result binding
  text = text.split("\n").map { |line| "# #{line}" }.join("\n") if commented_out
  "#{text}\n"
end

#subspecs_from_librariesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/react_native_util/core_ext/xcodeproj.rb', line 15

def subspecs_from_libraries
  libs = frameworks_build_phase.files.select do |file|
    path = file.file_ref.pretty_print
    next false unless /^lib(.+)\.a$/.match?(path)
    next false if path == 'libReact.a'

    # project is a ReactNativeUtil::Project
    # #static_libs is from the Libraries group
    project.static_libs(platform_name).include?(path)
  end

  react_project_subspecs = %w[Core CxxBridge DevSupport]
  react_project_subspecs << 'tvOS' if platform_name == :tvos

  react_project_subspecs + libs.map do |lib|
    root = lib.file_ref.pretty_print.sub(/^lib(.*)\.a$/, '\1')
    root.sub!(/-tvOS/, '')

    case root
    when 'RCTLinking'
      'RCTLinkingIOS'
    else
      root
    end
  end
end