Class: Pindo::XcodeBuildHelper
- Inherits:
-
Object
- Object
- Pindo::XcodeBuildHelper
- Defined in:
- lib/pindo/module/xcode/xcode_build_helper.rb
Class Method Summary collapse
- .backup_podfile_lock(project_dir: nil, app_config_dir: nil, appversion: nil) ⇒ Object
-
.build_project(project_dir:, icloud_id: nil) ⇒ String?
构建 Xcode 工程的主入口方法.
-
.delete_libtarget_firebase_shell(project_path) ⇒ Object
删除 Unity-iPhone 项目中的 Firebase Crashlytics 脚本.
-
.fix_xcode16_linker_flags(project_dir: nil) ⇒ Object
修复 Xcode 16 链接器兼容性问题 自动移除 -ld_classic 和 -ld64 标志.
-
.get_gym_build_options(project_fullname:, icloud_id: nil) ⇒ Hash
获取 Gym 构建参数.
-
.get_target_name_map ⇒ Object
获取 Target 名称映射.
- .install_google_plist(project_dir: nil, app_config_dir: nil) ⇒ Object
- .modify_info_plist(project_dir: nil, proj_name: nil, config_json: nil) ⇒ Object
- .modify_infoplist_version(plist_file_name: nil, config_json: nil, target_name: nil) ⇒ Object
- .modify_maintarget_info_plist(plist_file_name: nil, config_json: nil, target_name: nil) ⇒ Object
- .modify_project_config(project_dir: nil, proj_name: nil, config_json: nil) ⇒ Object
- .pull_podfile_lock(project_dir: nil, app_config_dir: nil) ⇒ Object
Class Method Details
.backup_podfile_lock(project_dir: nil, app_config_dir: nil, appversion: nil) ⇒ Object
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 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 62 def backup_podfile_lock(project_dir:nil, app_config_dir:nil, appversion:nil) begin proj_pod_file = File.join(project_dir, "Podfile.lock") FileUtils.cp_r(proj_pod_file, File.join(app_config_dir, "Podfile.lock")) git_addpush_repo(path:app_config_dir, message:"#{appversion} backup podfile.lock", commit_file_params:["Podfile.lock"]) bytes = File.binread(proj_pod_file) checksum = Digest::MD5.hexdigest(bytes) build_verify_file = File.join(app_config_dir, "build_verify.json") build_verify_json = nil begin build_verify_json = JSON.parse(File.read(build_verify_file)) rescue => error end build_verify_json = build_verify_json || {} build_verify_json["output_code_commit"] = git_latest_commit_id(local_repo_dir:project_dir) build_verify_json["output_config_commit"] = git_latest_commit_id(local_repo_dir:app_config_dir) build_verify_json["output_podfile_checksum"] = checksum build_verify_json["output_time"] = Time.now.strftime('%y/%m/%d %H:%M:%S') File.open(build_verify_file, "w") do |file| file.write(JSON.pretty_generate(build_verify_json)) file.close end git_addpush_repo(path:app_config_dir, message:"backup #{appversion} output info", commit_file_params:["build_verify.json"]) rescue => error raise Informative, "保存Podfile.lock 文件失败!!!" end end |
.build_project(project_dir:, icloud_id: nil) ⇒ String?
构建 Xcode 工程的主入口方法
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 444 def build_project(project_dir:, icloud_id: nil) project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by { |f| File.mtime(f) } if project_fullname.nil? puts "未找到 Xcode 工程文件" return nil end # 修复 Xcode 16 链接器兼容性问题 fix_xcode16_linker_flags(project_dir: project_dir) # 清理旧的 build 目录 build_dir = File.join(project_dir, "build") FileUtils.rm_rf(build_dir) if File.exist?(build_dir) # 获取构建参数 = ( project_fullname: project_fullname, icloud_id: icloud_id ) # 执行构建 require 'gym' config = FastlaneCore::Configuration.create(Gym::Options., ) Gym::Manager.new.work(config) # 查找生成的 IPA 文件 build_path = File.join(project_dir, "build", "*.ipa") ipa_file = Dir.glob(build_path).max_by { |f| File.mtime(f) } ipa_file end |
.delete_libtarget_firebase_shell(project_path) ⇒ Object
删除 Unity-iPhone 项目中的 Firebase Crashlytics 脚本
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 11 def delete_libtarget_firebase_shell(project_path) puts "[-] 开始检查并删除 Unity-iPhone下的Firebase Crashlytics脚本..." if File.directory?(File.join(project_path, 'Unity')) && File.exist?(File.join(project_path, 'Unity', 'Unity-iPhone.xcodeproj')) unity_project_path = File.join(project_path, 'Unity', 'Unity-iPhone.xcodeproj') xcdoe_unitylib_project = Xcodeproj::Project::open(unity_project_path) xcdoe_unitylib_project.targets.each do |target| target.shell_script_build_phases&.each do |phase| if phase.name.eql?("Crashlytics Run Script") puts " 从target:#{target.name}中删除: #{phase.name} ..." target.build_phases.delete(phase) end end end xcdoe_unitylib_project.save() puts "[✔] 完成检查并删除 Unity-iPhone下的Firebase Crashlytics脚本..." end end |
.fix_xcode16_linker_flags(project_dir: nil) ⇒ Object
修复 Xcode 16 链接器兼容性问题自动移除 -ld_classic 和 -ld64 标志
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 361 def fix_xcode16_linker_flags(project_dir: nil) begin # 查找所有 xcodeproj 文件 workspace_file = Dir.glob(File.join(project_dir, "*.xcworkspace")).first project_files = [] if workspace_file && File.exist?(workspace_file) # 如果存在 workspace,从中提取所有项目 workspace_data_file = File.join(workspace_file, "contents.xcworkspacedata") if File.exist?(workspace_data_file) require 'rexml/document' doc = REXML::Document.new(File.read(workspace_data_file)) doc.elements.each('Workspace/FileRef') do |file_ref| location = file_ref.attributes['location'] if location && location.start_with?('group:') relative_path = location.sub('group:', '') if relative_path.end_with?('.xcodeproj') full_path = File.join(project_dir, relative_path) project_files << full_path if File.exist?(full_path) end end end end else # 直接查找项目文件 project_files = Dir.glob(File.join(project_dir, "**/*.xcodeproj")) end return if project_files.empty? fixed_count = 0 project_files.each do |project_path| begin project = Xcodeproj::Project.open(project_path) project_modified = false project.targets.each do |target| target.build_configurations.each do |config| ldflags = config.build_settings['OTHER_LDFLAGS'] next unless ldflags original_flags = ldflags.dup # 移除过时的链接器标志 if ldflags.is_a?(Array) ldflags.delete('-ld_classic') ldflags.delete('-ld64') elsif ldflags.is_a?(String) ldflags = ldflags.gsub(/-ld_classic|-ld64/, '').strip end if original_flags != ldflags config.build_settings['OTHER_LDFLAGS'] = ldflags project_modified = true end end end if project_modified project.save fixed_count += 1 end rescue => e # 静默处理错误,不中断构建 end end if fixed_count > 0 puts "✅ 修复 Xcode 16 链接器兼容性配置".green end rescue => error puts "⚠️ 修复链接器标志时出现错误: #{error.message}".yellow # 不中断构建流程 end end |
.get_gym_build_options(project_fullname:, icloud_id: nil) ⇒ Hash
获取 Gym 构建参数
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 481 def (project_fullname:, icloud_id: nil) if project_fullname.nil? raise "请指定要编译的工程" end project_path = File.dirname(project_fullname) proj_name = File.basename(project_fullname, ".xcodeproj") project_obj = Xcodeproj::Project.open(project_fullname) project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"] main_target = project_obj.targets.select { |target| target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) }.first provisioning_profile_name = main_target.build_configurations.first.build_settings['PROVISIONING_PROFILE_SPECIFIER'].downcase.split(" ") # 确定构建类型和 iCloud 环境 build_type = "app-store" icloud_env = "Production" if !project_build_platform.nil? && project_build_platform.eql?("macosx") # macOS 平台 if provisioning_profile_name.include?("development") build_type = "development" icloud_env = "Development" elsif provisioning_profile_name.include?("appstore") build_type = "mac-application" icloud_env = "Production" else build_type = "developer-id" icloud_env = "Production" end else # iOS 平台 if provisioning_profile_name.include?("adhoc") build_type = "ad-hoc" icloud_env = "Development" elsif provisioning_profile_name.include?("development") build_type = "development" icloud_env = "Development" else build_type = "app-store" icloud_env = "Production" end end # 检查 Unity 测试模板 if build_type.eql?("app-store") || build_type.eql?("ad-hoc") if File.exist?(File.join(project_path, "Unity/Data/Raw/SettingsPluginFlag.txt")) raise Informative, "Unity代码包含测试模板,请重新导出Unity代码" end end # 获取应用名称 app_ipaname_temp = main_target.build_configurations.first.build_settings['INFOPLIST_KEY_CFBundleDisplayName'] || main_target.display_name app_ipaname_temp = app_ipaname_temp.gsub(/ /, '') app_ipaname_temp = app_ipaname_temp.gsub(/\'/, '') # 构建基本参数 values = { project: "#{proj_name}.xcodeproj", scheme: "#{proj_name}", configuration: "Release", clean: true, export_method: build_type, output_directory: "./build/", output_name: "#{app_ipaname_temp}.ipa" } # macOS 平台特殊处理 if !project_build_platform.nil? && project_build_platform.eql?("macosx") values[:output_name] = nil values[:destination] = "generic/platform=macosx" end # 如果使用 CocoaPods if File.exist?(File.join(project_path, "Podfile")) values[:workspace] = "#{proj_name}.xcworkspace" values[:project] = nil end # 导出选项 values[:export_options] ||= {} values[:export_options][:compileBitcode] = false values[:export_options][:stripSwiftSymbols] = true values[:export_options][:uploadSymbols] = false if !icloud_id.nil? values[:export_options][:iCloudContainerEnvironment] = icloud_env end values end |
.get_target_name_map ⇒ Object
获取 Target 名称映射
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 117 def get_target_name_map return { "MainTarget" => "bundle_id", "Content" => "bundle_id_pushcontent", "Service" => "bundle_id_pushservice", "Keyboard" => "bundle_id_keyboard", "iMessage" => "bundle_id_imessage", "Siri" => "bundle_id_siri", "SiriUI" => "bundle_id_siriui", "Widget" => "bundle_id_widget", "Extension" => "bundle_id_extension", "ExtensionAd" => "bundle_id_extensionad", "ExtensionPorn" => "bundle_id_extensionporn", "WatchApp" => "bundle_id_watchapp", "WatchAppComplication" => "bundle_id_watchapp_extension" } end |
.install_google_plist(project_dir: nil, app_config_dir: nil) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 94 def install_google_plist(project_dir:nil, app_config_dir:nil) project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)} project_obj = Xcodeproj::Project.open(project_fullname) select_target = project_obj.targets.select { |target| target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) }.first file_ref = select_target.resources_build_phase.files_references.select { |file| file.display_name.include?("GoogleService-Info.plist") }.first if !file_ref.nil? xcode_googleinfo_path = file_ref.real_path if !File.exist?(File.join(app_config_dir, "GoogleService-Info.plist")) raise Informative, "缺少 GoogleService-Info.plist ==> #{app_config_dir}!!!" else FileUtils.cp(File.join(app_config_dir, "GoogleService-Info.plist"), xcode_googleinfo_path) end if !File.exist?(xcode_googleinfo_path) raise Informative, "拷贝 GoogleService-Info.plist 失败!!==> #{xcode_googleinfo_path}!!!" end end end |
.modify_info_plist(project_dir: nil, proj_name: nil, config_json: nil) ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 324 def modify_info_plist(project_dir:nil, proj_name:nil, config_json:nil) ## Main Info.plist proj_fullname = File.join(project_dir, proj_name) + ".xcodeproj" project_obj = Xcodeproj::Project.open(proj_fullname) info_plist_path = nil project_obj.targets.each do |target| temp_info = target.build_configurations.first.build_settings['INFOPLIST_FILE'] if !temp_info.nil? info_plist_path = File.join(project_dir, temp_info) end # if target.product_type.to_s.eql?("com.apple.product-type.application") && !File.exist?(info_plist_path) # info_plist_array = Dir.glob(File.join(project_dir, target.name, "**", "Info.plist")) # if info_plist_array.size == 1 # info_plist_path = info_plist_array.first # else # raise Informative, "Missing Target #{target.name.to_s} Info.plist !!! Modify Info.plist Error !!!" # end # end if target.product_type.to_s.eql?("com.apple.product-type.application") && (info_plist_path.nil? || !File.exist?(info_plist_path)) raise Informative, "Target #{target.name.to_s} 没有找到Info.plist, 修改Info.plist出错了!!" end if target.product_type.to_s.eql?("com.apple.product-type.application") then modify_maintarget_info_plist(plist_file_name:info_plist_path, config_json:config_json, target_name:proj_name) end modify_infoplist_version(plist_file_name:info_plist_path, config_json:config_json, target_name:target.name.to_s) end end |
.modify_infoplist_version(plist_file_name: nil, config_json: nil, target_name: nil) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 177 def modify_infoplist_version(plist_file_name:nil, config_json:nil, target_name:nil) if File.exist?(plist_file_name) info_plist_dict = Xcodeproj::Plist.read_from_path(plist_file_name) info_plist_dict["CFBundleIdentifier"] = "$(PRODUCT_BUNDLE_IDENTIFIER)" exe_binary_name = config_json['app_info']["app_display_name"] exe_binary_name = exe_binary_name.gsub(/ /, ''); exe_binary_name = exe_binary_name.gsub(/\'/, ''); info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["app_display_name"] if !info_plist_dict["CFBundleName"].nil? info_plist_dict["CFBundleName"] = exe_binary_name end if config_json['app_info']["imessage_display_name"] && target_name && target_name.end_with?("iMessage") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["imessage_display_name"] end if config_json['app_info']["extension_display_name"] && target_name && target_name.end_with?("Extension") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["extension_display_name"] end if config_json['app_info']["extensionad_display_name"] && target_name && target_name.end_with?("ExtensionAd") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["extensionad_display_name"] end if config_json['app_info']["extensionporn_display_name"] && target_name && target_name.end_with?("ExtensionPorn") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["extensionporn_display_name"] end if config_json['app_info']["keyboard_display_name"] && target_name && target_name.end_with?("Keyboard") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["keyboard_display_name"] end if config_json['app_info']["siri_display_name"] && target_name && target_name.end_with?("Keyboard") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["siri_display_name"] end if config_json['app_info']["siriui_display_name"] && target_name && target_name.end_with?("iMessage") info_plist_dict["CFBundleDisplayName"] = config_json['app_info']["siriui_display_name"] end unless config_json['app_info']["app_version"] raise Informative, "config.json Missing app_info app_version !!!" end info_plist_dict["CFBundleShortVersionString"] = config_json['app_info']["app_version"] unless config_json['app_info']["app_build_version"] raise Informative, "config.json Missing app_info app_build_version !!!" end info_plist_dict["CFBundleVersion"] = config_json['app_info']["app_build_version"] Xcodeproj::Plist.write_to_path(info_plist_dict, plist_file_name) end end |
.modify_maintarget_info_plist(plist_file_name: nil, config_json: nil, target_name: nil) ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 238 def modify_maintarget_info_plist(plist_file_name:nil, config_json:nil, target_name:nil) if File.exist?(plist_file_name) info_plist_dict = Xcodeproj::Plist.read_from_path(plist_file_name) info_plist_dict.delete("AccountKitClientToken") if info_plist_dict["Fabric"] info_plist_dict.delete('Fabric') end if info_plist_dict["UIRequiredDeviceCapabilities"] && !info_plist_dict["UIRequiredDeviceCapabilities"].first.nil? && info_plist_dict["UIRequiredDeviceCapabilities"].first == "armv7" raise Informative, "Info.plist里面有多余的Key UIRequiredDeviceCapabilities armv7" end if !config_json['app_info']['admob_app_id'].nil? && config_json['app_info']['admob_app_id'].include?("__________config") raise Informative, "config.json 配置文件key :admob_app_id 包含初始值未修改, 配置正确的值或者删除!!!" end if !info_plist_dict["GADApplicationIdentifier"].nil? && config_json['app_info']['admob_app_id'].nil? raise Informative, "工程Info.plist中有 Admob 配置,config.json缺少 Admob 配置参数!!!" end if !config_json['app_info']['admob_app_id'].nil? info_plist_dict["GADApplicationIdentifier"] = config_json['app_info']['admob_app_id'] end if !config_json['app_info']['applovin_app_id'].nil? && config_json['app_info']['applovin_app_id'].include?("__________config") raise Informative, "config.json 配置文件key :applovin_app_id 包含初始值未修改, 配置正确的值或者删除!!!" end if !info_plist_dict["AppLovinSdkKey"].nil? && config_json['app_info']['applovin_app_id'].nil? raise Informative, "工程Info.plist中有 AppLovin 配置,config.json缺少 AppLovin 配置参数!!!" end if !info_plist_dict["AppLovinSdkKey"].nil? && !config_json['app_info']['applovin_app_id'].nil? info_plist_dict["AppLovinSdkKey"] = config_json['app_info']['applovin_app_id'] else info_plist_dict.delete('AppLovinSdkKey') end # if config_json['app_setting'] && config_json['app_setting']['applovin_app_id'] # info_plist_dict["AppLovinSdkKey"] = config_json['app_setting']['applovin_app_id'] # elsif config_json['app_setting'] && config_json['app_setting']['kGUKeyApplovinAppId'] # info_plist_dict["AppLovinSdkKey"] = config_json['app_setting']['kGUKeyApplovinAppId'] # else # info_plist_dict.delete('AppLovinSdkKey') # end info_plist_dict["CFBundleURLTypes"] = [] item0 = {} item0["CFBundleTypeRole"] = "Editor" item0["CFBundleURLName"] = "$(PRODUCT_BUNDLE_IDENTIFIER)" item0["CFBundleURLSchemes"] = [] item0["CFBundleURLSchemes"] << "$(PRODUCT_BUNDLE_IDENTIFIER)" info_plist_dict["CFBundleURLTypes"] << item0 if config_json['app_info'] && config_json['app_info']['facebook_app_id'] info_plist_dict["FacebookAppID"] = config_json['app_info']['facebook_app_id'] if config_json['app_info']['facebook_client_token'].nil? raise Informative, "config.json FB Token 是空的" end info_plist_dict["FacebookClientToken"] = config_json['app_info']['facebook_client_token'] info_plist_dict["FacebookDisplayName"] = config_json['app_info']['app_display_name'] item1 = {} item1["CFBundleTypeRole"] = "Editor" item1["CFBundleURLSchemes"] = [] item1["CFBundleURLSchemes"] << "fb" + config_json['app_info']['facebook_app_id'] info_plist_dict["CFBundleURLTypes"] << item1 else info_plist_dict.delete('FacebookAppID') info_plist_dict.delete('FacebookClientToken') info_plist_dict.delete('FacebookDisplayName') end Xcodeproj::Plist.write_to_path(info_plist_dict, plist_file_name) end end |
.modify_project_config(project_dir: nil, proj_name: nil, config_json: nil) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 135 def modify_project_config(project_dir:nil, proj_name:nil, config_json:nil) proj_fullname = File.join(project_dir, proj_name) + ".xcodeproj" project_obj = Xcodeproj::Project.open(proj_fullname) ios_deployment_targe = "14.0" if config_json && config_json['project_info'] && config_json['project_info']['ios_deployment_targe'] ios_deployment_targe = config_json['project_info']['ios_deployment_targe'] end project_obj.targets.each do |target| exe_binary_name = config_json['app_info']['app_display_name'] exe_binary_name = exe_binary_name.gsub(/ /, ''); exe_binary_name = exe_binary_name.gsub(/\'/, ''); target.build_configurations.each do |config| config.build_settings['CURRENT_PROJECT_VERSION'] = config_json['app_info']['app_build_version'] config.build_settings['MARKETING_VERSION'] = config_json['app_info']['app_version'] config.build_settings['INFOPLIST_KEY_CFBundleDisplayName'] = config_json['app_info']['app_display_name'] end target_name_map = get_target_name_map if target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) target.build_configurations.each do |config| config.build_settings['PRODUCT_NAME'] = exe_binary_name config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ios_deployment_targe end elsif target_name_map.each do |k, v| if target.name.to_s.end_with?(k) target.build_configurations.each do |config| config.build_settings['PRODUCT_NAME'] = exe_binary_name + k end end end end end project_obj.save end |
.pull_podfile_lock(project_dir: nil, app_config_dir: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pindo/module/xcode/xcode_build_helper.rb', line 29 def pull_podfile_lock(project_dir:nil, app_config_dir:nil) begin src_pod_file = File.join(app_config_dir, "Podfile.lock") build_verify_file = File.join(app_config_dir, "build_verify.json") build_verify_json = nil begin build_verify_json = JSON.parse(File.read(build_verify_file)) rescue => error end build_verify_json = build_verify_json || {} build_verify_json["release_code_commit"] = git_latest_commit_id(local_repo_dir:project_dir) build_verify_json["release_config_commit"] = git_latest_commit_id(local_repo_dir:app_config_dir) bytes = File.binread(src_pod_file) checksum = Digest::MD5.hexdigest(bytes) build_verify_json["release_podfile_checksum"] = checksum build_verify_json["release_time"] = Time.now.strftime('%y/%m/%d %H:%M:%S') File.open(build_verify_file, "w") do |file| file.write(JSON.pretty_generate(build_verify_json)) file.close end git_addpush_repo(path:app_config_dir, message:"back release info", commit_file_params:["build_verify.json"]) if File.exist?(src_pod_file) FileUtils.cp_r(src_pod_file, File.join(project_dir, "Podfile.lock")) end rescue => error raise Informative, "获取Podfile.lock 文件失败!!!" end end |