Class: Pindo::Command::Ios::Debug
- Inherits:
-
Pindo::Command::Ios
- Object
- Pindo::Command
- Pindo::Command::Ios
- Pindo::Command::Ios::Debug
- Includes:
- Appselect, Githelper, XcodeCertHelper
- Defined in:
- lib/pindo/command/ios/debug.rb
Class Method Summary collapse
- .modify_cert_with_project(project_dir: nil, config_file: nil, scheme_name: nil, bundleid: nil) ⇒ Object
- .modify_plist_scheme(project_dir: nil, scheme_name: nil) ⇒ Object
-
.options ⇒ Object
命令选项.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Debug
constructor
A new instance of Debug.
- #run ⇒ Object
Methods included from XcodeCertHelper
#config_infoplist_cert, #config_project_cert, #create_provisioning_info_array, #create_upload_cert_info, #create_upload_provisioning_info, #get_target_name_map, #modify_entitlements_plist, #modify_info_plist_icloud
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, which, which!
Methods included from Appselect
#all_dev_bundleid, #all_itc_bundleid, #all_release_bundleid, #all_tool_bundleid, #deploy_build_setting_json, #dev_build_setting_json, #get_deploy_repo_with_modul_name, #get_deploy_setting_repo, #get_dev_setting_repo, #get_selected_deploy_bundleid, #get_selected_dev_bundleid, #get_setting_bundleid_withdir, #load_setting, #select_main_app
Constructor Details
#initialize(argv) ⇒ Debug
Returns a new instance of Debug.
49 50 51 52 53 54 55 |
# File 'lib/pindo/command/ios/debug.rb', line 49 def initialize(argv) @args_adhoc_flag = argv.flag?('adhoc', false) @args_deploy_flag = argv.flag?('deploy', false) @args_macos_flag = argv.flag?('macos', false) @upload_flag = argv.flag?('upload', false) super end |
Class Method Details
.modify_cert_with_project(project_dir: nil, config_file: nil, scheme_name: nil, bundleid: nil) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 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 176 177 |
# File 'lib/pindo/command/ios/debug.rb', line 107 def self.modify_cert_with_project(project_dir:nil, config_file:nil, scheme_name:nil, bundleid:nil) project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)} if !project_fullname.nil? entitlements_plist_path = nil info_plist_path = nil project_obj = Xcodeproj::Project.open(project_fullname) project_obj.targets.each do |target| if target.product_type.to_s.eql?("com.apple.product-type.application") then temp_entitlements_file = target.build_configurations.first.build_settings['CODE_SIGN_ENTITLEMENTS'] if !temp_entitlements_file.nil? && !temp_entitlements_file.empty? entitlements_plist_path = File.join(project_dir, temp_entitlements_file) end temp_info_file = target.build_configurations.first.build_settings['INFOPLIST_FILE'] if !temp_info_file.nil? && !temp_info_file.empty? info_plist_path = File.join(project_dir, temp_info_file) end end end if !info_plist_path.nil? && File.exist?(info_plist_path) && !scheme_name.nil? && !scheme_name.empty? scheme_name = scheme_name.to_s.downcase.strip.gsub(/[\s\-_]/, '') info_plist_dict = Xcodeproj::Plist.read_from_path(info_plist_path) info_plist_dict["CFBundleURLTypes"] = info_plist_dict["CFBundleURLTypes"] || [] # info_plist_dict["CFBundleURLTypes"] 中不存在CFBundleURLName为scheme_name的item if !info_plist_dict["CFBundleURLTypes"].any? { |item| item["CFBundleURLName"] == scheme_name } item0 = {} item0["CFBundleTypeRole"] = "Editor" item0["CFBundleURLName"] = scheme_name item0["CFBundleURLSchemes"] = [] item0["CFBundleURLSchemes"] << scheme_name info_plist_dict["CFBundleURLTypes"] << item0 end Xcodeproj::Plist.write_to_path(info_plist_dict, info_plist_path) end # puts entitlements_plist_path if !entitlements_plist_path.nil? && File.exist?(entitlements_plist_path) config_json = nil if File.exist?(config_file) config_json = JSON.parse(File.read(config_file)) end entitlements_plist_dict = Xcodeproj::Plist.read_from_path(entitlements_plist_path) if entitlements_plist_dict["com.apple.developer.icloud-container-identifiers"].nil? if !config_json.nil? && !config_json["app_info"]['app_icloud_id'].nil? config_json["app_info"].delete('app_icloud_id') end end if entitlements_plist_dict["com.apple.security.application-groups"].nil? if !config_json.nil? && !config_json["app_info"]['app_group_id'].nil? config_json["app_info"].delete('app_group_id') end end # puts JSON.pretty_generate(config_json) if !config_json.nil? File.open(config_file, "w") do |f| f.write(JSON.pretty_generate(config_json)) end end end end end |
.modify_plist_scheme(project_dir: nil, scheme_name: nil) ⇒ Object
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 |
# File 'lib/pindo/command/ios/debug.rb', line 179 def self.modify_plist_scheme(project_dir:nil, scheme_name:nil) puts "modify_plist_scheme: #{project_dir} #{scheme_name}" project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)} if !project_fullname.nil? info_plist_path = nil bundleid_scheme_name = nil project_obj = Xcodeproj::Project.open(project_fullname) project_obj.targets.each do |target| if target.product_type.to_s.eql?("com.apple.product-type.application") then temp_info_file = target.build_configurations.first.build_settings['INFOPLIST_FILE'] if !temp_info_file.nil? && !temp_info_file.empty? info_plist_path = File.join(project_dir, temp_info_file) end bundleid_scheme_name = target.build_configurations.first.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] end end if !info_plist_path.nil? && File.exist?(info_plist_path) && !scheme_name.nil? && !scheme_name.empty? scheme_name = scheme_name.to_s.downcase.strip.gsub(/[\s\-_]/, '') info_plist_dict = Xcodeproj::Plist.read_from_path(info_plist_path) info_plist_dict["CFBundleURLTypes"] = info_plist_dict["CFBundleURLTypes"] || [] # info_plist_dict["CFBundleURLTypes"] 中不存在CFBundleURLName为scheme_name的item if !info_plist_dict["CFBundleURLTypes"].any? { |item| item["CFBundleURLName"] == scheme_name } item0 = {} item0["CFBundleTypeRole"] = "Editor" item0["CFBundleURLName"] = scheme_name item0["CFBundleURLSchemes"] = [] item0["CFBundleURLSchemes"] << scheme_name info_plist_dict["CFBundleURLTypes"] << item0 end Xcodeproj::Plist.write_to_path(info_plist_dict, info_plist_path) end if !info_plist_path.nil? && File.exist?(info_plist_path) && !bundleid_scheme_name.nil? && !bundleid_scheme_name.empty? info_plist_dict = Xcodeproj::Plist.read_from_path(info_plist_path) info_plist_dict["CFBundleURLTypes"] = info_plist_dict["CFBundleURLTypes"] || [] # info_plist_dict["CFBundleURLTypes"] 中不存在CFBundleURLName为bundleid的item #bundle id去除. 特殊字符串,保留全小写 bundleid_scheme_valeu = bundleid_scheme_name.gsub(/[^\w\s]/, '').downcase if !bundleid_scheme_name.nil? || bundleid_scheme_name.empty? || !info_plist_dict["CFBundleURLTypes"].any? { |item| item["CFBundleURLName"] == bundleid_scheme_valeu } item0 = {} item0["CFBundleTypeRole"] = "Editor" item0["CFBundleURLName"] = bundleid_scheme_valeu item0["CFBundleURLSchemes"] = [] item0["CFBundleURLSchemes"] << bundleid_scheme_valeu info_plist_dict["CFBundleURLTypes"] << item0 end Xcodeproj::Plist.write_to_path(info_plist_dict, info_plist_path) end end end |
.options ⇒ Object
命令选项
40 41 42 43 44 45 46 47 |
# File 'lib/pindo/command/ios/debug.rb', line 40 def self. [ ['--deploy', '默认使用开发环境的bundle id,使用此选项切换为发布环境的bundle id'], ['--adhoc', '默认使用开发证书,使用此选项切换为adhoc证书'], ['--macos', '指定为macOS平台的证书'], ['--upload', '生成用于上传到蒲公英平台的证书'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
58 59 60 61 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 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/pindo/command/ios/debug.rb', line 58 def run mainapp_bundleid= nil if @args_deploy_flag mainapp_bundleid = get_selected_deploy_bundleid() else mainapp_bundleid = get_selected_dev_bundleid() end args_temp = [] args_temp << mainapp_bundleid Pindo::Command::Deploy::Pullconfig::run(args_temp) project_dir = Dir.pwd Dir.chdir(project_dir) config_json_file = File.join(project_dir,"config.json") Pindo::Command::Ios::Debug::modify_cert_with_project(project_dir:project_dir, config_file:config_json_file, bundleid:mainapp_bundleid) args_temp = [] if @args_adhoc_flag args_temp << "--adhoc" else args_temp << "--dev" end project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)} if !project_fullname.nil? project_obj = Xcodeproj::Project.open(project_fullname) project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"] if !project_build_platform.nil? && project_build_platform.eql?("macosx") @args_macos_flag = true end end if @args_macos_flag args_temp << "--macos" end if @upload_flag args_temp << "--upload" end Pindo::Command::Deploy::Cert::run(args_temp) end |