about summary refs log tree commit diff
path: root/plugins/starterPackAppClipExtension/withClipEntitlements.js
blob: 77636b5c94140d8c994189d114e5676a864af542 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {withInfoPlist} = require('@expo/config-plugins')
const plist = require('@expo/plist')
const path = require('path')
const fs = require('fs')

const withClipEntitlements = (config, {targetName}) => {
  // eslint-disable-next-line no-shadow
  return withInfoPlist(config, config => {
    const entitlementsPath = path.join(
      config.modRequest.platformProjectRoot,
      targetName,
      `${targetName}.entitlements`,
    )

    const appClipEntitlements = {
      'com.apple.security.application-groups': [`group.app.bsky`],
      'com.apple.developer.parent-application-identifiers': [
        `$(AppIdentifierPrefix)${config.ios.bundleIdentifier}`,
      ],
      'com.apple.developer.associated-domains': config.ios.associatedDomains,
    }

    fs.mkdirSync(path.dirname(entitlementsPath), {
      recursive: true,
    })
    fs.writeFileSync(entitlementsPath, plist.default.build(appClipEntitlements))

    return config
  })
}

module.exports = {withClipEntitlements}