@@ -268,11 +268,20 @@ const ONSIDEKIT_PODSPEC_URL =
268268
269269const EXPO_IAP_IOS_PATH = '../node_modules/expo-iap/ios' ;
270270
271- const ensureOnsidePod = ( content : string ) : string => {
272- const alreadyHasOnside =
273- / ^ \s * p o d \s + [ ' " ] E x p o I a p \/ O n s i d e [ ' " ] .* $ / m. test ( content ) ||
274- / ^ \s * p o d \s + [ ' " ] O n s i d e K i t [ ' " ] \b .* $ / m. test ( content ) ;
275- if ( alreadyHasOnside ) {
271+ const ensureOnsidePod = ( content : string , onside : boolean ) : string => {
272+ const alreadyHasOnsideKit = / ^ \s * p o d \s + [ ' " ] O n s i d e K i t [ ' " ] \b .* $ / m. test ( content ) ;
273+ const alreadyHasExpoIapOnside =
274+ / ^ \s * p o d \s + [ ' " ] E x p o I a p \/ O n s i d e [ ' " ] .* $ / 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