Module: Pod::Podfile::DSL

Defined in:
lib/cocoapods-aqarahome/command/Podfile_Dev.rb

Instance Method Summary collapse

Instance Method Details

#aqarahome_xcode_compat_post_hooks!(react_native_path: 'node_modules/react-native', aggregate_target: 'Pods-AqaraHome', user_target: 'AqaraHome', testadhoc_config_name: 'TestADHoc', privacy_path_filter: 'LMNewSensorsAnalytics', privacy_resource_line_regex: nil) {|installer| ... } ⇒ Object

Registers post_install and post_integrate for Xcode / RN upgrades, legacy pods, privacy manifest dedupe, etc. Call once in the Podfile (after require of react_native_pods).

Parameters:

  • react_native_path (String) (defaults to: 'node_modules/react-native')

    second argument to react_native_post_install when no block is passed

  • aggregate_target (String) (defaults to: 'Pods-AqaraHome')

    CocoaPods aggregate target name (default Pods-AqaraHome)

  • user_target (String) (defaults to: 'AqaraHome')

    main app target name (default AqaraHome)

  • testadhoc_config_name (String) (defaults to: 'TestADHoc')

    RN dev flags are applied to React pods for this configuration only

  • privacy_path_filter (String) (defaults to: 'LMNewSensorsAnalytics')

    substring used to strip duplicate PrivacyInfo.xcprivacy inputs

  • privacy_resource_line_regex (Regexp, nil) (defaults to: nil)

    override for the Pods-*-resources.sh line removal

Yields:

  • (installer)

    optional; if given, called first inside post_install (use for react_native_post_install)



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/cocoapods-aqarahome/command/Podfile_Dev.rb', line 54

def aqarahome_xcode_compat_post_hooks!(
  react_native_path: 'node_modules/react-native',
  aggregate_target: 'Pods-AqaraHome',
  user_target: 'AqaraHome',
  testadhoc_config_name: 'TestADHoc',
  privacy_path_filter: 'LMNewSensorsAnalytics',
  privacy_resource_line_regex: nil,
  &react_native_block
)
  patch_options = {
    aggregate_target: aggregate_target,
    user_target: user_target,
    testadhoc_config_name: testadhoc_config_name,
    privacy_path_filter: privacy_path_filter
  }
  patch_options[:privacy_resource_line_regex] = privacy_resource_line_regex if privacy_resource_line_regex

  post_install do |installer|
    if block_given?
      react_native_block.call(installer)
    elsif respond_to?(:react_native_post_install, true)
      react_native_post_install(installer, react_native_path)
    else
      message = [
        'aqarahome_xcode_compat_post_hooks!: `react_native_post_install` is not defined.',
        'Require react_native/scripts/react_native_pods in the Podfile, or pass a block, e.g.:',
        "  aqarahome_xcode_compat_post_hooks! { |i| react_native_post_install(i, 'node_modules/react-native') }"
      ].join("\n")
      raise(Pod::Informative, message) if defined?(Pod::Informative)

      raise message
    end

    CocoapodsAqarahome::PostInstallPatches.apply_post_install(installer, patch_options)
  end

  post_integrate do |installer|
    CocoapodsAqarahome::PostInstallPatches.apply_post_integrate(
      installer,
      user_target: user_target,
      privacy_path_filter: privacy_path_filter
    )
  end
end

#code_signing_allow_no!Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/cocoapods-aqarahome/command/Podfile_Dev.rb', line 99

def code_signing_allow_no!
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
        target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
      if target.name == "Pods-AqaraHome"
        puts "Updating #{target.name} OTHER_LDFLAGS To fit Xcode15.0.1+"
        target.build_configurations.each do |config|
          xcconfig_path = config.base_configuration_reference.real_path

          # read from xcconfig to build_settings dictionary
          build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]

          File.open(xcconfig_path,'r+'){|f|
            f.each_line{|l|
              s=""
              if l.include?('iconv.2.4.0')
                len = l.length
                s+=l.gsub!("iconv.2.4.0", "iconv.2")
                #seek back to the beginning of the line.
                f.seek(-len, IO::SEEK_CUR)
                #overwrite line with spaces and add a newline char
                f.write(s * 1)
                f.write(' ' * (len - l.length - 1))
                break
              end
            }
          }
        end
      end
    end
  end
end

#dev_pods(pods, git_pull = false, branch = 'aqara') ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cocoapods-aqarahome/command/Podfile_Dev.rb', line 7

def dev_pods(pods, git_pull = false, branch = 'aqara')
  if branch.length > 0
    if git_pull
      pull_local_sdk_origin_source(pods)
    elsif
      podStr = pods.join(", ")
      puts "成功清除私有库".green + "#{podStr}".yellow + "的缓存数据".green
      pods.each do |pod|
        args = ['clean',pod, "--all"]
        Pod::Command::Cache.run(args)
      end
      pull_latest_code_and_resolve_conflict(pods)
    end
    # pods.each do |name|
    #   pod name, :git => "https://xyz.com/ios/#{name}.git", :branch => "#{branch}"
    # end

    # puts "lebbay: using remote pods with branch: #{branch}".green
  else
    # 自定义开发目录
    development_path = Config.instance.dev_pods_path
    pods.each do |name|
      pod name, :path => "#{development_path}#{name}"
    end
    puts "lebbay: using local pods with path: #{development_path}xxx".green
  end
end

#watch_upObject



35
36
37
38
39
40
41
42
# File 'lib/cocoapods-aqarahome/command/Podfile_Dev.rb', line 35

def watch_up
  puts '|========================================================================|'.red
  (0..10).each do |i|
    puts '|                                                                        |'.red unless i == 5
    puts '|                       '.red + '你小子注意更新私有库SDK'.green + '                          |'.red unless i != 5
  end
  puts '|========================================================================|'.red
end