@@ -49,29 +49,32 @@ const modifyAppBuildGradle = (
4949) : string => {
5050 let modified = gradle ;
5151
52- // Add OpenIAP dependency to app-level build.gradle(.kts)
52+ // Ensure OpenIAP dependency exists at desired version in app-level build.gradle(.kts)
5353 const impl = ( ga : string , v : string ) =>
5454 language === 'kotlin'
5555 ? ` implementation("${ ga } :${ v } ")`
5656 : ` implementation "${ ga } :${ v } "` ;
5757 // Pin OpenIAP Google library to 1.1.0
5858 const openiapDep = impl ( 'io.github.hyochan.openiap:openiap-google' , '1.1.0' ) ;
5959
60- const hasGA = ( ga : string ) =>
61- new RegExp ( String . raw `\b(?:implementation|api)\s*\(?["']${ ga } :` , 'm' ) . test (
62- modified ,
63- ) ;
64-
65- let hasAddedDependency = false ;
66-
67- if ( ! hasGA ( 'io.github.hyochan.openiap:openiap-google' ) ) {
68- modified = addLineToGradle ( modified , / d e p e n d e n c i e s \s * { / , openiapDep , 0 ) ;
69- hasAddedDependency = true ;
60+ // Remove any existing openiap-google lines (any version, groovy/kotlin, implementation/api)
61+ const openiapAnyLine =
62+ / ^ \s * (?: i m p l e m e n t a t i o n | a p i ) \s * \( ? \s * [ " ' ] i o \. g i t h u b \. h y o c h a n \. o p e n i a p : o p e n i a p - g o o g l e : [ ^ " ' ] + [ " ' ] \s * \) ? \s * $ / gm;
63+ const hadExisting = openiapAnyLine . test ( modified ) ;
64+ if ( hadExisting ) {
65+ modified = modified . replace ( openiapAnyLine , '' ) . replace ( / \n { 3 , } / g, '\n\n' ) ;
7066 }
7167
72- // Log only once and only if we actually added dependencies
73- if ( hasAddedDependency )
74- logOnce ( '🛠️ expo-iap: Added OpenIAP dependency to build.gradle' ) ;
68+ // Ensure the desired dependency line is present
69+ if ( ! new RegExp ( String . raw `io\.github\.hyochan\.openiap:openiap-google:1\.1\.0` ) . test ( modified ) ) {
70+ // Insert just after the opening `dependencies {` line
71+ modified = addLineToGradle ( modified , / d e p e n d e n c i e s \s * { / , openiapDep , 1 ) ;
72+ logOnce (
73+ hadExisting
74+ ? '🛠️ expo-iap: Replaced OpenIAP dependency with 1.1.0'
75+ : '🛠️ expo-iap: Added OpenIAP dependency (1.1.0) to build.gradle' ,
76+ ) ;
77+ }
7578
7679 return modified ;
7780} ;
@@ -173,12 +176,13 @@ const withIap: ConfigPlugin<ExpoIapPluginOptions | void> = (
173176 options ,
174177) => {
175178 try {
176- const isLocalDev = ! ! ( options ?. enableLocalDev || options ?. localPath ) ;
179+ // Respect explicit flag; fall back to presence of localPath only when flag is unset
180+ const isLocalDev = options ?. enableLocalDev ?? ! ! options ?. localPath ;
177181 // Apply Android modifications (skip adding deps when linking local module)
178182 let result = withIapAndroid ( config , { addDeps : ! isLocalDev } ) ;
179183
180184 // iOS: choose one path to avoid overlap
181- if ( options ?. enableLocalDev || options ?. localPath ) {
185+ if ( isLocalDev ) {
182186 if ( ! options ?. localPath ) {
183187 WarningAggregator . addWarningIOS (
184188 'expo-iap' ,
0 commit comments