DYXCFrameworkBuilder 0.1.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.
@@ -0,0 +1,292 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'fileutils'
5
+
6
+ module DYXCFrameworkBuilder
7
+ class YamlGenerator
8
+ attr_reader :podspec_parser, :output_path
9
+
10
+ def initialize(podspec_parser)
11
+ @podspec_parser = podspec_parser
12
+ @output_path = File.join(@podspec_parser.podspec_dir, 'build_config.yml')
13
+ end
14
+
15
+ def generate(custom_output_path = nil, auto_build = false, auto_publish = false, use_oss = false, auto_publish_private = false)
16
+ @output_path = custom_output_path if custom_output_path
17
+
18
+ # 确保输出目录存在
19
+ FileUtils.mkdir_p(File.dirname(@output_path))
20
+
21
+ # 生成 YAML 配置
22
+ yaml_content = @podspec_parser.to_yaml_config
23
+
24
+ # 写入文件
25
+ File.write(@output_path, yaml_content.to_yaml)
26
+
27
+ log_generation_info(auto_build)
28
+
29
+ # 如果启用自动构建,立即执行构建
30
+ if auto_build
31
+ build_result = auto_build_xcframework
32
+
33
+ # 根据参数选择不同的工作流程
34
+ if build_result[:success]
35
+ if auto_publish_private
36
+ # 完整工作流程:OSS 上传 + 自动发布私有库
37
+ auto_complete_workflow(build_result)
38
+ elsif use_oss
39
+ # 自动工作流程:OSS 上传 + 生成 podspec(不发布)
40
+ auto_oss_upload_and_generate_podspec(build_result)
41
+ elsif auto_publish
42
+ # 传统发布流程
43
+ auto_publish_framework(build_result)
44
+ end
45
+ end
46
+
47
+ return build_result
48
+ end
49
+
50
+ @output_path
51
+ end
52
+
53
+ def self.generate_from_podspec(podspec_path, custom_output_path = nil, auto_build = false, auto_publish = false, use_oss = false, auto_publish_private = false)
54
+ parser = PodspecParser.new(podspec_path)
55
+ generator = new(parser)
56
+ generator.generate(custom_output_path, auto_build, auto_publish, use_oss, auto_publish_private)
57
+ end
58
+
59
+ private
60
+
61
+ def log_generation_info(auto_build = false)
62
+ puts "✅ YAML configuration generated successfully!"
63
+ puts "📁 Podspec: #{@podspec_parser.podspec_path}"
64
+ puts "📄 Generated config: #{@output_path}"
65
+ puts "🏗️ Project path: #{@podspec_parser.find_workspace_path}"
66
+ puts "📦 Framework name: #{@podspec_parser.framework_name}"
67
+ puts "🎯 Deployment target: #{@podspec_parser.deployment_target || '11.0 (default)'}"
68
+
69
+ unless auto_build
70
+ puts ""
71
+ puts "Next steps:"
72
+ puts " 1. Review the generated configuration file: #{@output_path}"
73
+ puts " 2. Run the build: bundle exec builder -f #{@output_path} -v"
74
+ end
75
+ end
76
+
77
+ def auto_build_xcframework
78
+ puts ""
79
+ puts "🚀 Starting automatic XCFramework build..."
80
+ puts "="*60
81
+
82
+ begin
83
+ # 创建 Builder 实例并执行构建
84
+ builder_options = {
85
+ config_path: @output_path,
86
+ verbose: true
87
+ }
88
+
89
+ builder = Builder.new(builder_options)
90
+ result = builder.build
91
+
92
+ puts "="*60
93
+ puts "✅ XCFramework build completed successfully!"
94
+ xcframework_path = File.join(@podspec_parser.output_directory, @podspec_parser.framework_name)
95
+ puts "📦 Output: #{xcframework_path}"
96
+ puts ""
97
+ puts "🎉 Podspec to XCFramework conversion complete!"
98
+
99
+ # 返回构建结果和路径信息,供后续发布使用
100
+ {
101
+ success: true,
102
+ xcframework_path: xcframework_path,
103
+ config_path: @output_path,
104
+ parser: @podspec_parser
105
+ }
106
+ rescue => e
107
+ puts "="*60
108
+ puts "❌ Build failed: #{e.message}"
109
+ puts ""
110
+ puts "You can try building manually with:"
111
+ puts " bundle exec builder -f #{@output_path} -v"
112
+ puts ""
113
+ puts "Or check the configuration file: #{@output_path}"
114
+ raise e
115
+ end
116
+ end
117
+
118
+ def auto_publish_framework(auto_build_result)
119
+ puts ""
120
+ puts "🚀 Starting framework podspec generation and publishing..."
121
+ puts "="*60
122
+
123
+ begin
124
+ # 生成用于发布的 framework podspec
125
+ framework_info = FrameworkPodspecGenerator.generate_from_original(
126
+ auto_build_result[:parser],
127
+ auto_build_result[:xcframework_path]
128
+ )
129
+
130
+ puts ""
131
+ puts "📝 Framework podspec generated successfully!"
132
+ puts "📄 Framework podspec: #{framework_info[:path]}"
133
+ puts "📦 Framework name: #{framework_info[:name]}"
134
+ puts "🔢 Version: #{framework_info[:version]}"
135
+
136
+ # 发布到私有仓库
137
+ puts ""
138
+ publisher_success = FrameworkPublisher.publish_framework(framework_info[:path])
139
+
140
+ if publisher_success
141
+ puts ""
142
+ puts "🎉 Complete workflow finished successfully!"
143
+ puts "✅ Your framework is now available as: #{framework_info[:name]}"
144
+ puts "💡 You can now use it in your Podfile:"
145
+ puts " pod '#{framework_info[:name]}', '#{framework_info[:version]}'"
146
+ end
147
+
148
+ framework_info.merge(published: publisher_success)
149
+ rescue => e
150
+ puts "❌ Publishing failed: #{e.message}"
151
+ puts "🔧 The XCFramework was built successfully, you can publish manually"
152
+ raise e
153
+ end
154
+ end
155
+
156
+ def auto_oss_upload_and_generate_podspec(auto_build_result)
157
+ puts ""
158
+ puts "🚀 Starting auto workflow: Build → OSS Upload → Generate Podspec"
159
+ puts "="*70
160
+
161
+ begin
162
+ puts "📝 Step 1: ✅ XCFramework built successfully"
163
+ puts "📁 XCFramework path: #{auto_build_result[:xcframework_path]}"
164
+ puts ""
165
+
166
+ puts "📤 Step 2: Uploading to OSS and generating framework podspec..."
167
+
168
+ # 构建 OSS 配置
169
+ oss_config = {
170
+ access_key_id: ENV['ALIBABA_CLOUD_ACCESS_KEY_ID'],
171
+ access_key_secret: ENV['ALIBABA_CLOUD_ACCESS_KEY_SECRET'],
172
+ bucket: ENV['OSS_BUCKET'],
173
+ endpoint: ENV['OSS_ENDPOINT']
174
+ }
175
+
176
+ # 生成用于发布的 framework podspec (使用 OSS 上传)
177
+ framework_info = FrameworkPodspecGenerator.generate_from_original(
178
+ auto_build_result[:parser],
179
+ auto_build_result[:xcframework_path],
180
+ nil, # base_url
181
+ '-xc', # version_suffix
182
+ true, # use_oss
183
+ oss_config
184
+ )
185
+
186
+ puts ""
187
+ puts "✅ Step 2: OSS upload completed successfully!"
188
+ puts "🌐 OSS Download URL: #{framework_info[:download_url]}"
189
+ puts ""
190
+
191
+ puts "📝 Step 3: ✅ Framework podspec generated successfully!"
192
+ puts "📄 Podspec path: #{framework_info[:path]}"
193
+ puts "📦 Framework name: #{framework_info[:name]}"
194
+ puts "🔢 Version: #{framework_info[:version]}"
195
+
196
+ puts ""
197
+ puts "="*70
198
+ puts "🎉 Auto workflow completed successfully!"
199
+ puts ""
200
+ puts "📋 Summary:"
201
+ puts " ✅ Step 1: XCFramework built"
202
+ puts " ✅ Step 2: Uploaded to OSS"
203
+ puts " ✅ Step 3: Podspec generated"
204
+ puts ""
205
+ puts "💡 Next steps:"
206
+ puts " You can now manually publish the podspec:"
207
+ puts " pod repo push ios-specs #{framework_info[:path]} --sources='http://git.diyiedu.com/yangtianyan/ios-specs.git,https://github.com/CocoaPods/Specs' --skip-import-validation --allow-warnings"
208
+
209
+ framework_info.merge(oss_uploaded: true, published: false)
210
+ rescue => e
211
+ puts "❌ OSS upload or podspec generation failed: #{e.message}"
212
+ puts "🔧 The XCFramework was built successfully, you can upload manually"
213
+ raise e
214
+ end
215
+ end
216
+
217
+ def auto_complete_workflow(auto_build_result)
218
+ puts ""
219
+ puts "🎯 Starting complete workflow: OSS upload + private podspec publishing..."
220
+ puts "="*70
221
+
222
+ begin
223
+ # 1. 构建 OSS 配置
224
+ oss_config = {
225
+ access_key_id: ENV['ALIBABA_CLOUD_ACCESS_KEY_ID'],
226
+ access_key_secret: ENV['ALIBABA_CLOUD_ACCESS_KEY_SECRET'],
227
+ bucket: ENV['OSS_BUCKET'],
228
+ endpoint: ENV['OSS_ENDPOINT']
229
+ }
230
+
231
+ # 2. 生成用于发布的 framework podspec (使用 OSS 上传)
232
+ puts "📝 Step 1: Generating framework podspec with OSS upload..."
233
+ framework_info = FrameworkPodspecGenerator.generate_from_original(
234
+ auto_build_result[:parser],
235
+ auto_build_result[:xcframework_path],
236
+ nil, # base_url
237
+ '-xc', # version_suffix
238
+ true, # use_oss
239
+ oss_config
240
+ )
241
+
242
+ puts ""
243
+ puts "✅ Framework podspec with OSS URL generated successfully!"
244
+ puts "📄 Podspec path: #{framework_info[:path]}"
245
+ puts "📦 Framework name: #{framework_info[:name]}"
246
+ puts "🔢 Version: #{framework_info[:version]}"
247
+ puts "🌐 OSS Download URL: #{framework_info[:download_url]}"
248
+
249
+ # 3. 自动发布到私有仓库
250
+ puts ""
251
+ puts "🚀 Step 2: Publishing to private CocoaPods repository..."
252
+ puts "="*50
253
+
254
+ publisher = FrameworkPublisher.new(
255
+ framework_info[:path],
256
+ 'ios-specs' # 私有仓库名称
257
+ )
258
+
259
+ publisher_success = publisher.publish
260
+
261
+ if publisher_success
262
+ puts "="*50
263
+ puts "🎉 Complete workflow finished successfully!"
264
+ puts ""
265
+ puts "📋 Summary:"
266
+ puts " ✅ XCFramework: Built successfully"
267
+ puts " ✅ OSS Upload: #{framework_info[:download_url]}"
268
+ puts " ✅ Podspec: #{framework_info[:name]} #{framework_info[:version]}"
269
+ puts " ✅ Repository: ios-specs"
270
+ puts ""
271
+ puts "💡 Your framework is now available for use:"
272
+ puts " pod '#{framework_info[:name]}', '#{framework_info[:version]}'"
273
+ else
274
+ puts "="*50
275
+ puts "❌ Failed to publish to private repository"
276
+ puts "🔧 Manual publish command:"
277
+ puts " pod repo push ios-specs #{framework_info[:path]} --sources='http://git.diyiedu.com/yangtianyan/ios-specs.git,https://github.com/CocoaPods/Specs' --skip-import-validation --allow-warnings"
278
+ end
279
+
280
+ framework_info.merge(
281
+ oss_uploaded: true,
282
+ published: publisher_success,
283
+ complete_workflow: true
284
+ )
285
+ rescue => e
286
+ puts "❌ Complete workflow failed: #{e.message}"
287
+ puts "🔧 The XCFramework was built successfully, you can continue manually"
288
+ raise e
289
+ end
290
+ end
291
+ end
292
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "DYXCFrameworkBuilder/version"
4
+ require_relative "DYXCFrameworkBuilder/builder"
5
+ require_relative "DYXCFrameworkBuilder/podspec_parser"
6
+ require_relative "DYXCFrameworkBuilder/yaml_generator"
7
+ require_relative "DYXCFrameworkBuilder/framework_podspec_generator"
8
+ require_relative "DYXCFrameworkBuilder/framework_publisher"
9
+ require_relative "DYXCFrameworkBuilder/oss_uploader"
10
+
11
+ module DYXCFrameworkBuilder
12
+ class Error < StandardError; end
13
+
14
+ # Main entry point - delegates to the Builder class
15
+ class XCFrameworkBuilder
16
+ def initialize(options = {})
17
+ @builder = Builder.new(options)
18
+ end
19
+
20
+ def build
21
+ @builder.build
22
+ end
23
+
24
+ def self.create_config_template(path)
25
+ Builder.create_config_template(path)
26
+ end
27
+
28
+ def self.generate_config_from_podspec(podspec_path, output_path = nil, auto_build = false, auto_publish = false, use_oss = false, auto_publish_private = false)
29
+ YamlGenerator.generate_from_podspec(podspec_path, output_path, auto_build, auto_publish, use_oss, auto_publish_private)
30
+ end
31
+ end
32
+ end
33
+
34
+ # xcodebuild archive \
35
+ # -workspace DYBase.xcworkspace \
36
+ # -scheme DYBase-Example \
37
+ # -configuration Release \
38
+ # -sdk iphoneos \
39
+ # -archivePath ./archives/ios_devices \
40
+ # SKIP_INSTALL=NO \
41
+ # BUILD_LIBRARY_FOR_DISTRIBUTION=YES
42
+
43
+ # xcodebuild -create-xcframework \
44
+ # -framework /Users/leigeng/Desktop/diyi/Module/DYBase/Example/archives/ios_devices.xcarchive/Products/Library/Frameworks/DYBase.framework \
45
+ # -output DYBase.xcframework
@@ -0,0 +1,4 @@
1
+ module DYXCFrameworkBuilder
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: DYXCFrameworkBuilder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - GL
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: psych
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aliyun-sdk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.0
55
+ description: DYXCFrameworkBuilder is a comprehensive Ruby tool for automatically building
56
+ iOS private libraries into XCFramework format. It supports YAML configuration, automatic
57
+ podspec parsing, Alibaba Cloud OSS upload, and private CocoaPods repository publishing.
58
+ email:
59
+ - genglei@diyiedu.com
60
+ executables:
61
+ - xcbuilder
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".idea/.gitignore"
66
+ - ".idea/DYXCFrameworkBuilder.iml"
67
+ - ".idea/misc.xml"
68
+ - ".idea/modules.xml"
69
+ - ".idea/vcs.xml"
70
+ - ARCHITECTURE.md
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - README.md
74
+ - Rakefile
75
+ - bin/xcbuilder
76
+ - lib/DYXCFrameworkBuilder.rb
77
+ - lib/DYXCFrameworkBuilder/builder.rb
78
+ - lib/DYXCFrameworkBuilder/config.rb
79
+ - lib/DYXCFrameworkBuilder/framework_podspec_generator.rb
80
+ - lib/DYXCFrameworkBuilder/framework_publisher.rb
81
+ - lib/DYXCFrameworkBuilder/oss_uploader.rb
82
+ - lib/DYXCFrameworkBuilder/podspec_parser.rb
83
+ - lib/DYXCFrameworkBuilder/version.rb
84
+ - lib/DYXCFrameworkBuilder/xcframework_builder.rb
85
+ - lib/DYXCFrameworkBuilder/yaml_generator.rb
86
+ - sig/DYXCFrameworkBuilder.rbs
87
+ homepage: http://git.diyiedu.com/components/dyxcframeworkbuilder.git
88
+ licenses:
89
+ - MIT
90
+ metadata:
91
+ homepage_uri: http://git.diyiedu.com/components/dyxcframeworkbuilder.git
92
+ source_code_uri: http://git.diyiedu.com/components/dyxcframeworkbuilder.git
93
+ changelog_uri: https://git.diyiedu.com/components/dyxcframeworkbuilder/-/blob/master/README.md
94
+ documentation_uri: https://git.diyiedu.com/components/dyxcframeworkbuilder/-/blob/master/README.md
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.6.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.4.1
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A Ruby tool for building iOS private libraries into XCFramework
114
+ test_files: []