11import { ConfigPlugin } from "@expo/config-plugins" ;
22
3+ import { addApplicationGroupsEntitlement , getWidgetExtensionEntitlements } from "./lib/getWidgetExtensionEntitlements" ;
4+
35export const withConfig : ConfigPlugin < {
46 bundleIdentifier : string ;
57 targetName : string ;
6- } > = ( config , { bundleIdentifier, targetName } ) => {
8+ groupIdentifier ?: string ;
9+ } > = ( config , { bundleIdentifier, targetName, groupIdentifier } ) => {
710 let configIndex : null | number = null ;
8- config . extra ?. eas ?. build ?. experimental ?. ios ?. appExtensions ?. forEach (
9- ( ext : any , index : number ) => {
10- if ( ext . targetName === targetName ) {
11- configIndex = index ;
12- }
11+ config . extra ?. eas ?. build ?. experimental ?. ios ?. appExtensions ?. forEach ( ( ext : any , index : number ) => {
12+ if ( ext . targetName === targetName ) {
13+ configIndex = index ;
1314 }
14- ) ;
15+ } ) ;
1516
1617 if ( ! configIndex ) {
1718 config . extra = {
@@ -25,8 +26,7 @@ export const withConfig: ConfigPlugin<{
2526 ios : {
2627 ...config . extra ?. eas ?. build ?. experimental ?. ios ,
2728 appExtensions : [
28- ...( config . extra ?. eas ?. build ?. experimental ?. ios
29- ?. appExtensions ?? [ ] ) ,
29+ ...( config . extra ?. eas ?. build ?. experimental ?. ios ?. appExtensions ?? [ ] ) ,
3030 {
3131 targetName,
3232 bundleIdentifier,
@@ -41,10 +41,21 @@ export const withConfig: ConfigPlugin<{
4141 }
4242
4343 if ( configIndex != null && config . extra ) {
44- const appClipConfig =
45- config . extra . eas . build . experimental . ios . appExtensions [ configIndex ] ;
44+ const widgetsExtensionConfig = config . extra . eas . build . experimental . ios . appExtensions [ configIndex ] ;
45+
46+ widgetsExtensionConfig . entitlements = {
47+ ...widgetsExtensionConfig . entitlements ,
48+ ...getWidgetExtensionEntitlements ( config . ios , {
49+ groupIdentifier,
50+ } ) ,
51+ } ;
4652
47- appClipConfig . entitlements = { } ;
53+ config . ios = {
54+ ...config . ios ,
55+ entitlements : {
56+ ...addApplicationGroupsEntitlement ( config . ios ?. entitlements ?? { } , groupIdentifier ) ,
57+ } ,
58+ } ;
4859 }
4960
5061 return config ;
0 commit comments