Class: Pod::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-kz/native/installer.rb,
lib/cocoapods-kz/native/target_integrator.rb,
lib/cocoapods-kz/native/pods_project_writer.rb,
lib/cocoapods-kz/native/pod_target_installer.rb,
lib/cocoapods-kz/native/pod_target_integrator.rb,
lib/cocoapods-kz/native/target_installer_helper.rb

Defined Under Namespace

Classes: UserProjectIntegrator, Xcode

Instance Method Summary collapse

Instance Method Details

#download_dependenciesObject



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
34
35
36
37
38
39
# File 'lib/cocoapods-kz/native/installer.rb', line 9

def download_dependencies
  original_download_dependencies

  # 因为kz_pod_target提供不少方法,需要判断pod文件情况,所以依赖分析需要挪到download之后
  if KZ::KZGlobalHelper.instance.generate_kz_pod_targets
    kz_analyer = KZ::KZAnalyzer.new(pod_targets, self.sandbox.development_pods)
    kz_analyer.analyer
    KZ::KZGlobalHelper.instance.kz_analyzer = kz_analyer
  end

  if KZ::KZGlobalHelper.instance.kz_pod_enable
    main_project = aggregate_targets.first.user_project
    main_project.targets.each do |main_target|
      if KZ::KZGlobalHelper.instance.on_demand_resources_info.odr_target_names.include?(main_target.display_name)
        bundle_id = main_target.build_configurations.first.kz_simple_attributes_buildSettings_hash["PRODUCT_BUNDLE_IDENTIFIER"]
        unless bundle_id.nil?
          if !KZ::KZGlobalHelper.instance.on_demand_resources_info.bundle_id.empty? && KZ::KZGlobalHelper.instance.on_demand_resources_info.bundle_id != bundle_id
            KZ::KZLog.log("'#{main_target.display_name}'的bundleId:'#{bundle_id}'与其他odr target不同,ODR配置失败", :error)
            exit
          end
          KZ::KZGlobalHelper.instance.on_demand_resources_info.bundle_id = bundle_id
          KZ::KZLog.log("'#{main_target.display_name}'开启ODR,bundleId为: '#{bundle_id}'", :success)
        else
          KZ::KZLog.log("'#{main_target.display_name}'开启ODR失败,bundleId为空", :warning)
        end
      end
    end
    KZ::KZGlobalHelper.instance.kz_generator = KZ::KZGenerator.new(main_project)
    KZ::KZGlobalHelper.instance.handle_flexCompiler
  end
end

#install!Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cocoapods-kz/native/installer.rb', line 56

def install!
  original_install!

  if KZ::KZGlobalHelper.instance.kz_pod_enable
    KZ::KZGlobalHelper.instance.write_lock_file

    KZ::KZLog.run_shell("sh '#{KZ::KZ_GENERATE_XCODE_ENV_PATH}' #{KZ::KZ_POD_CONFIG_ROOT + ".xcode_env.sh"}")

    current_pods_pbxproj_path = self.pods_project.path + 'project.pbxproj'
    temp_pods_pbxproj_path = KZ::KZ_POD_CONFIG_POD_TEMPDIR + 'project.pbxproj'
    KZ::KZLog.run_shell("(sleep 1 && ruby '#{KZ::KZ_FEFRESH_PODS_PBXPROJ}' '#{current_pods_pbxproj_path}' '#{temp_pods_pbxproj_path}') &")
  end
end

#integrateObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cocoapods-kz/native/installer.rb', line 42

def integrate
  if KZ::KZGlobalHelper.instance.kz_pod_enable
    # hmap的创建需要在download之后,integrate之前
    KZ::KZGlobalHelper.instance.kz_generator.create_hamp

    if KZ::KZGlobalHelper.instance.on_demand_resources_info.enable
      KZ::KZGlobalHelper.instance.kz_generator.create_on_demand_resources
    end
  end
  original_integrate
end

#original_download_dependenciesObject



8
# File 'lib/cocoapods-kz/native/installer.rb', line 8

alias_method :original_download_dependencies, :download_dependencies

#original_install!Object

pod结束



55
# File 'lib/cocoapods-kz/native/installer.rb', line 55

alias_method :original_install!, :install!

#original_integrateObject



41
# File 'lib/cocoapods-kz/native/installer.rb', line 41

alias_method :original_integrate, :integrate