pindo 5.6.6 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,135 @@ module Pindo
7
7
 
8
8
  class XcodeBuildConfig
9
9
 
10
+ # 使用package_name更新Display Name到iOS工程的Info.plist
11
+ # @param project_dir [String] iOS项目目录路径
12
+ # @param package_name [String] 工作流的package_name(如:"Test Demo")
13
+ # @return [Boolean] 是否成功更新
14
+ def self.update_display_name_with_packagename(project_dir: nil, package_name: nil)
15
+ raise ArgumentError, "项目目录不能为空" if project_dir.nil?
16
+ raise ArgumentError, "Package Name不能为空" if package_name.nil?
17
+
18
+ # 生成 Display Name(去除特殊字符和空格)
19
+ display_name = package_name.gsub(/[^a-zA-Z0-9\s]/, '').gsub(/\s+/, '')
20
+
21
+ project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
22
+ return false if project_fullname.nil?
23
+
24
+ info_plist_path = nil
25
+
26
+ project_obj = Xcodeproj::Project.open(project_fullname)
27
+ project_obj.targets.each do |target|
28
+ if target.product_type.to_s.eql?("com.apple.product-type.application")
29
+ temp_info_file = target.build_configurations.first.build_settings['INFOPLIST_FILE']
30
+ if temp_info_file && !temp_info_file.empty?
31
+ info_plist_path = File.join(project_dir, temp_info_file)
32
+ end
33
+ break # 找到第一个application target即可
34
+ end
35
+ end
36
+
37
+ return false unless info_plist_path && File.exist?(info_plist_path)
38
+
39
+ # 使用Xcodeproj::Plist读写plist
40
+ info_plist_dict = Xcodeproj::Plist.read_from_path(info_plist_path)
41
+ info_plist_dict["CFBundleDisplayName"] = display_name
42
+ Xcodeproj::Plist.write_to_path(info_plist_dict, info_plist_path)
43
+
44
+ puts " ✓ Display Name 已更新为: #{display_name} (来自: #{package_name})"
45
+ return true
46
+ end
47
+
48
+ # 使用package_name更新Bundle ID到iOS工程(同时修改plist和xcodeproj)
49
+ # @param project_dir [String] iOS项目目录路径
50
+ # @param package_name [String] 工作流的package_name(如:"Test Demo")
51
+ # @return [Boolean] 是否成功更新
52
+ def self.update_bundleid_with_packagename(project_dir: nil, package_name: nil)
53
+ raise ArgumentError, "项目目录不能为空" if project_dir.nil?
54
+ raise ArgumentError, "Package Name不能为空" if package_name.nil?
55
+
56
+ # 从 package_name 生成 Bundle ID
57
+ bundle_id_suffix = package_name.gsub(/[^a-zA-Z0-9]/, '').downcase
58
+ final_bundle_id = "com.heroneverdie101.#{bundle_id_suffix}"
59
+
60
+ project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
61
+ return false if project_fullname.nil?
62
+
63
+ info_plist_path = nil
64
+ app_target = nil
65
+
66
+ project_obj = Xcodeproj::Project.open(project_fullname)
67
+ project_obj.targets.each do |target|
68
+ if target.product_type.to_s.eql?("com.apple.product-type.application")
69
+ temp_info_file = target.build_configurations.first.build_settings['INFOPLIST_FILE']
70
+ if temp_info_file && !temp_info_file.empty?
71
+ info_plist_path = File.join(project_dir, temp_info_file)
72
+ end
73
+ app_target = target
74
+ break # 找到第一个application target即可
75
+ end
76
+ end
77
+
78
+ return false unless info_plist_path && File.exist?(info_plist_path)
79
+
80
+ # 1. 修改 Info.plist 中的 CFBundleIdentifier
81
+ info_plist_dict = Xcodeproj::Plist.read_from_path(info_plist_path)
82
+ info_plist_dict["CFBundleIdentifier"] = final_bundle_id
83
+ Xcodeproj::Plist.write_to_path(info_plist_dict, info_plist_path)
84
+
85
+ # 2. 修改 Xcode 项目中的 PRODUCT_BUNDLE_IDENTIFIER
86
+ if app_target
87
+ app_target.build_configurations.each do |config|
88
+ config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = final_bundle_id
89
+ end
90
+ project_obj.save
91
+ end
92
+
93
+ puts " ✓ Bundle ID 已更新为: #{final_bundle_id} (来自: #{package_name})"
94
+ return true
95
+ end
96
+
97
+ # 使用package_name添加URL Scheme到iOS工程的Info.plist
98
+ # @param project_dir [String] iOS项目目录路径
99
+ # @param package_name [String] 工作流的package_name(如:"Test Demo")
100
+ # @return [Boolean] 是否成功添加
101
+ def self.add_url_scheme_packagename(project_dir: nil, package_name: nil)
102
+ raise ArgumentError, "项目目录不能为空" if project_dir.nil?
103
+ raise ArgumentError, "Package Name不能为空" if package_name.nil?
104
+
105
+ # 从 package_name 生成 URL Scheme(去除特殊字符,转小写)
106
+ scheme_value = package_name.to_s.gsub(/[^a-zA-Z0-9]/, '').downcase
107
+
108
+ project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
109
+ return false if project_fullname.nil?
110
+
111
+ info_plist_path = nil
112
+
113
+ project_obj = Xcodeproj::Project.open(project_fullname)
114
+ project_obj.targets.each do |target|
115
+ if target.product_type.to_s.eql?("com.apple.product-type.application")
116
+ temp_info_file = target.build_configurations.first.build_settings['INFOPLIST_FILE']
117
+ if temp_info_file && !temp_info_file.empty?
118
+ info_plist_path = File.join(project_dir, temp_info_file)
119
+ end
120
+ break # 找到第一个application target即可
121
+ end
122
+ end
123
+
124
+ return false unless info_plist_path && File.exist?(info_plist_path)
125
+
126
+ # 使用Xcodeproj::Plist读写plist
127
+ info_plist_dict = Xcodeproj::Plist.read_from_path(info_plist_path)
128
+ info_plist_dict["CFBundleURLTypes"] ||= []
129
+
130
+ # 添加基于package_name的URL Scheme
131
+ if add_single_scheme(info_plist_dict, scheme_value)
132
+ Xcodeproj::Plist.write_to_path(info_plist_dict, info_plist_path)
133
+ puts " ✓ 已添加URL Scheme: #{scheme_value} (来自: #{package_name})"
134
+ end
135
+
136
+ return true
137
+ end
138
+
10
139
  # 添加URL Schemes到iOS工程的Info.plist
