Skip to content

Commit c317097

Browse files
committed
💩 app: patch meawallet podspec
1 parent b42b0c5 commit c317097

3 files changed

Lines changed: 75 additions & 8 deletions

File tree

‎app.config.ts‎

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/(allprojects[\s\S]*?repositories\s*\{)/, `$1\n${meaRepo}`);
166-
writeFileSync(buildGradle, contents);
166+
const replaced = contents.replace(/(allprojects[\s\S]*?repositories\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}react_native_post_install\([\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
},

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
},
207207
"patchedDependencies": {
208208
"@lifi/sdk": "patches/@lifi__sdk.patch",
209+
"@meawallet/react-native-mpp": "patches/@meawallet__react-native-mpp.patch",
209210
"embedded-postgres": "patches/embedded-postgres.patch",
210211
"eslint-config-universe": "patches/eslint-config-universe.patch"
211212
},
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff --git a/meawallet-react-native-mpp.podspec b/meawallet-react-native-mpp.podspec
2+
index 05795f1b..7396ff2b 100644
3+
--- a/meawallet-react-native-mpp.podspec
4+
+++ b/meawallet-react-native-mpp.podspec
5+
@@ -21,4 +21,5 @@ Pod::Spec.new do |s|
6+
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "REACT_NATIVE_MPP_VERSION=\"@\\\"#{s.version}\\\"\"" }
7+
8+
install_modules_dependencies(s)
9+
+ s.dependency "React-RCTAppDelegate"
10+
end

0 commit comments

Comments
 (0)