brick-module 0.1.1

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,339 @@
1
+ // Generated by Apple Swift version 6.0.3 effective-5.10 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
2
+ #ifndef BRICKMODULE_SWIFT_H
3
+ #define BRICKMODULE_SWIFT_H
4
+ #pragma clang diagnostic push
5
+ #pragma clang diagnostic ignored "-Wgcc-compat"
6
+
7
+ #if !defined(__has_include)
8
+ # define __has_include(x) 0
9
+ #endif
10
+ #if !defined(__has_attribute)
11
+ # define __has_attribute(x) 0
12
+ #endif
13
+ #if !defined(__has_feature)
14
+ # define __has_feature(x) 0
15
+ #endif
16
+ #if !defined(__has_warning)
17
+ # define __has_warning(x) 0
18
+ #endif
19
+
20
+ #if __has_include(<swift/objc-prologue.h>)
21
+ # include <swift/objc-prologue.h>
22
+ #endif
23
+
24
+ #pragma clang diagnostic ignored "-Wauto-import"
25
+ #if defined(__OBJC__)
26
+ #include <Foundation/Foundation.h>
27
+ #endif
28
+ #if defined(__cplusplus)
29
+ #include <cstdint>
30
+ #include <cstddef>
31
+ #include <cstdbool>
32
+ #include <cstring>
33
+ #include <stdlib.h>
34
+ #include <new>
35
+ #include <type_traits>
36
+ #else
37
+ #include <stdint.h>
38
+ #include <stddef.h>
39
+ #include <stdbool.h>
40
+ #include <string.h>
41
+ #endif
42
+ #if defined(__cplusplus)
43
+ #pragma clang diagnostic push
44
+ #pragma clang diagnostic ignored "-Wnon-modular-include-in-framework-module"
45
+ #if defined(__arm64e__) && __has_include(<ptrauth.h>)
46
+ # include <ptrauth.h>
47
+ #else
48
+ #pragma clang diagnostic push
49
+ #pragma clang diagnostic ignored "-Wreserved-macro-identifier"
50
+ # ifndef __ptrauth_swift_value_witness_function_pointer
51
+ # define __ptrauth_swift_value_witness_function_pointer(x)
52
+ # endif
53
+ # ifndef __ptrauth_swift_class_method_pointer
54
+ # define __ptrauth_swift_class_method_pointer(x)
55
+ # endif
56
+ #pragma clang diagnostic pop
57
+ #endif
58
+ #pragma clang diagnostic pop
59
+ #endif
60
+
61
+ #if !defined(SWIFT_TYPEDEFS)
62
+ # define SWIFT_TYPEDEFS 1
63
+ # if __has_include(<uchar.h>)
64
+ # include <uchar.h>
65
+ # elif !defined(__cplusplus)
66
+ typedef uint_least16_t char16_t;
67
+ typedef uint_least32_t char32_t;
68
+ # endif
69
+ typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
70
+ typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
71
+ typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
72
+ typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
73
+ typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
74
+ typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
75
+ typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
76
+ typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
77
+ typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
78
+ typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
79
+ typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
80
+ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
81
+ #endif
82
+
83
+ #if !defined(SWIFT_PASTE)
84
+ # define SWIFT_PASTE_HELPER(x, y) x##y
85
+ # define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
86
+ #endif
87
+ #if !defined(SWIFT_METATYPE)
88
+ # define SWIFT_METATYPE(X) Class
89
+ #endif
90
+ #if !defined(SWIFT_CLASS_PROPERTY)
91
+ # if __has_feature(objc_class_property)
92
+ # define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
93
+ # else
94
+ # define SWIFT_CLASS_PROPERTY(...)
95
+ # endif
96
+ #endif
97
+ #if !defined(SWIFT_RUNTIME_NAME)
98
+ # if __has_attribute(objc_runtime_name)
99
+ # define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
100
+ # else
101
+ # define SWIFT_RUNTIME_NAME(X)
102
+ # endif
103
+ #endif
104
+ #if !defined(SWIFT_COMPILE_NAME)
105
+ # if __has_attribute(swift_name)
106
+ # define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
107
+ # else
108
+ # define SWIFT_COMPILE_NAME(X)
109
+ # endif
110
+ #endif
111
+ #if !defined(SWIFT_METHOD_FAMILY)
112
+ # if __has_attribute(objc_method_family)
113
+ # define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
114
+ # else
115
+ # define SWIFT_METHOD_FAMILY(X)
116
+ # endif
117
+ #endif
118
+ #if !defined(SWIFT_NOESCAPE)
119
+ # if __has_attribute(noescape)
120
+ # define SWIFT_NOESCAPE __attribute__((noescape))
121
+ # else
122
+ # define SWIFT_NOESCAPE
123
+ # endif
124
+ #endif
125
+ #if !defined(SWIFT_RELEASES_ARGUMENT)
126
+ # if __has_attribute(ns_consumed)
127
+ # define SWIFT_RELEASES_ARGUMENT __attribute__((ns_consumed))
128
+ # else
129
+ # define SWIFT_RELEASES_ARGUMENT
130
+ # endif
131
+ #endif
132
+ #if !defined(SWIFT_WARN_UNUSED_RESULT)
133
+ # if __has_attribute(warn_unused_result)
134
+ # define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
135
+ # else
136
+ # define SWIFT_WARN_UNUSED_RESULT
137
+ # endif
138
+ #endif
139
+ #if !defined(SWIFT_NORETURN)
140
+ # if __has_attribute(noreturn)
141
+ # define SWIFT_NORETURN __attribute__((noreturn))
142
+ # else
143
+ # define SWIFT_NORETURN
144
+ # endif
145
+ #endif
146
+ #if !defined(SWIFT_CLASS_EXTRA)
147
+ # define SWIFT_CLASS_EXTRA
148
+ #endif
149
+ #if !defined(SWIFT_PROTOCOL_EXTRA)
150
+ # define SWIFT_PROTOCOL_EXTRA
151
+ #endif
152
+ #if !defined(SWIFT_ENUM_EXTRA)
153
+ # define SWIFT_ENUM_EXTRA
154
+ #endif
155
+ #if !defined(SWIFT_CLASS)
156
+ # if __has_attribute(objc_subclassing_restricted)
157
+ # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
158
+ # define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
159
+ # else
160
+ # define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
161
+ # define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
162
+ # endif
163
+ #endif
164
+ #if !defined(SWIFT_RESILIENT_CLASS)
165
+ # if __has_attribute(objc_class_stub)
166
+ # define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME) __attribute__((objc_class_stub))
167
+ # define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_class_stub)) SWIFT_CLASS_NAMED(SWIFT_NAME)
168
+ # else
169
+ # define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME)
170
+ # define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) SWIFT_CLASS_NAMED(SWIFT_NAME)
171
+ # endif
172
+ #endif
173
+ #if !defined(SWIFT_PROTOCOL)
174
+ # define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
175
+ # define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
176
+ #endif
177
+ #if !defined(SWIFT_EXTENSION)
178
+ # define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
179
+ #endif
180
+ #if !defined(OBJC_DESIGNATED_INITIALIZER)
181
+ # if __has_attribute(objc_designated_initializer)
182
+ # define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
183
+ # else
184
+ # define OBJC_DESIGNATED_INITIALIZER
185
+ # endif
186
+ #endif
187
+ #if !defined(SWIFT_ENUM_ATTR)
188
+ # if __has_attribute(enum_extensibility)
189
+ # define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
190
+ # else
191
+ # define SWIFT_ENUM_ATTR(_extensibility)
192
+ # endif
193
+ #endif
194
+ #if !defined(SWIFT_ENUM)
195
+ # define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
196
+ # if __has_feature(generalized_swift_name)
197
+ # define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
198
+ # else
199
+ # define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
200
+ # endif
201
+ #endif
202
+ #if !defined(SWIFT_UNAVAILABLE)
203
+ # define SWIFT_UNAVAILABLE __attribute__((unavailable))
204
+ #endif
205
+ #if !defined(SWIFT_UNAVAILABLE_MSG)
206
+ # define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
207
+ #endif
208
+ #if !defined(SWIFT_AVAILABILITY)
209
+ # define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
210
+ #endif
211
+ #if !defined(SWIFT_WEAK_IMPORT)
212
+ # define SWIFT_WEAK_IMPORT __attribute__((weak_import))
213
+ #endif
214
+ #if !defined(SWIFT_DEPRECATED)
215
+ # define SWIFT_DEPRECATED __attribute__((deprecated))
216
+ #endif
217
+ #if !defined(SWIFT_DEPRECATED_MSG)
218
+ # define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
219
+ #endif
220
+ #if !defined(SWIFT_DEPRECATED_OBJC)
221
+ # if __has_feature(attribute_diagnose_if_objc)
222
+ # define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
223
+ # else
224
+ # define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
225
+ # endif
226
+ #endif
227
+ #if defined(__OBJC__)
228
+ #if !defined(IBSegueAction)
229
+ # define IBSegueAction
230
+ #endif
231
+ #endif
232
+ #if !defined(SWIFT_EXTERN)
233
+ # if defined(__cplusplus)
234
+ # define SWIFT_EXTERN extern "C"
235
+ # else
236
+ # define SWIFT_EXTERN extern
237
+ # endif
238
+ #endif
239
+ #if !defined(SWIFT_CALL)
240
+ # define SWIFT_CALL __attribute__((swiftcall))
241
+ #endif
242
+ #if !defined(SWIFT_INDIRECT_RESULT)
243
+ # define SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result))
244
+ #endif
245
+ #if !defined(SWIFT_CONTEXT)
246
+ # define SWIFT_CONTEXT __attribute__((swift_context))
247
+ #endif
248
+ #if !defined(SWIFT_ERROR_RESULT)
249
+ # define SWIFT_ERROR_RESULT __attribute__((swift_error_result))
250
+ #endif
251
+ #if defined(__cplusplus)
252
+ # define SWIFT_NOEXCEPT noexcept
253
+ #else
254
+ # define SWIFT_NOEXCEPT
255
+ #endif
256
+ #if !defined(SWIFT_C_INLINE_THUNK)
257
+ # if __has_attribute(always_inline)
258
+ # if __has_attribute(nodebug)
259
+ # define SWIFT_C_INLINE_THUNK inline __attribute__((always_inline)) __attribute__((nodebug))
260
+ # else
261
+ # define SWIFT_C_INLINE_THUNK inline __attribute__((always_inline))
262
+ # endif
263
+ # else
264
+ # define SWIFT_C_INLINE_THUNK inline
265
+ # endif
266
+ #endif
267
+ #if defined(_WIN32)
268
+ #if !defined(SWIFT_IMPORT_STDLIB_SYMBOL)
269
+ # define SWIFT_IMPORT_STDLIB_SYMBOL __declspec(dllimport)
270
+ #endif
271
+ #else
272
+ #if !defined(SWIFT_IMPORT_STDLIB_SYMBOL)
273
+ # define SWIFT_IMPORT_STDLIB_SYMBOL
274
+ #endif
275
+ #endif
276
+ #if defined(__OBJC__)
277
+ #if __has_feature(objc_modules)
278
+ #if __has_warning("-Watimport-in-framework-header")
279
+ #pragma clang diagnostic ignored "-Watimport-in-framework-header"
280
+ #endif
281
+ @import Foundation;
282
+ @import ObjectiveC;
283
+ #endif
284
+
285
+ #endif
286
+ #pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
287
+ #pragma clang diagnostic ignored "-Wduplicate-method-arg"
288
+ #if __has_warning("-Wpragma-clang-attribute")
289
+ # pragma clang diagnostic ignored "-Wpragma-clang-attribute"
290
+ #endif
291
+ #pragma clang diagnostic ignored "-Wunknown-pragmas"
292
+ #pragma clang diagnostic ignored "-Wnullability"
293
+ #pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
294
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
295
+
296
+ #if __has_attribute(external_source_symbol)
297
+ # pragma push_macro("any")
298
+ # undef any
299
+ # pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="BrickModule",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
300
+ # pragma pop_macro("any")
301
+ #endif
302
+
303
+ #if defined(__OBJC__)
304
+ @class NSArray;
305
+ @class NSString;
306
+ @class RCTEventEmitter;
307
+
308
+ /// Central registry for all Brick modules
309
+ /// Manages module lifecycle and provides simple module storage
310
+ SWIFT_CLASS("_TtC11BrickModule19BrickModuleRegistry")
311
+ @interface BrickModuleRegistry : NSObject
312
+ SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) BrickModuleRegistry * _Nonnull shared;)
313
+ + (BrickModuleRegistry * _Nonnull)shared SWIFT_WARN_UNUSED_RESULT;
314
+ - (nonnull instancetype)init SWIFT_UNAVAILABLE;
315
+ + (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable");
316
+ /// Registers an array of Brick modules (Objective-C API)
317
+ /// Each module must implement BrickModuleBase protocol
318
+ /// This should be called once during app initialization
319
+ - (void)registerModules:(NSArray * _Nonnull)modules;
320
+ /// Returns list of registered module names
321
+ - (NSArray<NSString *> * _Nonnull)getRegisteredModules SWIFT_WARN_UNUSED_RESULT;
322
+ /// Sets the React Native event emitter instance for event emission
323
+ /// This should be called during app initialization from the main BrickModule
324
+ - (void)setEventEmitter:(RCTEventEmitter * _Nonnull)eventEmitter;
325
+ /// Returns the React Native event emitter instance for event emission
326
+ /// Used by generated module code to emit events to JavaScript
327
+ - (RCTEventEmitter * _Nullable)getEventEmitter SWIFT_WARN_UNUSED_RESULT;
328
+ /// Clears all registered modules (for testing purposes only)
329
+ - (void)clearRegistry;
330
+ @end
331
+
332
+ #endif
333
+ #if __has_attribute(external_source_symbol)
334
+ # pragma clang attribute pop
335
+ #endif
336
+ #if defined(__cplusplus)
337
+ #endif
338
+ #pragma clang diagnostic pop
339
+ #endif
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "brick-module",
3
+ "version": "0.1.1",
4
+ "description": "Better React Native native module development",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./podfile_helper.rb": "./podfile_helper.rb",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist/",
19
+ "ios/",
20
+ "android/",
21
+ "src/",
22
+ "bin/",
23
+ "BrickModule.podspec",
24
+ "podfile_helper.rb"
25
+ ],
26
+ "keywords": [
27
+ "react-native",
28
+ "native-module",
29
+ "turbomodule",
30
+ "ios",
31
+ "swift",
32
+ "jsi",
33
+ "codegen",
34
+ "brick-module"
35
+ ],
36
+ "license": "Apache-2.0",
37
+ "author": "Toss <opensource@toss.im>",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/toss/brick.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/toss/brick/issues"
44
+ },
45
+ "homepage": "https://github.com/toss/brick#readme",
46
+ "bin": {
47
+ "brick-codegen": "./bin/brick-codegen.js"
48
+ },
49
+ "dependencies": {
50
+ "brick-codegen": "0.1.1"
51
+ },
52
+ "peerDependencies": {
53
+ "react": ">=18.2.0",
54
+ "react-native": ">=0.70.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/react": "^18.2.0",
58
+ "@types/react-native": "^0.72.0",
59
+ "tsdown": "^0.12.8",
60
+ "typescript": "^5.1.0"
61
+ },
62
+ "codegenConfig": {
63
+ "name": "BrickModuleSpec",
64
+ "type": "modules",
65
+ "jsSrcsDir": "src",
66
+ "includesGeneratedCode": true
67
+ },
68
+ "scripts": {
69
+ "build": "tsdown",
70
+ "test": "vitest",
71
+ "lint": "biome lint --write .",
72
+ "format": "biome format --write .",
73
+ "typecheck": "tsc --noEmit"
74
+ }
75
+ }
@@ -0,0 +1,176 @@
1
+ # Copyright (c) Toss.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ require 'json'
7
+ require 'pathname'
8
+
9
+ def use_brick_modules!
10
+ brick_root = "#{Pod::Config.instance.installation_root}/.."
11
+ discovered_modules = []
12
+
13
+ begin
14
+ # Discover Brick modules before running codegen
15
+ discovered_modules = discover_brick_modules(brick_root)
16
+
17
+ # Run brick-codegen with real-time output and colors (iOS only)
18
+ exit_status = system("cd #{brick_root} && FORCE_COLOR=1 npx brick-codegen --platform ios")
19
+
20
+ if exit_status
21
+ # Generate BrickModuleProvider.swift for auto-registration
22
+ generate_brick_module_provider(brick_root, discovered_modules)
23
+
24
+ # Add generated BrickCodegen pod if it exists
25
+ brick_codegen_podspec_path = "#{brick_root}/ios/.brick/BrickCodegen.podspec"
26
+ brick_codegen_pod_path = "#{brick_root}/ios/.brick"
27
+
28
+ if File.exist?(brick_codegen_podspec_path)
29
+ begin
30
+ pod 'BrickCodegen', :path => brick_codegen_pod_path
31
+ rescue => pod_error
32
+ Pod::UI.warn "[Brick] Failed to add BrickCodegen pod: #{pod_error.message}"
33
+ end
34
+ end
35
+ else
36
+ Pod::UI.warn "[Brick] brick-codegen failed to run. Please make sure it's installed: npm install brick-codegen"
37
+ end
38
+ rescue => e
39
+ Pod::UI.warn "[Brick] Error running brick-codegen: #{e.message}"
40
+ end
41
+ end
42
+
43
+ def discover_brick_modules(project_root)
44
+ modules = []
45
+ node_modules_path = File.join(project_root, 'node_modules')
46
+
47
+ return modules unless File.exist?(node_modules_path)
48
+
49
+ # Read the main package.json to get dependencies
50
+ package_json_path = File.join(project_root, 'package.json')
51
+ return modules unless File.exist?(package_json_path)
52
+
53
+ begin
54
+ package_json = JSON.parse(File.read(package_json_path))
55
+ dependencies = (package_json['dependencies'] || {}).merge(package_json['devDependencies'] || {})
56
+
57
+ dependencies.each do |dep_name, _version|
58
+ dep_path = File.join(node_modules_path, dep_name)
59
+ dep_package_json_path = File.join(dep_path, 'package.json')
60
+
61
+ next unless File.exist?(dep_package_json_path)
62
+
63
+ begin
64
+ dep_package_json = JSON.parse(File.read(dep_package_json_path))
65
+
66
+ # Check if this is a Brick module
67
+ if dep_package_json['brickModule']
68
+ brick_config = dep_package_json['brickModule']
69
+ ios_config = brick_config['ios'] || {}
70
+
71
+ # Extract the iOS module name and class name
72
+ module_name = ios_config['moduleName']
73
+ class_name = ios_config['className']
74
+
75
+ modules << {
76
+ 'name' => dep_name,
77
+ 'moduleName' => module_name,
78
+ 'className' => class_name,
79
+ }
80
+
81
+ Pod::UI.puts "[Brick] Found module: #{dep_name} (#{module_name})"
82
+ end
83
+ rescue => e
84
+ Pod::UI.warn "[Brick] Failed to parse #{dep_package_json_path}: #{e.message}"
85
+ end
86
+ end
87
+ rescue => e
88
+ Pod::UI.warn "[Brick] Failed to discover modules: #{e.message}"
89
+ end
90
+
91
+ modules
92
+ end
93
+
94
+ def generate_brick_module_provider(project_root, modules)
95
+ return if modules.empty?
96
+
97
+ # Create the .brick directory if it doesn't exist
98
+ brick_dir = File.join(project_root, 'ios', '.brick')
99
+ FileUtils.mkdir_p(brick_dir) unless File.exist?(brick_dir)
100
+
101
+ # Generate imports and module instances
102
+ imports = modules.map { |m| "import #{m['moduleName']}" }.join("\n")
103
+ module_instances = modules.map { |m| " #{m['className']}()" }.join(",\n")
104
+ module_names = modules.map { |m| " \"#{m['moduleName']}\"" }.join(",\n")
105
+
106
+ # Generate the Swift file content
107
+ swift_content = <<-SWIFT
108
+ // Auto-generated by brick-module podfile_helper.rb
109
+ // Do not edit manually - this file is regenerated on each pod install
110
+
111
+ import Foundation
112
+ import BrickModule
113
+ #{imports}
114
+
115
+ @objcMembers
116
+ public class BrickModuleProvider: NSObject {
117
+ @objc public static func registerAll() {
118
+ let modules: [BrickModuleBase] = [
119
+ #{module_instances}
120
+ ]
121
+
122
+ if !modules.isEmpty {
123
+ BrickModuleRegistry.shared.register(modules)
124
+ print("🧱 BrickModuleProvider: Registered \\(modules.count) modules")
125
+ }
126
+ }
127
+
128
+ @objc public static func getAvailableModules() -> [String] {
129
+ return [
130
+ #{module_names}
131
+ ]
132
+ }
133
+ }
134
+ SWIFT
135
+
136
+ # Write the Swift file
137
+ provider_path = File.join(brick_dir, 'BrickModuleProvider.swift')
138
+ File.write(provider_path, swift_content)
139
+
140
+ # Generate simple Objective-C wrapper with clean name
141
+ objc_header_content = <<-OBJC
142
+ // Auto-generated by brick-module podfile_helper.rb
143
+ // Simple Objective-C wrapper for auto-linking
144
+
145
+ #import <Foundation/Foundation.h>
146
+
147
+ @interface BrickModuleProviderObjC : NSObject
148
+ + (void)registerAll;
149
+ @end
150
+ OBJC
151
+
152
+ objc_impl_content = <<-OBJC
153
+ // Auto-generated by brick-module podfile_helper.rb
154
+ // Simple Objective-C wrapper implementation
155
+
156
+ #import "BrickModuleProviderObjC.h"
157
+ #import "BrickCodegen-Swift.h"
158
+
159
+ @implementation BrickModuleProviderObjC
160
+
161
+ + (void)registerAll {
162
+ [BrickModuleProvider registerAll];
163
+ }
164
+
165
+ @end
166
+ OBJC
167
+
168
+ # Write Objective-C wrapper files
169
+ objc_header_path = File.join(brick_dir, 'BrickModuleProviderObjC.h')
170
+ objc_impl_path = File.join(brick_dir, 'BrickModuleProviderObjC.m')
171
+ File.write(objc_header_path, objc_header_content)
172
+ File.write(objc_impl_path, objc_impl_content)
173
+
174
+ Pod::UI.puts "[Brick] Generated BrickModuleProvider.swift with #{modules.size} modules"
175
+ Pod::UI.puts "[Brick] Generated BrickModuleProviderObjC wrapper for clean Objective-C integration"
176
+ end