Starter Packs (#4332)
Co-authored-by: Dan Abramov <dan.abramov@gmail.com> Co-authored-by: Paul Frazee <pfrazee@gmail.com> Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
parent
35f64535cb
commit
f089f45781
115 changed files with 6336 additions and 237 deletions
16
plugins/starterPackAppClipExtension/withAppEntitlements.js
Normal file
16
plugins/starterPackAppClipExtension/withAppEntitlements.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
const {withEntitlementsPlist} = require('@expo/config-plugins')
|
||||
|
||||
const withAppEntitlements = config => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
return withEntitlementsPlist(config, async config => {
|
||||
config.modResults['com.apple.security.application-groups'] = [
|
||||
`group.app.bsky`,
|
||||
]
|
||||
config.modResults[
|
||||
'com.apple.developer.associated-appclip-app-identifiers'
|
||||
] = [`$(AppIdentifierPrefix)${config.ios.bundleIdentifier}.AppClip`]
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {withAppEntitlements}
|
32
plugins/starterPackAppClipExtension/withClipEntitlements.js
Normal file
32
plugins/starterPackAppClipExtension/withClipEntitlements.js
Normal file
|
@ -0,0 +1,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}
|
38
plugins/starterPackAppClipExtension/withClipInfoPlist.js
Normal file
38
plugins/starterPackAppClipExtension/withClipInfoPlist.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const {withInfoPlist} = require('@expo/config-plugins')
|
||||
const plist = require('@expo/plist')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const withClipInfoPlist = (config, {targetName}) => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
return withInfoPlist(config, config => {
|
||||
const targetPath = path.join(
|
||||
config.modRequest.platformProjectRoot,
|
||||
targetName,
|
||||
'Info.plist',
|
||||
)
|
||||
|
||||
const newPlist = plist.default.build({
|
||||
NSAppClip: {
|
||||
NSAppClipRequestEphemeralUserNotification: false,
|
||||
NSAppClipRequestLocationConfirmation: false,
|
||||
},
|
||||
UILaunchScreen: {},
|
||||
CFBundleName: '$(PRODUCT_NAME)',
|
||||
CFBundleIdentifier: '$(PRODUCT_BUNDLE_IDENTIFIER)',
|
||||
CFBundleVersion: '$(CURRENT_PROJECT_VERSION)',
|
||||
CFBundleExecutable: '$(EXECUTABLE_NAME)',
|
||||
CFBundlePackageType: '$(PRODUCT_BUNDLE_PACKAGE_TYPE)',
|
||||
CFBundleShortVersionString: config.version,
|
||||
CFBundleIconName: 'AppIcon',
|
||||
UIViewControllerBasedStatusBarAppearance: 'NO',
|
||||
})
|
||||
|
||||
fs.mkdirSync(path.dirname(targetPath), {recursive: true})
|
||||
fs.writeFileSync(targetPath, newPlist)
|
||||
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {withClipInfoPlist}
|
40
plugins/starterPackAppClipExtension/withFiles.js
Normal file
40
plugins/starterPackAppClipExtension/withFiles.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
const {withXcodeProject} = require('@expo/config-plugins')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const FILES = ['AppDelegate.swift', 'ViewController.swift']
|
||||
|
||||
const withFiles = (config, {targetName}) => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
return withXcodeProject(config, config => {
|
||||
const basePath = path.join(
|
||||
config.modRequest.projectRoot,
|
||||
'modules',
|
||||
targetName,
|
||||
)
|
||||
|
||||
for (const file of FILES) {
|
||||
const sourcePath = path.join(basePath, file)
|
||||
const targetPath = path.join(
|
||||
config.modRequest.platformProjectRoot,
|
||||
targetName,
|
||||
file,
|
||||
)
|
||||
|
||||
fs.mkdirSync(path.dirname(targetPath), {recursive: true})
|
||||
fs.copyFileSync(sourcePath, targetPath)
|
||||
}
|
||||
|
||||
const imagesBasePath = path.join(basePath, 'Images.xcassets')
|
||||
const imagesTargetPath = path.join(
|
||||
config.modRequest.platformProjectRoot,
|
||||
targetName,
|
||||
'Images.xcassets',
|
||||
)
|
||||
fs.cpSync(imagesBasePath, imagesTargetPath, {recursive: true})
|
||||
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {withFiles}
|
|
@ -0,0 +1,40 @@
|
|||
const {withPlugins} = require('@expo/config-plugins')
|
||||
const {withAppEntitlements} = require('./withAppEntitlements')
|
||||
const {withClipEntitlements} = require('./withClipEntitlements')
|
||||
const {withClipInfoPlist} = require('./withClipInfoPlist')
|
||||
const {withFiles} = require('./withFiles')
|
||||
const {withXcodeTarget} = require('./withXcodeTarget')
|
||||
|
||||
const APP_CLIP_TARGET_NAME = 'BlueskyClip'
|
||||
|
||||
const withStarterPackAppClip = config => {
|
||||
return withPlugins(config, [
|
||||
withAppEntitlements,
|
||||
[
|
||||
withClipEntitlements,
|
||||
{
|
||||
targetName: APP_CLIP_TARGET_NAME,
|
||||
},
|
||||
],
|
||||
[
|
||||
withClipInfoPlist,
|
||||
{
|
||||
targetName: APP_CLIP_TARGET_NAME,
|
||||
},
|
||||
],
|
||||
[
|
||||
withFiles,
|
||||
{
|
||||
targetName: APP_CLIP_TARGET_NAME,
|
||||
},
|
||||
],
|
||||
[
|
||||
withXcodeTarget,
|
||||
{
|
||||
targetName: APP_CLIP_TARGET_NAME,
|
||||
},
|
||||
],
|
||||
])
|
||||
}
|
||||
|
||||
module.exports = withStarterPackAppClip
|
91
plugins/starterPackAppClipExtension/withXcodeTarget.js
Normal file
91
plugins/starterPackAppClipExtension/withXcodeTarget.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
const {withXcodeProject} = require('@expo/config-plugins')
|
||||
|
||||
const BUILD_PHASE_FILES = ['AppDelegate.swift', 'ViewController.swift']
|
||||
|
||||
const withXcodeTarget = (config, {targetName}) => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
return withXcodeProject(config, config => {
|
||||
const pbxProject = config.modResults
|
||||
|
||||
const target = pbxProject.addTarget(targetName, 'application', targetName)
|
||||
target.pbxNativeTarget.productType = `"com.apple.product-type.application.on-demand-install-capable"`
|
||||
pbxProject.addBuildPhase(
|
||||
BUILD_PHASE_FILES.map(f => `${targetName}/${f}`),
|
||||
'PBXSourcesBuildPhase',
|
||||
'Sources',
|
||||
target.uuid,
|
||||
'application',
|
||||
'"AppClips"',
|
||||
)
|
||||
pbxProject.addBuildPhase(
|
||||
[`${targetName}/Images.xcassets`],
|
||||
'PBXResourcesBuildPhase',
|
||||
'Resources',
|
||||
target.uuid,
|
||||
'application',
|
||||
'"AppClips"',
|
||||
)
|
||||
|
||||
const pbxGroup = pbxProject.addPbxGroup([
|
||||
'AppDelegate.swift',
|
||||
'ViewController.swift',
|
||||
'Images.xcassets',
|
||||
`${targetName}.entitlements`,
|
||||
'Info.plist',
|
||||
])
|
||||
|
||||
pbxProject.addFile(`${targetName}/Info.plist`, pbxGroup.uuid)
|
||||
const configurations = pbxProject.pbxXCBuildConfigurationSection()
|
||||
for (const key in configurations) {
|
||||
if (typeof configurations[key].buildSettings !== 'undefined') {
|
||||
const buildSettingsObj = configurations[key].buildSettings
|
||||
if (
|
||||
typeof buildSettingsObj.PRODUCT_NAME !== 'undefined' &&
|
||||
buildSettingsObj.PRODUCT_NAME === `"${targetName}"`
|
||||
) {
|
||||
buildSettingsObj.CLANG_ENABLE_MODULES = 'YES'
|
||||
buildSettingsObj.INFOPLIST_FILE = `"${targetName}/Info.plist"`
|
||||
buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `"${targetName}/${targetName}.entitlements"`
|
||||
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic'
|
||||
buildSettingsObj.CURRENT_PROJECT_VERSION = `"${
|
||||
process.env.BSKY_IOS_BUILD_NUMBER ?? '1'
|
||||
}"`
|
||||
buildSettingsObj.GENERATE_INFOPLIST_FILE = 'YES'
|
||||
buildSettingsObj.MARKETING_VERSION = `"${config.version}"`
|
||||
buildSettingsObj.PRODUCT_BUNDLE_IDENTIFIER = `"${config.ios?.bundleIdentifier}.AppClip"`
|
||||
buildSettingsObj.SWIFT_EMIT_LOC_STRINGS = 'YES'
|
||||
buildSettingsObj.SWIFT_VERSION = '5.0'
|
||||
buildSettingsObj.TARGETED_DEVICE_FAMILY = `"1"`
|
||||
buildSettingsObj.DEVELOPMENT_TEAM = 'B3LX46C5HS'
|
||||
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = '14.0'
|
||||
buildSettingsObj.ASSETCATALOG_COMPILER_APPICON_NAME = 'AppIcon'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pbxProject.addTargetAttribute('DevelopmentTeam', 'B3LX46C5HS', targetName)
|
||||
|
||||
if (!pbxProject.hash.project.objects.PBXTargetDependency) {
|
||||
pbxProject.hash.project.objects.PBXTargetDependency = {}
|
||||
}
|
||||
if (!pbxProject.hash.project.objects.PBXContainerItemProxy) {
|
||||
pbxProject.hash.project.objects.PBXContainerItemProxy = {}
|
||||
}
|
||||
pbxProject.addTargetDependency(pbxProject.getFirstTarget().uuid, [
|
||||
target.uuid,
|
||||
])
|
||||
|
||||
pbxProject.addBuildPhase(
|
||||
[`${targetName}.app`],
|
||||
'PBXCopyFilesBuildPhase',
|
||||
'Embed App Clips',
|
||||
pbxProject.getFirstTarget().uuid,
|
||||
'application',
|
||||
'"AppClips"',
|
||||
)
|
||||
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {withXcodeTarget}
|
Loading…
Add table
Add a link
Reference in a new issue