Class: CBin::Build::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-bb-bin/helpers/build_utils.rb

Class Method Summary collapse

Class Method Details

.is_framework(spec) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/cocoapods-bb-bin/helpers/build_utils.rb', line 9

def Utils.is_framework(spec)
  if Utils.uses_frameworks?
    return true
  end
  if Utils.is_generate_frameworks(spec)
    return true
  end

  return Utils.is_swift_module(spec)
end

.is_generate_frameworks(spec) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cocoapods-bb-bin/helpers/build_utils.rb', line 67

def Utils.is_generate_frameworks(spec)
  # framework
  zip_file = CBin::Config::Builder.instance.framework_zip_file(spec) + ".zip"
  res = File.exist?(zip_file)
  Pod::UI::puts "zip_file = #{zip_file}"
  unless res
    # xcframework
    zip_file = CBin::Config::Builder.instance.xcframework_zip_file(spec) + ".zip"
    res = File.exist?(zip_file)
    Pod::UI::puts "zip_file = #{zip_file}"
  end
  if res
    is_framework = true
  end
  return is_framework
end

.is_swift_module(spec) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cocoapods-bb-bin/helpers/build_utils.rb', line 20

def Utils.is_swift_module(spec)

  is_framework = false
  dir = File.join(CBin::Config::Builder.instance.gen_dir, CBin::Config::Builder.instance.target_name)
  #auto 走这里
  if File.exist?(dir)
    Dir.chdir(dir) do
      public_headers = Array.new
      spec_header_dir = "./Headers/Public/#{spec.name}"

      unless File.exist?(spec_header_dir)
        spec_header_dir = "./Pods/Headers/Public/#{spec.name}"
      end
      return false unless File.exist?(spec_header_dir)

      is_framework = File.exist?(File.join(spec_header_dir, "#{spec.name}-umbrella.h"))
    end
  end

  if $ARGV[1] == "local"
    is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_build_dir, "#{spec.name}.framework"))
    unless is_framework
      is_framework = File.exist?(File.join(CBin::Config::Builder.instance.xcode_BuildProductsPath_dir, "#{spec.name}","Swift Compatibility Header"))
    end
  end

  is_framework
end

.uses_frameworks?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cocoapods-bb-bin/helpers/build_utils.rb', line 49

def Utils.uses_frameworks?
  uses_frameworks = false
  podfile_path = Pod::Config.instance.podfile_path
  unless podfile_path
    return true
  end
  Pod::Config.instance.podfile.target_definitions.each do |key,value|
    if key != "Pods"
      uses_frameworks = value.uses_frameworks?
      if uses_frameworks
        break ;
      end
    end
  end

  return uses_frameworks
end