@@ -134,13 +134,14 @@ export default {
134134 ] ) ;
135135 return withXcodeProject ( withAndroid , ( c ) => {
136136 const source = path . join ( c . modRequest . projectRoot , "src/assets/mea_config" ) ;
137- const destination = path . join ( c . modRequest . projectRoot , "ios" , c . modRequest . projectName ?? "" , "mea_config" ) ;
137+ const projectName = c . modRequest . projectName ?? "" ;
138+ const destination = path . join ( c . modRequest . projectRoot , "ios" , projectName , "mea_config" ) ;
138139 if ( existsSync ( source ) ) {
139140 copyFileSync ( source , destination ) ;
140- c . modResults = IOSConfig . XcodeUtils . addResourceFileToGroup ( {
141- filepath : `${ c . modRequest . projectName ?? "" } /mea_config` ,
142- groupName : c . modRequest . projectName ?? "" ,
143- project : c . modResults ,
141+ IOSConfig . XcodeUtils . addResourceFileToGroup ( {
142+ filepath : `${ projectName } /mea_config` ,
143+ groupName : projectName ,
144+ project : c . modResults , // eslint-disable-line @typescript-eslint/no-unsafe-assignment -- expo xcode project type
144145 isBuildFile : true ,
145146 } ) ;
146147 }
@@ -160,10 +161,65 @@ export default {
160161 password = "${ env . MEAWALLET_ANDROID_PASS } "
161162 }
162163 }` ;
163- let contents = readFileSync ( buildGradle , "utf8" ) ;
164+ const contents = readFileSync ( buildGradle , "utf8" ) ;
164165 if ( ! contents . includes ( "nexus.ext.meawallet.com" ) ) {
165- contents = contents . replace ( / ( a l l p r o j e c t s [ \s \S ] * ?r e p o s i t o r i e s \s * \{ ) / , `$1\n${ meaRepo } ` ) ;
166- writeFileSync ( buildGradle , contents ) ;
166+ const replaced = contents . replace ( / ( a l l p r o j e c t s [ \s \S ] * ?r e p o s i t o r i e s \s * \{ ) / , `$1\n${ meaRepo } ` ) ; // cspell:ignore allprojects
167+ if ( replaced === contents )
168+ throw new Error ( "meawallet: failed to inject maven repo into android/build.gradle" ) ;
169+ writeFileSync ( buildGradle , replaced ) ;
170+ }
171+ return c ;
172+ } ,
173+ ] ) ) satisfies ConfigPlugin ,
174+ // @ts -expect-error inline plugin
175+ ( ( config ) =>
176+ withDangerousMod ( config , [
177+ "ios" ,
178+ ( c ) => {
179+ const podfile = path . join ( c . modRequest . projectRoot , "ios/Podfile" ) ; // cspell:ignore podfile Podfile OBJC RCTJS RCTUI modulemap fmodule
180+ if ( ! existsSync ( podfile ) ) return c ;
181+ const workaround = ` rctHeaders = "#{installer.sandbox.root}/Headers/Public/React-RCTAppDelegate"
182+ Dir.mkdir(rctHeaders) unless Dir.exist?(rctHeaders)
183+ File.write("#{rctHeaders}/React-RCTAppDelegate-umbrella.h", <<~'H')
184+ #ifdef __OBJC__
185+ #import <UIKit/UIKit.h>
186+ #endif
187+ #import "RCTAppDelegate.h"
188+ #import "RCTAppSetupUtils.h"
189+ #import "RCTArchConfiguratorProtocol.h"
190+ #import "RCTDefaultReactNativeFactoryDelegate.h"
191+ #import "RCTDependencyProvider.h"
192+ #import "RCTJSRuntimeConfiguratorProtocol.h"
193+ #import "RCTReactNativeFactory.h"
194+ #import "RCTRootViewFactory.h"
195+ #import "RCTUIConfiguratorProtocol.h"
196+ H
197+ File.write("#{rctHeaders}/React_RCTAppDelegate.modulemap", <<~MAP)
198+ module React_RCTAppDelegate {
199+ umbrella header "React-RCTAppDelegate-umbrella.h"
200+ export *
201+ module * { export * }
202+ }
203+ MAP
204+ installer.pods_project.targets.each do |target|
205+ next unless target.name == "meawallet-react-native-mpp"
206+ target.build_configurations.each do |buildConfiguration|
207+ flags = buildConfiguration.build_settings["OTHER_SWIFT_FLAGS"] || "$(inherited)"
208+ next if flags.include?("React_RCTAppDelegate.modulemap")
209+ buildConfiguration.build_settings["OTHER_SWIFT_FLAGS"] =
210+ "#{flags} -Xcc -fmodule-map-file=\${PODS_ROOT}/Headers/Public/React-RCTAppDelegate/React_RCTAppDelegate.modulemap"
211+ end
212+ end
213+ ` ;
214+ const contents = readFileSync ( podfile , "utf8" ) ;
215+ if ( ! contents . includes ( "React_RCTAppDelegate.modulemap" ) ) {
216+ const replaced = contents . replace (
217+ / ( \s { 4 } r e a c t _ n a t i v e _ p o s t _ i n s t a l l \( [ \s \S ] * ?\n \s { 4 } \) \n ) / ,
218+ `$1${ workaround } ` ,
219+ ) ;
220+ if ( replaced === contents )
221+ throw new Error ( "meawallet: failed to inject react_native_post_install workaround into ios/Podfile" ) ;
222+ writeFileSync ( podfile , replaced ) ;
167223 }
168224 return c ;
169225 } ,
0 commit comments