lib/cocoapods-jxedt/binary/helper/prebuild_installer.rb in cocoapods-jxedt-0.0.18 vs lib/cocoapods-jxedt/binary/helper/prebuild_installer.rb in cocoapods-jxedt-0.0.19

- old
+ new

@@ -10,24 +10,26 @@ def generate_pods_index_project! return unless Jxedt.config.create_index_project? Pod::UI.puts "-----------------------------------------" - Pod::UI.puts "🚖 生成Pods-Index.xcodeproj,可以直接把工程拖入workspace来查看源码或进行二进制调试" + Pod::UI.puts "🚖 正在生成Pods-Index.xcodeproj,可以直接把工程拖入workspace来查看源码或进行二进制调试" Pod::UI.puts "-----------------------------------------" # 生成index project开始标识 sandbox.index_project_create_stage = true - # 只生成pods target工程 + # 获取缓存 cache_analysis_result = analyze_project_cache - # 获取缓存中需要生成的pod_targets - pod_targets_to_generate = cache_analysis_result.pod_targets_to_generate.clone - # 修改标识,这个标识用于修改Target的productName - pod_targets_to_generate.each { |target| target.binary_index_enabled = true } - - # 调用生成project的方法,aggregate_targets传空 + # 获取缓存中需要生成的pod_targets,并拷贝一份新的,不修改原来的值 + pod_targets_to_generate = cache_analysis_result.pod_targets_to_generate.map do |target| + target_to_copy = target.clone + target_to_copy.binary_index_enabled = true # 修改标识,用于修改Target的productName + target_to_copy + end + + # 调用生成project的方法,aggregate_targets传空数组 create_and_save_projects(pod_targets_to_generate, [], cache_analysis_result.build_configurations, cache_analysis_result.project_object_version) # 恢复sandbox标识 sandbox.index_project_create_stage = false @@ -53,15 +55,22 @@ end class PodTarget < Target attr_accessor :binary_index_enabled - # 修改product module name - alias_method :old_product_module_name, :product_module_name - def product_module_name - name_ = old_product_module_name - return "#{name_}_Source" if binary_index_enabled - name_ + # Target的PRODUCT_NAME写入逻辑可以查看`PodTargetInstaller` + # settings['PRODUCT_NAME'] = target.product_basename + # settings['PRODUCT_MODULE_NAME'] = target.product_module_name + # + # 所以插件采用的方式是修改`product_basename`来改变Pods-Index.xcodeproj的名称 + # + alias_method :old_product_basename, :product_basename + def product_basename + if binary_index_enabled + # 在后面添加'_Source'改变PRODUCT_NAME + return "#{old_product_basename}_Source" + end + old_product_basename end end end \ No newline at end of file