class Escalator::Archive
Attributes
archive_path[RW]
assets_paths[RW]
cmd_source[RW]
command[RW]
coverInfo_path[RW]
output_path[RW]
plist_path[RW]
product_name[RW]
scheme[RW]
Public Class Methods
run(command)
click to toggle source
# File lib/escalator/archive.rb, line 7 def run command @command = command Throw.note "Begin archive #{File.basename File.dirname command.project_path} ..." prepareContext buildProject archiveProject exportAssets exportCoverInfo if command.show_output? system "open #{command.output_path}" end Throw.note "Archive Success!" "#{output_path}/#{product_name}.ipa" end
Private Class Methods
archiveProject()
click to toggle source
# File lib/escalator/archive.rb, line 93 def archiveProject Throw.note "Begin export ipa ..." cmd = "xcodebuild -exportArchive -archivePath #{archive_path} \ -exportPath #{output_path} -exportOptionsPlist #{plist_path} \ -allowProvisioningUpdates" system cmd if !$?.success? Throw.error "Export faild with #{cmd}" end end
buildProject()
click to toggle source
# File lib/escalator/archive.rb, line 83 def buildProject Throw.note "Begin build project ..." cmd = "xcodebuild archive #{cmd_source} -scheme #{scheme} \ -configuration Release -arch arm64 -archivePath #{archive_path}" system cmd if !$?.success? Throw.error "Build faild with #{cmd}" end end
exportAssets()
click to toggle source
# File lib/escalator/archive.rb, line 104 def exportAssets Throw.note "Begin export assets ..." assets_paths.each { |path| FileUtils.cp_r path, output_path } end
exportCoverInfo()
click to toggle source
# File lib/escalator/archive.rb, line 111 def exportCoverInfo Throw.note "Begin export CoverInfo.plist ..." if File.exist? coverInfo_path FileUtils.cp_r coverInfo_path, output_path end end
prepareContext()
click to toggle source
# File lib/escalator/archive.rb, line 42 def prepareContext Throw.note "Prepare archive context ..." tmpdir = ENV["TMPDIR"] + "escalator/archive" if File.exist? tmpdir FileUtils.rm_rf Dir["#{tmpdir}/*"] else FileUtils.mkdir_p tmpdir end @plist_path = "#{tmpdir}/ExportOptions.plist" @scheme = Xcodeproj::Project.schemes(command.project_path).first project = Xcodeproj::Project.open command.project_path target = project.targets.first @assets_paths = target.resources_build_phase.files.select { |f| f.file_ref.real_path.extname == ".xcassets" }.map { |f| f.file_ref.real_path.to_s } build_settings = target.build_settings "Release" enableBitCode = build_settings["ENABLE_BITCODE"] == "YES" @product_name = build_settings["PRODUCT_NAME"] if product_name == "$(TARGET_NAME)" @product_name = target.name end @archive_path = "#{tmpdir}/#{product_name}.xcarchive" base_path = File.dirname command.project_path @coverInfo_path = base_path + "/CoverInfo.plist" project_name = File.basename(command.project_path).split(".").first workspace_path = "#{base_path}/#{project_name}.xcworkspace" @cmd_source = "-project #{command.project_path}" if File.exist? workspace_path @cmd_source = "-workspace #{workspace_path}" end @output_path = File.expand_path "./#{File.basename base_path}", command.output_path FileUtils.rm_rf output_path options_path = File.expand_path "../../../resources/ExportOptions.plist", __FILE__ plist = CFPropertyList::List.new :file => options_path data = CFPropertyList.native_types plist.value data["method"] = command.method data["uploadBitcode"] = enableBitCode plist.value = CFPropertyList::guess data plist.save plist_path end