@@ -44,12 +44,18 @@ function withIosPodfile(configuration) {
4444function withIosAssociatedDomain ( configuration ) {
4545 const associatedDomain = process . env . ASSOCIATED_DOMAIN ;
4646 if ( ! associatedDomain ) {
47- throw new Error ( 'ASSOCIATED_DOMAIN environment variable is not set' ) ;
47+ return configuration ;
4848 }
4949 return withEntitlementsPlist ( configuration , ( config ) => {
50- config . modResults [ 'com.apple.developer.associated-domains' ] = [
51- `webcredentials:${ associatedDomain } ` ,
52- ] ;
50+ const key = 'com.apple.developer.associated-domains' ;
51+ const webCredEntitlement = `webcredentials:${ associatedDomain } ` ;
52+ // Get existing associated domains if they exist
53+ let domains = config . modResults [ key ] || [ ] ;
54+ // Add the new domain only if it's not already present
55+ if ( ! domains . includes ( webCredEntitlement ) ) {
56+ domains . push ( webCredEntitlement ) ;
57+ }
58+ config . modResults [ key ] = domains ;
5359 return config ;
5460 } ) ;
5561}
@@ -88,7 +94,7 @@ function withAndroidGradleDependency(configuration) {
8894function withAndroidAssociatedDomain ( configuration ) {
8995 const associatedDomain = process . env . ASSOCIATED_DOMAIN ;
9096 if ( ! associatedDomain ) {
91- throw new Error ( 'ASSOCIATED_DOMAIN environment variable is not set' ) ;
97+ return configuration ;
9298 }
9399
94100 // Modify AndroidManifest.xml
@@ -124,7 +130,7 @@ function withAndroidAssociatedDomain(configuration) {
124130 }
125131 let stringsXmlContent = fs . readFileSync ( stringsXmlPath , 'utf-8' ) ;
126132 // Check if the string already exists
127- if ( ! stringsXmlContent . includes ( '<string name="passage_auth_origin ">' ) ) {
133+ if ( ! stringsXmlContent . includes ( '<string name="asset_statements ">' ) ) {
128134 const newStrings = `<string name="passage_auth_origin">${ associatedDomain } </string>
129135 <string name="asset_statements">[{"include": "https://@string/passage_auth_origin/.well-known/assetlinks.json"}]</string>` ;
130136 // Insert the new strings before the closing </resources> tag
0 commit comments