Method: Flutter::Upload#copy_products

Defined in:
lib/upload.rb

#copy_productsObject

将产物copy到@framework_localPath目录下



94
95
96
97
98
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
# File 'lib/upload.rb', line 94

def copy_products
  # 先记录下旧的产物,用于比较是否有更新
  @origin_products = Dir.glob(File.join(@framework_localPath, "*.xcframework")).map do |file|
    File.basename(file)
  end

  # 如果有则删之
  system("find #{@framework_localPath} -name 'Debug' | xargs rm -rf")
  system("find #{@framework_localPath} -name 'Profile' | xargs rm -rf")
  system("find #{@framework_localPath} -name 'Release' | xargs rm -rf")
  system("find #{@framework_localPath} -name 'iphoneos' | xargs rm -rf")
  system("find #{@framework_localPath} -name 'iphonesimulator' | xargs rm -rf")
  # 1、先移除旧的framework
  xcframework_files = Dir.glob(File.join(@framework_localPath, "*.xcframework"))
  xcframework_files.each do |xc_file|
    # FileUtils.rm(xc_file)
    system("rm -rf #{xc_file}")
  end
  # 2、将新产物move到@framework_localPath目录下
  source_dir = path_for_product

  # 获取源文件夹下的所有.xcframework文件
  xc_files = Dir.glob(File.join(source_dir, "*"))
  raise "当前产物路径:#{source_dir}为空,\n请先构建需要的产物" unless xc_files.any?

  # 移动到目标文件夹下
  xc_files.each do |file|
    FileUtils.mv(file, @framework_localPath)
  end
end