Skip to content

Commit bdbdbf4

Browse files
author
retweakr
committed
fix(ios): Adjust OnsideKit and ExpoIap/Onside handling in Podfile logic and podspec
1 parent b1f7ccc commit bdbdbf4

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

ios/ExpoIap.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ Pod::Spec.new do |s|
3737
}
3838

3939
s.source_files = "**/*.{h,m,swift}"
40+
s.default_subspecs = []
4041
end

plugin/src/withIAP.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,20 @@ const ONSIDEKIT_PODSPEC_URL =
268268

269269
const EXPO_IAP_IOS_PATH = '../node_modules/expo-iap/ios';
270270

271-
const ensureOnsidePod = (content: string): string => {
272-
const alreadyHasOnside =
273-
/^\s*pod\s+['"]ExpoIap\/Onside['"].*$/m.test(content) ||
274-
/^\s*pod\s+['"]OnsideKit['"]\b.*$/m.test(content);
275-
if (alreadyHasOnside) {
271+
const ensureOnsidePod = (content: string, onside: boolean): string => {
272+
const alreadyHasOnsideKit = /^\s*pod\s+['"]OnsideKit['"]\b.*$/m.test(content);
273+
const alreadyHasExpoIapOnside =
274+
/^\s*pod\s+['"]ExpoIap\/Onside['"].*$/m.test(content);
275+
276+
let podLines = '';
277+
if (!alreadyHasOnsideKit) {
278+
podLines += ` pod 'OnsideKit', :podspec => '${ONSIDEKIT_PODSPEC_URL}'\n`;
279+
}
280+
if (onside && !alreadyHasExpoIapOnside) {
281+
podLines += ` pod 'ExpoIap/Onside', :path => '${EXPO_IAP_IOS_PATH}'`;
282+
}
283+
284+
if (!podLines) {
276285
return content;
277286
}
278287

@@ -289,13 +298,13 @@ const ensureOnsidePod = (content: string): string => {
289298
const before = content.slice(0, insertIndex);
290299
const after = content.slice(insertIndex);
291300

292-
const podLines =
293-
` pod 'OnsideKit', :podspec => '${ONSIDEKIT_PODSPEC_URL}'\n` +
294-
` pod 'ExpoIap/Onside', :path => '${EXPO_IAP_IOS_PATH}'`;
295-
296-
logOnce(
297-
'📦 expo-iap: Added ExpoIap/Onside subspec (and OnsideKit for resolution) to Podfile',
298-
);
301+
if (onside && !alreadyHasExpoIapOnside) {
302+
logOnce(
303+
'📦 expo-iap: Added ExpoIap/Onside subspec (and OnsideKit for resolution) to Podfile',
304+
);
305+
} else if (!alreadyHasOnsideKit) {
306+
logOnce('📦 expo-iap: Added OnsideKit to Podfile');
307+
}
299308

300309
return `${before}${podLines}\n${after}`;
301310
};
@@ -501,10 +510,8 @@ const withIapIOS: ConfigPlugin<WithIapIosOptions | undefined> = (
501510
logOnce('🧹 expo-iap: Removed local OpenIAP pod from Podfile');
502511
}
503512

504-
// 3) Optionally install OnsideKit when enabled in config
505-
if (options?.enableOnside) {
506-
content = ensureOnsidePod(content);
507-
}
513+
// 3) Always add OnsideKit; add ExpoIap/Onside only when onside is enabled
514+
content = ensureOnsidePod(content, options?.enableOnside ?? false);
508515

509516
config.modResults.contents = content;
510517
return config;

0 commit comments

Comments
 (0)