11
140
  # @param project_dir [String] iOS项目目录路径
12
141
  # @param scheme_name [String] 要添加的scheme名称(可选)
@@ -46,7 +175,7 @@ module Pindo
46
175
  end
47
176
  end
48
177
 
49
- # 添加基于Bundle ID的scheme
178
+ # 添加基于Bundle ID的scheme(从PRODUCT_BUNDLE_IDENTIFIER中读取)
50
179
  if bundleid_scheme_name && !bundleid_scheme_name.empty?
51
180
  bundleid_scheme_value = bundleid_scheme_name.gsub(/[^a-zA-Z0-9]/, '').downcase
52
181
  if add_single_scheme(info_plist_dict, bundleid_scheme_value)
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.6.6"
9
+ VERSION = "5.7.0"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.6
4
+ version: 5.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2025-10-20 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: claide
@@ -115,20 +115,20 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '1.2'
118
+ version: '1.3'
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
- version: 1.2.0
121
+ version: 1.3.0
122
122
  type: :runtime
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '1.2'
128
+ version: '1.3'
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 1.2.0
131
+ version: 1.3.0
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: rqrcode
134
134
  requirement: !ruby/object:Gem::Requirement
@@ -479,7 +479,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
479
479
  - !ruby/object:Gem::Version
480
480
  version: '0'
481
481
  requirements: []
482
- rubygems_version: 3.6.9
482
+ rubygems_version: 3.6.3
483
483
  specification_version: 3
484
484
  summary: easy work
485
485
  test_files: []