Class: CBin::Build::Utils

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

Class Method Summary collapse

Class Method Details

.is_framework(spec) ⇒ Object



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

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

  return Utils.is_swift_module(spec)
end

.is_swift_module(spec) ⇒ Object



17
18
19
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
# File 'lib/cocoapods-imy-bin/helpers/build_utils.rb', line 17

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)


46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cocoapods-imy-bin/helpers/build_utils.rb', line 46

def Utils.uses_frameworks?
  uses_frameworks = false
  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