@expo/config-plugins 4.0.18 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/build/android/BuildProperties.d.ts +28 -0
- package/build/android/BuildProperties.js +96 -0
- package/build/android/BuildProperties.js.map +1 -0
- package/build/android/EasBuild.js +8 -8
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/GoogleServices.js +16 -14
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/Manifest.js +7 -5
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Package.js +27 -15
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.js +6 -6
- package/build/android/Paths.js.map +1 -1
- package/build/android/Scheme.d.ts +5 -2
- package/build/android/Scheme.js +26 -15
- package/build/android/Scheme.js.map +1 -1
- package/build/android/index.d.ts +2 -2
- package/build/android/index.js +18 -18
- package/build/android/index.js.map +1 -1
- package/build/ios/BuildProperties.d.ts +27 -0
- package/build/ios/BuildProperties.js +83 -0
- package/build/ios/BuildProperties.js.map +1 -0
- package/build/ios/BuildScheme.js +6 -3
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +6 -6
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/Entitlements.d.ts +5 -1
- package/build/ios/Entitlements.js +63 -52
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +5 -5
- package/build/ios/Google.js +62 -12
- package/build/ios/Google.js.map +1 -1
- package/build/ios/Locales.js +14 -14
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +7 -7
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Paths.d.ts +4 -5
- package/build/ios/Paths.js +33 -25
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/ProvisioningProfile.js +4 -4
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/Swift.js +5 -5
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.d.ts +1 -0
- package/build/ios/Target.js +11 -1
- package/build/ios/Target.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -5
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/index.d.ts +2 -2
- package/build/ios/index.js +19 -19
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +2 -1
- package/build/ios/utils/Xcodeproj.js +4 -1
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +3 -3
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.js +0 -3
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withIosBaseMods.js +27 -7
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +25 -0
- package/build/utils/BuildProperties.types.js +2 -0
- package/build/utils/BuildProperties.types.js.map +1 -0
- package/build/utils/Updates.d.ts +1 -1
- package/build/utils/Updates.js +15 -7
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -0
- package/build/utils/XML.js +33 -11
- package/build/utils/XML.js.map +1 -1
- package/build/utils/fs.d.ts +4 -0
- package/build/utils/fs.js +56 -0
- package/build/utils/fs.js.map +1 -0
- package/build/utils/modules.js +1 -1
- package/build/utils/modules.js.map +1 -1
- package/build/utils/versions.js +2 -2
- package/build/utils/versions.js.map +1 -1
- package/package.json +3 -5
- package/build/android/JsEngine.d.ts +0 -8
- package/build/android/JsEngine.js +0 -59
- package/build/android/JsEngine.js.map +0 -1
- package/build/ios/JsEngine.d.ts +0 -8
- package/build/ios/JsEngine.js +0 -47
- package/build/ios/JsEngine.js.map +0 -1
package/build/ios/Maps.js
CHANGED
|
@@ -14,10 +14,10 @@ exports.removeMapsCocoaPods = removeMapsCocoaPods;
|
|
|
14
14
|
exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
|
|
15
15
|
exports.withMaps = void 0;
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
const data = _interopRequireDefault(require("fs
|
|
17
|
+
function _fs() {
|
|
18
|
+
const data = _interopRequireDefault(require("fs"));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
_fs = function () {
|
|
21
21
|
return data;
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -208,7 +208,7 @@ const withMapsCocoaPods = (config, {
|
|
|
208
208
|
return (0, _withDangerousMod().withDangerousMod)(config, ['ios', async config => {
|
|
209
209
|
const filePath = _path().default.join(config.modRequest.platformProjectRoot, 'Podfile');
|
|
210
210
|
|
|
211
|
-
const contents = await
|
|
211
|
+
const contents = await _fs().default.promises.readFile(filePath, 'utf-8');
|
|
212
212
|
let results; // Only add the block if react-native-maps is installed in the project (best effort).
|
|
213
213
|
// Generally prebuild runs after a yarn install so this should always work as expected.
|
|
214
214
|
|
|
@@ -233,7 +233,7 @@ const withMapsCocoaPods = (config, {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
if (results.didMerge || results.didClear) {
|
|
236
|
-
await
|
|
236
|
+
await _fs().default.promises.writeFile(filePath, results.contents);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
return config;
|
|
@@ -244,7 +244,7 @@ const withGoogleMapsAppDelegate = (config, {
|
|
|
244
244
|
apiKey
|
|
245
245
|
}) => {
|
|
246
246
|
return (0, _iosPlugins().withAppDelegate)(config, config => {
|
|
247
|
-
if (config.modResults.language
|
|
247
|
+
if (['objc', 'objcpp'].includes(config.modResults.language)) {
|
|
248
248
|
if (apiKey && isReactNativeMapsAutolinked(config) && isReactNativeMapsInstalled(config.modRequest.projectRoot)) {
|
|
249
249
|
try {
|
|
250
250
|
config.modResults.contents = addGoogleMapsAppDelegateImport(config.modResults.contents).contents;
|
|
@@ -261,7 +261,7 @@ const withGoogleMapsAppDelegate = (config, {
|
|
|
261
261
|
config.modResults.contents = removeGoogleMapsAppDelegateInit(config.modResults.contents).contents;
|
|
262
262
|
}
|
|
263
263
|
} else {
|
|
264
|
-
throw new Error(
|
|
264
|
+
throw new Error(`Cannot setup Google Maps because the project AppDelegate is not a supported language: ${config.modResults.language}`);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
return config;
|
package/build/ios/Maps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","filePath","modRequest","platformProjectRoot","contents","fs","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,8BAAjB,CAAd,C,CAEA;;;AACO,MAAMC,UAAU,GAAG,2MAAnB;;AAEP,MAAMC,iBAAiB,GAAG,yCAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAGC,MAAM,IAAI;AAC9CA,EAAAA,MAAM,GAAGH,iBAAiB,CAACG,M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,UAAP,CAAkBZ,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIQ,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAO3C,MAAP;AACD,GAnCM,CAAP;AAoCD,CArCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src The contents of the Podfile.\n * @returns Podfile with Google Maps added.\n */\nexport function addMapsCocoaPods(src: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: File.dirname(\\`node --print \"require.resolve('react-native-maps/package.json')\"\\`)`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n\n // TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.\n return true;\n\n // return (\n // !config._internal?.autolinkedModules ||\n // config._internal.autolinkedModules.includes('react-native-maps')\n // );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n try {\n results = addMapsCocoaPods(contents);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","filePath","modRequest","platformProjectRoot","contents","fs","promises","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","includes","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAA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mC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACL1C,QAAAA,MAAM,CAACiD,UAAP,CAAkBd,QAAlB,GAA6BhB,iCAAiC,CAC5DnB,MAAM,CAACiD,UAAP,CAAkBd,QAD0C,CAAjC,CAE3BA,QAFF;AAGAnC,QAAAA,MAAM,CAACiD,UAAP,CAAkBd,QAAlB,GAA6Bd,+BAA+B,CAC1DrB,MAAM,CAACiD,UAAP,CAAkBd,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIS,KAAJ,CACH,yFAAwF5C,MAAM,CAACiD,UAAP,CAAkBC,QAAS,EADhH,CAAN;AAGD;;AACD,WAAOlD,MAAP;AACD,GArCM,CAAP;AAsCD,CAvCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src The contents of the Podfile.\n * @returns Podfile with Google Maps added.\n */\nexport function addMapsCocoaPods(src: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: File.dirname(\\`node --print \"require.resolve('react-native-maps/package.json')\"\\`)`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n\n // TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.\n return true;\n\n // return (\n // !config._internal?.autolinkedModules ||\n // config._internal.autolinkedModules.includes('react-native-maps')\n // );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.promises.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n try {\n results = addMapsCocoaPods(contents);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.promises.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (['objc', 'objcpp'].includes(config.modResults.language)) {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error(\n `Cannot setup Google Maps because the project AppDelegate is not a supported language: ${config.modResults.language}`\n );\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
package/build/ios/Paths.d.ts
CHANGED
|
@@ -3,14 +3,15 @@ interface ProjectFile<L extends string = string> {
|
|
|
3
3
|
language: L;
|
|
4
4
|
contents: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
declare type AppleLanguage = 'objc' | 'objcpp' | 'swift';
|
|
7
|
+
export declare type AppDelegateProjectFile = ProjectFile<AppleLanguage>;
|
|
7
8
|
export declare function getAppDelegateHeaderFilePath(projectRoot: string): string;
|
|
8
9
|
export declare function getAppDelegateFilePath(projectRoot: string): string;
|
|
9
10
|
export declare function getAppDelegateObjcHeaderFilePath(projectRoot: string): string;
|
|
10
11
|
export declare function getFileInfo(filePath: string): {
|
|
11
12
|
path: string;
|
|
12
13
|
contents: string;
|
|
13
|
-
language:
|
|
14
|
+
language: AppleLanguage;
|
|
14
15
|
};
|
|
15
16
|
export declare function getAppDelegate(projectRoot: string): AppDelegateProjectFile;
|
|
16
17
|
export declare function getSourceRoot(projectRoot: string): string;
|
|
@@ -27,9 +28,7 @@ export declare function getAllInfoPlistPaths(projectRoot: string): string[];
|
|
|
27
28
|
export declare function getInfoPlistPath(projectRoot: string): string;
|
|
28
29
|
export declare function getAllEntitlementsPaths(projectRoot: string): string[];
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param projectRoot
|
|
31
|
+
* @deprecated: use Entitlements.getEntitlementsPath instead
|
|
33
32
|
*/
|
|
34
33
|
export declare function getEntitlementsPath(projectRoot: string): string | null;
|
|
35
34
|
export declare function getSupportingPath(projectRoot: string): string;
|
package/build/ios/Paths.js
CHANGED
|
@@ -22,10 +22,10 @@ exports.getSourceRoot = getSourceRoot;
|
|
|
22
22
|
exports.getSupportingPath = getSupportingPath;
|
|
23
23
|
exports.getXcodeProjectPath = getXcodeProjectPath;
|
|
24
24
|
|
|
25
|
-
function
|
|
26
|
-
const data = require("fs
|
|
25
|
+
function _fs() {
|
|
26
|
+
const data = require("fs");
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
_fs = function () {
|
|
29
29
|
return data;
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -72,6 +72,16 @@ function _warnings() {
|
|
|
72
72
|
return data;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
function Entitlements() {
|
|
76
|
+
const data = _interopRequireWildcard(require("./Entitlements"));
|
|
77
|
+
|
|
78
|
+
Entitlements = function () {
|
|
79
|
+
return data;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return data;
|
|
83
|
+
}
|
|
84
|
+
|
|
75
85
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
76
86
|
|
|
77
87
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -103,7 +113,7 @@ function getAppDelegateHeaderFilePath(projectRoot) {
|
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
function getAppDelegateFilePath(projectRoot) {
|
|
106
|
-
const [using, ...extra] = (0, _glob().sync)('ios/*/AppDelegate.@(m|swift)', {
|
|
116
|
+
const [using, ...extra] = (0, _glob().sync)('ios/*/AppDelegate.@(m|mm|swift)', {
|
|
107
117
|
absolute: true,
|
|
108
118
|
cwd: projectRoot,
|
|
109
119
|
ignore: ignoredPaths
|
|
@@ -154,6 +164,9 @@ function getLanguage(filePath) {
|
|
|
154
164
|
const extension = path().extname(filePath);
|
|
155
165
|
|
|
156
166
|
switch (extension) {
|
|
167
|
+
case '.mm':
|
|
168
|
+
return 'objcpp';
|
|
169
|
+
|
|
157
170
|
case '.m':
|
|
158
171
|
case '.h':
|
|
159
172
|
return 'objc';
|
|
@@ -169,7 +182,7 @@ function getLanguage(filePath) {
|
|
|
169
182
|
function getFileInfo(filePath) {
|
|
170
183
|
return {
|
|
171
184
|
path: path().normalize(filePath),
|
|
172
|
-
contents: (0,
|
|
185
|
+
contents: (0, _fs().readFileSync)(filePath, 'utf8'),
|
|
173
186
|
language: getLanguage(filePath)
|
|
174
187
|
};
|
|
175
188
|
}
|
|
@@ -199,11 +212,20 @@ function findSchemeNames(projectRoot) {
|
|
|
199
212
|
|
|
200
213
|
function getAllXcodeProjectPaths(projectRoot) {
|
|
201
214
|
const iosFolder = 'ios';
|
|
202
|
-
const pbxprojPaths = (0, _glob().sync)('
|
|
215
|
+
const pbxprojPaths = (0, _glob().sync)('ios/**/*.xcodeproj', {
|
|
203
216
|
cwd: projectRoot,
|
|
204
217
|
ignore: ignoredPaths
|
|
205
|
-
}).filter(project => !/test|example|sample/i.test(project) || path().dirname(project) === iosFolder)
|
|
206
|
-
.sort()
|
|
218
|
+
}).filter(project => !/test|example|sample/i.test(project) || path().dirname(project) === iosFolder) // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)
|
|
219
|
+
.sort().sort((a, b) => {
|
|
220
|
+
const isAInIos = path().dirname(a) === iosFolder;
|
|
221
|
+
const isBInIos = path().dirname(b) === iosFolder; // preserve previous sort order
|
|
222
|
+
|
|
223
|
+
if (isAInIos && isBInIos || !isAInIos && !isBInIos) {
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return isAInIos ? -1 : 1;
|
|
228
|
+
});
|
|
207
229
|
|
|
208
230
|
if (!pbxprojPaths.length) {
|
|
209
231
|
throw new (_errors().UnexpectedError)(`Failed to locate the ios/*.xcodeproj files relative to path "${projectRoot}".`);
|
|
@@ -234,7 +256,7 @@ function getXcodeProjectPath(projectRoot) {
|
|
|
234
256
|
|
|
235
257
|
function getAllPBXProjectPaths(projectRoot) {
|
|
236
258
|
const projectPaths = getAllXcodeProjectPaths(projectRoot);
|
|
237
|
-
const paths = projectPaths.map(value => path().join(value, 'project.pbxproj')).filter(value => (0,
|
|
259
|
+
const paths = projectPaths.map(value => path().join(value, 'project.pbxproj')).filter(value => (0, _fs().existsSync)(value));
|
|
238
260
|
|
|
239
261
|
if (!paths.length) {
|
|
240
262
|
throw new (_errors().UnexpectedError)(`Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path "${projectRoot}".`);
|
|
@@ -299,26 +321,12 @@ function getAllEntitlementsPaths(projectRoot) {
|
|
|
299
321
|
return paths;
|
|
300
322
|
}
|
|
301
323
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* @param projectRoot
|
|
324
|
+
* @deprecated: use Entitlements.getEntitlementsPath instead
|
|
305
325
|
*/
|
|
306
326
|
|
|
307
327
|
|
|
308
328
|
function getEntitlementsPath(projectRoot) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (extra.length) {
|
|
312
|
-
warnMultipleFiles({
|
|
313
|
-
tag: 'entitlements',
|
|
314
|
-
fileName: '*.entitlements',
|
|
315
|
-
projectRoot,
|
|
316
|
-
using,
|
|
317
|
-
extra
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return using !== null && using !== void 0 ? using : null;
|
|
329
|
+
return Entitlements().getEntitlementsPath(projectRoot);
|
|
322
330
|
}
|
|
323
331
|
|
|
324
332
|
function getSupportingPath(projectRoot) {
|
package/build/ios/Paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Paths.ts"],"names":["ignoredPaths","getAppDelegateHeaderFilePath","projectRoot","using","extra","absolute","cwd","ignore","UnexpectedError","length","warnMultipleFiles","tag","fileName","getAppDelegateFilePath","getAppDelegateObjcHeaderFilePath","getLanguage","filePath","extension","path","extname","getFileInfo","normalize","contents","language","getAppDelegate","getSourceRoot","appDelegate","dirname","findSchemePaths","findSchemeNames","schemePaths","map","schemePath","parse","name","getAllXcodeProjectPaths","iosFolder","pbxprojPaths","filter","project","test","sort","value","join","getXcodeProjectPath","getAllPBXProjectPaths","projectPaths","paths","getPBXProjectPath","getAllInfoPlistPaths","a","b","getInfoPlistPath","getAllEntitlementsPaths","getEntitlementsPath","getSupportingPath","resolve","basename","getExpoPlistPath","supportingPath","usingPath","relative","extraPaths","v","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,YAAY,GAAG,CAAC,4CAAD,CAArB;;AAUO,SAASC,4BAAT,CAAsCC,WAAtC,EAAmE;AACxE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,qBAAT,EAAgC;AACxDC,IAAAA,QAAQ,EAAE,IAD8C;AAExDC,IAAAA,GAAG,EAAEJ,WAFmD;AAGxDK,IAAAA,MAAM,EAAEP;AAHgD,GAAhC,CAA1B;;AAMA,MAAI,CAACG,KAAL,EAAY;AACV,UAAM,KAAIK,yBAAJ,EACH,yDAAwDN,WAAY,GADjE,CAAN;AAGD;;AAED,MAAIE,KAAK,CAACK,MAAV,EAAkB;AAChBC,IAAAA,iBAAiB,CAAC;AAChBC,MAAAA,GAAG,EAAE,qBADW;AAEhBC,MAAAA,QAAQ,EAAE,aAFM;AAGhBV,MAAAA,WAHgB;AAIhBC,MAAAA,KAJgB;AAKhBC,MAAAA;AALgB,KAAD,CAAjB;AAOD;;AAED,SAAOD,KAAP;AACD;;AAEM,SAASU,sBAAT,CAAgCX,WAAhC,EAA6D;AAClE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,8BAAT,EAAyC;AACjEC,IAAAA,QAAQ,EAAE,IADuD;AAEjEC,IAAAA,GAAG,EAAEJ,WAF4D;AAGjEK,IAAAA,MAAM,EAAEP;AAHyD,GAAzC,CAA1B;;AAMA,MAAI,CAACG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AAW,GAAGgB,IAAI,GAAC2C,QAAL,CAAc3D,WAAd,EAA2BC,KAA3B,CAAH,GAAuCA,KAApE;AACA,QAAM2D,UAAU,GAAG5D,WAAW,GAAGE,KAAK,CAAC2B,GAAN,CAAUgC,CAAC,IAAI7C,IAAI,GAAC2C,QAAL,CAAc3D,WAAd,EAA2B6D,CAA3B,CAAf,CAAH,GAAmD3D,KAAjF;AACA,iCACG,SAAQO,GAAI,EADf,EAEG,kBAAiBC,QAAS,uBAAsBgD,SAAU,qBAAoBI,IAAI,CAACC,SAAL,CAC7EH,UAD6E,CAE7E,EAJJ;AAMD","sourcesContent":["import { pathExistsSync, readFileSync } from 'fs-extra';\nimport { sync as globSync } from 'glob';\nimport * as path from 'path';\n\nimport { UnexpectedError } from '../utils/errors';\nimport { addWarningIOS } from '../utils/warnings';\n\nconst ignoredPaths = ['**/@(Carthage|Pods|vendor|node_modules)/**'];\n\ninterface ProjectFile<L extends string = string> {\n path: string;\n language: L;\n contents: string;\n}\n\nexport type AppDelegateProjectFile = ProjectFile<'objc' | 'swift'>;\n\nexport function getAppDelegateHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(\n `Could not locate a valid AppDelegate header at root: \"${projectRoot}\"`\n );\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-header',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.@(m|swift)', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateObjcHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate.h at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-objc-header',\n fileName: 'AppDelegate.h',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nfunction getLanguage(filePath: string): 'objc' | 'swift' {\n const extension = path.extname(filePath);\n switch (extension) {\n case '.m':\n case '.h':\n return 'objc';\n case '.swift':\n return 'swift';\n default:\n throw new UnexpectedError(`Unexpected iOS file extension: ${extension}`);\n }\n}\n\nexport function getFileInfo(filePath: string) {\n return {\n path: path.normalize(filePath),\n contents: readFileSync(filePath, 'utf8'),\n language: getLanguage(filePath),\n };\n}\n\nexport function getAppDelegate(projectRoot: string): AppDelegateProjectFile {\n const filePath = getAppDelegateFilePath(projectRoot);\n return getFileInfo(filePath);\n}\n\nexport function getSourceRoot(projectRoot: string): string {\n const appDelegate = getAppDelegate(projectRoot);\n return path.dirname(appDelegate.path);\n}\n\nexport function findSchemePaths(projectRoot: string): string[] {\n return globSync('ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n}\n\nexport function findSchemeNames(projectRoot: string): string[] {\n const schemePaths = findSchemePaths(projectRoot);\n return schemePaths.map(schemePath => path.parse(schemePath).name);\n}\n\nexport function getAllXcodeProjectPaths(projectRoot: string): string[] {\n const iosFolder = 'ios';\n const pbxprojPaths = globSync('**/*.xcodeproj', { cwd: projectRoot, ignore: ignoredPaths })\n .filter(project => !/test|example|sample/i.test(project) || path.dirname(project) === iosFolder)\n .sort(project => (path.dirname(project) === iosFolder ? -1 : 1))\n // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)\n .sort();\n\n if (!pbxprojPaths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj files relative to path \"${projectRoot}\".`\n );\n }\n return pbxprojPaths.map(value => path.join(projectRoot, value));\n}\n\n/**\n * Get the pbxproj for the given path\n */\nexport function getXcodeProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllXcodeProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'xcodeproj',\n fileName: '*.xcodeproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllPBXProjectPaths(projectRoot: string): string[] {\n const projectPaths = getAllXcodeProjectPaths(projectRoot);\n const paths = projectPaths\n .map(value => path.join(value, 'project.pbxproj'))\n .filter(value => pathExistsSync(value));\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getPBXProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllPBXProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'project-pbxproj',\n fileName: 'project.pbxproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllInfoPlistPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/Info.plist', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n }).sort(\n // longer name means more suffixes, we want the shortest possible one to be first.\n (a, b) => a.length - b.length\n );\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate Info.plist files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getInfoPlistPath(projectRoot: string): string {\n const [using, ...extra] = getAllInfoPlistPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'info-plist',\n fileName: 'Info.plist',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllEntitlementsPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/*.entitlements', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n return paths;\n}\n\n/**\n * Get the entitlements file path if it exists.\n *\n * @param projectRoot\n */\nexport function getEntitlementsPath(projectRoot: string): string | null {\n const [using, ...extra] = getAllEntitlementsPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'entitlements',\n fileName: '*.entitlements',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using ?? null;\n}\n\nexport function getSupportingPath(projectRoot: string): string {\n return path.resolve(projectRoot, 'ios', path.basename(getSourceRoot(projectRoot)), 'Supporting');\n}\n\nexport function getExpoPlistPath(projectRoot: string): string {\n const supportingPath = getSupportingPath(projectRoot);\n return path.join(supportingPath, 'Expo.plist');\n}\n\nfunction warnMultipleFiles({\n tag,\n fileName,\n projectRoot,\n using,\n extra,\n}: {\n tag: string;\n fileName: string;\n projectRoot?: string;\n using: string;\n extra: string[];\n}) {\n const usingPath = projectRoot ? path.relative(projectRoot, using) : using;\n const extraPaths = projectRoot ? extra.map(v => path.relative(projectRoot, v)) : extra;\n addWarningIOS(\n `paths-${tag}`,\n `Found multiple ${fileName} file paths, using \"${usingPath}\". Ignored paths: ${JSON.stringify(\n extraPaths\n )}`\n );\n}\n"],"file":"Paths.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Paths.ts"],"names":["ignoredPaths","getAppDelegateHeaderFilePath","projectRoot","using","extra","absolute","cwd","ignore","UnexpectedError","length","warnMultipleFiles","tag","fileName","getAppDelegateFilePath","getAppDelegateObjcHeaderFilePath","getLanguage","filePath","extension","path","extname","getFileInfo","normalize","contents","language","getAppDelegate","getSourceRoot","appDelegate","dirname","findSchemePaths","findSchemeNames","schemePaths","map","schemePath","parse","name","getAllXcodeProjectPaths","iosFolder","pbxprojPaths","filter","project","test","sort","a","b","isAInIos","isBInIos","value","join","getXcodeProjectPath","getAllPBXProjectPaths","projectPaths","paths","getPBXProjectPath","getAllInfoPlistPaths","getInfoPlistPath","getAllEntitlementsPaths","getEntitlementsPath","Entitlements","getSupportingPath","resolve","basename","getExpoPlistPath","supportingPath","usingPath","relative","extraPaths","v","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,YAAY,GAAG,CAAC,4CAAD,CAArB;;AAYO,SAASC,4BAAT,CAAsCC,WAAtC,EAAmE;AACxE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,qBAAT,EAAgC;AACxDC,IAAAA,QAAQ,EAAE,IAD8C;AAExDC,IAAAA,GAAG,EAAEJ,WAFmD;AAGxDK,IAAAA,MAAM,EAAEP;AAHgD,GAAhC,CAA1B;;AAMA,MAAI,CAACG,KAAL,EAAY;AACV,UAAM,KAAIK,yBAAJ,EACH,yDAAwDN,WAAY,GADjE,CAAN;AAGD;;AAED,MAAIE,KAAK,CAACK,MAAV,EAAkB;AAChBC,IAAAA,iBAAiB,CAAC;AAChBC,MAAAA,GAAG,EAAE,qBADW;AAEhBC,MAAAA,QAAQ,EAAE,aAFM;AAGhBV,MAAAA,WAHgB;AAIhBC,MAAAA,KAJgB;AAKhBC,MAAAA;AALgB,KAAD,CAAjB;AAOD;;AAED,SAAOD,KAAP;AACD;;AAEM,SAASU,sBAAT,CAAgCX,WAAhC,EAA6D;AAClE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,iCAAT,EAA4C;AACpEC,IAAAA,QAAQ,EAAE,IAD0D;AAEpEC,IAAAA,GAAG,EAAEJ,WAF+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C,EAAAA;AALyB,CAA3B,EAYG;AACD,QAAM2D,SAAS,GAAG7D,WAAW,GAAGgB,IAAI,GAAC8C,QAAL,CAAc9D,WAAd,EAA2BC,KAA3B,CAAH,GAAuCA,KAApE;AACA,QAAM8D,UAAU,GAAG/D,WAAW,GAAGE,KAAK,CAAC2B,GAAN,CAAUmC,CAAC,IAAIhD,IAAI,GAAC8C,QAAL,CAAc9D,WAAd,EAA2BgE,CAA3B,CAAf,CAAH,GAAmD9D,KAAjF;AACA,iCACG,SAAQO,GAAI,EADf,EAEG,kBAAiBC,QAAS,uBAAsBmD,SAAU,qBAAoBI,IAAI,CAACC,SAAL,CAC7EH,UAD6E,CAE7E,EAJJ;AAMD","sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { sync as globSync } from 'glob';\nimport * as path from 'path';\n\nimport { UnexpectedError } from '../utils/errors';\nimport { addWarningIOS } from '../utils/warnings';\nimport * as Entitlements from './Entitlements';\n\nconst ignoredPaths = ['**/@(Carthage|Pods|vendor|node_modules)/**'];\n\ninterface ProjectFile<L extends string = string> {\n path: string;\n language: L;\n contents: string;\n}\n\ntype AppleLanguage = 'objc' | 'objcpp' | 'swift';\n\nexport type AppDelegateProjectFile = ProjectFile<AppleLanguage>;\n\nexport function getAppDelegateHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(\n `Could not locate a valid AppDelegate header at root: \"${projectRoot}\"`\n );\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-header',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.@(m|mm|swift)', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateObjcHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate.h at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-objc-header',\n fileName: 'AppDelegate.h',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nfunction getLanguage(filePath: string): AppleLanguage {\n const extension = path.extname(filePath);\n switch (extension) {\n case '.mm':\n return 'objcpp';\n case '.m':\n case '.h':\n return 'objc';\n case '.swift':\n return 'swift';\n default:\n throw new UnexpectedError(`Unexpected iOS file extension: ${extension}`);\n }\n}\n\nexport function getFileInfo(filePath: string) {\n return {\n path: path.normalize(filePath),\n contents: readFileSync(filePath, 'utf8'),\n language: getLanguage(filePath),\n };\n}\n\nexport function getAppDelegate(projectRoot: string): AppDelegateProjectFile {\n const filePath = getAppDelegateFilePath(projectRoot);\n return getFileInfo(filePath);\n}\n\nexport function getSourceRoot(projectRoot: string): string {\n const appDelegate = getAppDelegate(projectRoot);\n return path.dirname(appDelegate.path);\n}\n\nexport function findSchemePaths(projectRoot: string): string[] {\n return globSync('ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n}\n\nexport function findSchemeNames(projectRoot: string): string[] {\n const schemePaths = findSchemePaths(projectRoot);\n return schemePaths.map(schemePath => path.parse(schemePath).name);\n}\n\nexport function getAllXcodeProjectPaths(projectRoot: string): string[] {\n const iosFolder = 'ios';\n const pbxprojPaths = globSync('ios/**/*.xcodeproj', { cwd: projectRoot, ignore: ignoredPaths })\n .filter(project => !/test|example|sample/i.test(project) || path.dirname(project) === iosFolder)\n // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)\n .sort()\n .sort((a, b) => {\n const isAInIos = path.dirname(a) === iosFolder;\n const isBInIos = path.dirname(b) === iosFolder;\n // preserve previous sort order\n if ((isAInIos && isBInIos) || (!isAInIos && !isBInIos)) {\n return 0;\n }\n return isAInIos ? -1 : 1;\n });\n\n if (!pbxprojPaths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj files relative to path \"${projectRoot}\".`\n );\n }\n return pbxprojPaths.map(value => path.join(projectRoot, value));\n}\n\n/**\n * Get the pbxproj for the given path\n */\nexport function getXcodeProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllXcodeProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'xcodeproj',\n fileName: '*.xcodeproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllPBXProjectPaths(projectRoot: string): string[] {\n const projectPaths = getAllXcodeProjectPaths(projectRoot);\n const paths = projectPaths\n .map(value => path.join(value, 'project.pbxproj'))\n .filter(value => existsSync(value));\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getPBXProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllPBXProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'project-pbxproj',\n fileName: 'project.pbxproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllInfoPlistPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/Info.plist', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n }).sort(\n // longer name means more suffixes, we want the shortest possible one to be first.\n (a, b) => a.length - b.length\n );\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate Info.plist files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getInfoPlistPath(projectRoot: string): string {\n const [using, ...extra] = getAllInfoPlistPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'info-plist',\n fileName: 'Info.plist',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllEntitlementsPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/*.entitlements', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n return paths;\n}\n\n/**\n * @deprecated: use Entitlements.getEntitlementsPath instead\n */\nexport function getEntitlementsPath(projectRoot: string): string | null {\n return Entitlements.getEntitlementsPath(projectRoot);\n}\n\nexport function getSupportingPath(projectRoot: string): string {\n return path.resolve(projectRoot, 'ios', path.basename(getSourceRoot(projectRoot)), 'Supporting');\n}\n\nexport function getExpoPlistPath(projectRoot: string): string {\n const supportingPath = getSupportingPath(projectRoot);\n return path.join(supportingPath, 'Expo.plist');\n}\n\nfunction warnMultipleFiles({\n tag,\n fileName,\n projectRoot,\n using,\n extra,\n}: {\n tag: string;\n fileName: string;\n projectRoot?: string;\n using: string;\n extra: string[];\n}) {\n const usingPath = projectRoot ? path.relative(projectRoot, using) : using;\n const extraPaths = projectRoot ? extra.map(v => path.relative(projectRoot, v)) : extra;\n addWarningIOS(\n `paths-${tag}`,\n `Found multiple ${fileName} file paths, using \"${usingPath}\". Ignored paths: ${JSON.stringify(\n extraPaths\n )}`\n );\n}\n"],"file":"Paths.js"}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.setProvisioningProfileForPbxproj = setProvisioningProfileForPbxproj;
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
const data = _interopRequireDefault(require("fs
|
|
8
|
+
function _fs() {
|
|
9
|
+
const data = _interopRequireDefault(require("fs"));
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
_fs = function () {
|
|
12
12
|
return data;
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -62,7 +62,7 @@ function setProvisioningProfileForPbxproj(projectRoot, {
|
|
|
62
62
|
item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
_fs().default.writeFileSync(project.filepath, project.writeSync());
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const ensureQuotes = value => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/ProvisioningProfile.ts"],"names":["setProvisioningProfileForPbxproj","projectRoot","targetName","profileName","appleTeamId","buildConfiguration","project","nativeTargetEntry","nativeTargetId","nativeTarget","quotedAppleTeamId","ensureQuotes","buildConfigurationList","filter","item","name","forEach","buildSettings","PROVISIONING_PROFILE_SPECIFIER","DEVELOPMENT_TEAM","CODE_SIGN_IDENTITY","CODE_SIGN_STYLE","Object","entries","isNotComment","attributes","TargetAttributes","DevelopmentTeam","ProvisioningStyle","fs","writeFileSync","filepath","writeSync","value","match"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAgBO,SAASA,gCAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,WAHF;AAIEC,EAAAA,kBAAkB,GAAG;AAJvB,CAFK,EAQC;AACN,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AAEA,QAAMM,iBAAiB,GAAGL,UAAU,GAChC,sCAAuBI,OAAvB,EAAgCJ,UAAhC,CADgC,GAEhC,qCAAsBI,OAAtB,CAFJ;AAGA,QAAM,CAACE,cAAD,EAAiBC,YAAjB,IAAiCF,iBAAvC;AAEA,QAAMG,iBAAiB,GAAGC,YAAY,CAACP,WAAD,CAAtC;AAEA,oDAAgCE,OAAhC,EAAyCG,YAAY,CAACG,sBAAtD,EACGC,MADH,CACU,CAAC,GAAGC,IAAH,CAAD,KAAyCA,IAAI,CAACC,IAAL,KAAcV,kBADjE,EAEGW,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAyC;AAChDA,IAAAA,IAAI,CAACG,aAAL,CAAmBC,8BAAnB,GAAqD,IAAGf,WAAY,GAApE;AACAW,IAAAA,IAAI,CAACG,aAAL,CAAmBE,gBAAnB,GAAsCT,iBAAtC;AACAI,IAAAA,IAAI,CAACG,aAAL,CAAmBG,kBAAnB,GAAwC,uBAAxC;AACAN,IAAAA,IAAI,CAACG,aAAL,CAAmBI,eAAnB,GAAqC,QAArC;AACD,GAPH;AASAC,EAAAA,MAAM,CAACC,OAAP,CAAe,oCAAkBjB,OAAlB,CAAf,EACGO,MADH,CACUW,yBADV,EAEGR,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAmC;AAC1C,QAAI,CAACA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,CAAL,EAAuD;AACrDM,MAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,IAAmD,EAAnD;AACD;;AACDM,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,EAAiDmB,eAAjD,GAAmEjB,iBAAnE;AACAI,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,EAAiDoB,iBAAjD,GAAqE,QAArE;AACD,GARH;;AAUAC,
|
|
1
|
+
{"version":3,"sources":["../../src/ios/ProvisioningProfile.ts"],"names":["setProvisioningProfileForPbxproj","projectRoot","targetName","profileName","appleTeamId","buildConfiguration","project","nativeTargetEntry","nativeTargetId","nativeTarget","quotedAppleTeamId","ensureQuotes","buildConfigurationList","filter","item","name","forEach","buildSettings","PROVISIONING_PROFILE_SPECIFIER","DEVELOPMENT_TEAM","CODE_SIGN_IDENTITY","CODE_SIGN_STYLE","Object","entries","isNotComment","attributes","TargetAttributes","DevelopmentTeam","ProvisioningStyle","fs","writeFileSync","filepath","writeSync","value","match"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAgBO,SAASA,gCAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,WAHF;AAIEC,EAAAA,kBAAkB,GAAG;AAJvB,CAFK,EAQC;AACN,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AAEA,QAAMM,iBAAiB,GAAGL,UAAU,GAChC,sCAAuBI,OAAvB,EAAgCJ,UAAhC,CADgC,GAEhC,qCAAsBI,OAAtB,CAFJ;AAGA,QAAM,CAACE,cAAD,EAAiBC,YAAjB,IAAiCF,iBAAvC;AAEA,QAAMG,iBAAiB,GAAGC,YAAY,CAACP,WAAD,CAAtC;AAEA,oDAAgCE,OAAhC,EAAyCG,YAAY,CAACG,sBAAtD,EACGC,MADH,CACU,CAAC,GAAGC,IAAH,CAAD,KAAyCA,IAAI,CAACC,IAAL,KAAcV,kBADjE,EAEGW,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAyC;AAChDA,IAAAA,IAAI,CAACG,aAAL,CAAmBC,8BAAnB,GAAqD,IAAGf,WAAY,GAApE;AACAW,IAAAA,IAAI,CAACG,aAAL,CAAmBE,gBAAnB,GAAsCT,iBAAtC;AACAI,IAAAA,IAAI,CAACG,aAAL,CAAmBG,kBAAnB,GAAwC,uBAAxC;AACAN,IAAAA,IAAI,CAACG,aAAL,CAAmBI,eAAnB,GAAqC,QAArC;AACD,GAPH;AASAC,EAAAA,MAAM,CAACC,OAAP,CAAe,oCAAkBjB,OAAlB,CAAf,EACGO,MADH,CACUW,yBADV,EAEGR,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAmC;AAC1C,QAAI,CAACA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,CAAL,EAAuD;AACrDM,MAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,IAAmD,EAAnD;AACD;;AACDM,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,EAAiDmB,eAAjD,GAAmEjB,iBAAnE;AACAI,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiClB,cAAjC,EAAiDoB,iBAAjD,GAAqE,QAArE;AACD,GARH;;AAUAC,gBAAGC,aAAH,CAAiBxB,OAAO,CAACyB,QAAzB,EAAmCzB,OAAO,CAAC0B,SAAR,EAAnC;AACD;;AAED,MAAMrB,YAAY,GAAIsB,KAAD,IAAmB;AACtC,MAAI,CAACA,KAAK,CAACC,KAAN,CAAY,OAAZ,CAAL,EAA2B;AACzB,WAAQ,IAAGD,KAAM,GAAjB;AACD;;AACD,SAAOA,KAAP;AACD,CALD","sourcesContent":["import fs from 'fs';\n\nimport { findFirstNativeTarget, findNativeTargetByName } from './Target';\nimport {\n ConfigurationSectionEntry,\n getBuildConfigurationsForListId,\n getPbxproj,\n getProjectSection,\n isNotComment,\n ProjectSectionEntry,\n} from './utils/Xcodeproj';\n\ntype ProvisioningProfileSettings = {\n targetName?: string;\n appleTeamId: string;\n profileName: string;\n buildConfiguration?: string;\n};\n\nexport function setProvisioningProfileForPbxproj(\n projectRoot: string,\n {\n targetName,\n profileName,\n appleTeamId,\n buildConfiguration = 'Release',\n }: ProvisioningProfileSettings\n): void {\n const project = getPbxproj(projectRoot);\n\n const nativeTargetEntry = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [nativeTargetId, nativeTarget] = nativeTargetEntry;\n\n const quotedAppleTeamId = ensureQuotes(appleTeamId);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList)\n .filter(([, item]: ConfigurationSectionEntry) => item.name === buildConfiguration)\n .forEach(([, item]: ConfigurationSectionEntry) => {\n item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `\"${profileName}\"`;\n item.buildSettings.DEVELOPMENT_TEAM = quotedAppleTeamId;\n item.buildSettings.CODE_SIGN_IDENTITY = '\"iPhone Distribution\"';\n item.buildSettings.CODE_SIGN_STYLE = 'Manual';\n });\n\n Object.entries(getProjectSection(project))\n .filter(isNotComment)\n .forEach(([, item]: ProjectSectionEntry) => {\n if (!item.attributes.TargetAttributes[nativeTargetId]) {\n item.attributes.TargetAttributes[nativeTargetId] = {};\n }\n item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = quotedAppleTeamId;\n item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';\n });\n\n fs.writeFileSync(project.filepath, project.writeSync());\n}\n\nconst ensureQuotes = (value: string) => {\n if (!value.match(/^['\"]/)) {\n return `\"${value}\"`;\n }\n return value;\n};\n"],"file":"ProvisioningProfile.js"}
|
package/build/ios/Swift.js
CHANGED
|
@@ -9,10 +9,10 @@ exports.getDesignatedSwiftBridgingHeaderFileReference = getDesignatedSwiftBridgi
|
|
|
9
9
|
exports.linkBridgingHeaderFile = linkBridgingHeaderFile;
|
|
10
10
|
exports.withSwiftBridgingHeader = exports.withNoopSwiftFile = void 0;
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
const data = _interopRequireDefault(require("fs
|
|
12
|
+
function _fs() {
|
|
13
|
+
const data = _interopRequireDefault(require("fs"));
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
_fs = function () {
|
|
16
16
|
return data;
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -196,9 +196,9 @@ function createBridgingHeaderFile({
|
|
|
196
196
|
}) {
|
|
197
197
|
const bridgingHeaderProjectPath = _path().default.join((0, _Paths().getSourceRoot)(projectRoot), bridgingHeader);
|
|
198
198
|
|
|
199
|
-
if (!
|
|
199
|
+
if (!_fs().default.existsSync(bridgingHeaderProjectPath)) {
|
|
200
200
|
// Create the file
|
|
201
|
-
|
|
201
|
+
_fs().default.writeFileSync(bridgingHeaderProjectPath, templateBridgingHeader, 'utf8');
|
|
202
202
|
} // This is non-standard, Xcode generates the bridging header in `/ios` which is kinda annoying.
|
|
203
203
|
// Instead, this'll generate the default header in the application code folder `/ios/myproject/`.
|
|
204
204
|
|
package/build/ios/Swift.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Swift.ts"],"names":["templateBridgingHeader","withSwiftBridgingHeader","config","modResults","ensureSwiftBridgingHeaderSetup","project","projectRoot","modRequest","shouldCreateSwiftBridgingHeader","projectName","bridgingHeader","createBridgingHeaderFileName","createBridgingHeaderFile","linkBridgingHeaderFile","path","join","isObjc","language","getDesignatedSwiftBridgingHeaderFileReference","configurations","pbxXCBuildConfigurationSection","buildSettings","Object","values","PRODUCT_NAME","SWIFT_OBJC_BRIDGING_HEADER","bridgingHeaderProjectPath","fs","existsSync","writeFileSync","filePath","hasFile","filepath","groupName","isBuildFile","verbose","withNoopSwiftFile","contents"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,sBAAsB,GAAI;AAChC;AACA;AACA,CAHA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,uBAAqC,GAAGC,MAAM,IAAI;AAC7D,SAAO,oCAAiBA,MAAjB,EAAyBA,MAAM,IAAI;AACxCA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,8BAA8B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Mc,cAAc,GAAGd,OAAO,CAACe,8BAAR,EAAvB,CADgB,CAEhB;;AACA,OAAK,MAAM;AAAEC,IAAAA;AAAF,GAAX,IAAgCC,MAAM,CAACC,MAAP,CAAcJ,cAAc,IAAI,EAAhC,CAAhC,EAAqE;AACnE;AACA;AACA,QAAI,QAAOE,aAAP,aAAOA,aAAP,uBAAOA,aAAa,CAAEG,YAAtB,MAAuC,WAA3C,EAAwD;AACtD,UACE,OAAOH,aAAa,CAACI,0BAArB,KAAoD,QAApD,IACAJ,aAAa,CAACI,0BAFhB,EAGE;AACA,eAAOJ,aAAa,CAACI,0BAArB;AACD;AACF;AACF;;AACD,SAAO,IAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASZ,sBAAT,CAAgC;AACrCR,EAAAA,OADqC;AAErCK,EAAAA;AAFqC,CAAhC,EAMU;AACf,QAAMS,cAAc,GAAGd,OAAO,CAACe,8BAAR,EAAvB,CADe,CAEf;;AACA,OAAK,MAAM;AAAEC,IAAAA;AAAF,GAAX,IAAgCC,MAAM,CAACC,MAAP,CAAcJ,cAAc,IAAI,EAAhC,CAAhC,EAAqE;AACnE;AACA;AACA,QAAI,QAAOE,aAAP,aAAOA,aAAP,uBAAOA,aAAa,CAAEG,YAAtB,MAAuC,WAA3C,EAAwD;AACtDH,MAAAA,aAAa,CAACI,0BAAd,GAA2Cf,cAA3C;AACD;AACF;;AAED,SAAOL,OAAP;AACD;;AAEM,SAASO,wBAAT,CAAkC;AACvCN,EAAAA,WADuC;AAEvCG,EAAAA,WAFuC;AAGvCJ,EAAAA,OAHuC;AAIvCK,EAAAA;AAJuC,CAAlC,EAUU;AACf,QAAMgB,yBAAyB,GAAGZ,gBAAKC,IAAL,CAAU,4BAAcT,WAAd,CAAV,EAAsCI,cAAtC,CAAlC;;AACA,MAAI,CAACiB,
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Swift.ts"],"names":["templateBridgingHeader","withSwiftBridgingHeader","config","modResults","ensureSwiftBridgingHeaderSetup","project","projectRoot","modRequest","shouldCreateSwiftBridgingHeader","projectName","bridgingHeader","createBridgingHeaderFileName","createBridgingHeaderFile","linkBridgingHeaderFile","path","join","isObjc","language","getDesignatedSwiftBridgingHeaderFileReference","configurations","pbxXCBuildConfigurationSection","buildSettings","Object","values","PRODUCT_NAME","SWIFT_OBJC_BRIDGING_HEADER","bridgingHeaderProjectPath","fs","existsSync","writeFileSync","filePath","hasFile","filepath","groupName","isBuildFile","verbose","withNoopSwiftFile","contents"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,sBAAsB,GAAI;AAChC;AACA;AACA,CAHA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,uBAAqC,GAAGC,MAAM,IAAI;AAC7D,SAAO,oCAAiBA,MAAjB,EAAyBA,MAAM,IAAI;AACxCA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,8BAA8B,CAAC;AACjDC,MAAAA,OAAO,EAAEH,MAAM,CAACC,UADiC;AAEjDG,MAAAA,WAAW,EAAEJ,MAAM,CAACK,UAAP,CAAkBD;AAFkB,KAAD,CAAlD;AAIA,WAAOJ,MAAP;AACD,GANM,CAAP;AAOD,CARM;;;;AAUA,SAASE,8BAAT,CAAwC;AAC7CE,EAAAA,WAD6C;AAE7CD,EAAAA;AAF6C,CAAxC,EAMJ;AACD;AACA,MAAIG,+BAA+B,CAAC;AAAEF,IAAAA,WAAF;AAAeD,IAAAA;AAAf,GAAD,CAAnC,EAA+D;AAC7D,UAAMI,WAAW,GAAG,iCAAeH,WAAf,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AAQD;;AACD,SAAO9B,OAAP;AACD;;AAEM,MAAM+B,iBAA+B,GAAGlC,MAAM,IAAI;AACvD,SAAO,6CAAoBA,MAApB,EAA4B;AACjC4B,IAAAA,QAAQ,EAAE,iBADuB;AAEjCO,IAAAA,QAAQ,EAAE,CACR,IADQ,EAER,eAFQ,EAGR,8FAHQ,EAIR,IAJQ,EAKR,EALQ,EAMRtB,IANQ,CAMH,IANG;AAFuB,GAA5B,CAAP;AAUD,CAXM","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { ConfigPlugin, XcodeProject } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { getAppDelegate, getSourceRoot } from './Paths';\nimport { withBuildSourceFile } from './XcodeProjectFile';\nimport { addResourceFileToGroup, getProjectName } from './utils/Xcodeproj';\n\nconst templateBridgingHeader = `//\n// Use this file to import your target's public headers that you would like to expose to Swift.\n//\n`;\n\n/**\n * Ensure a Swift bridging header is created for the project.\n * This helps fix problems related to using modules that are written in Swift (lottie, FBSDK).\n *\n * 1. Ensures the file exists given the project path.\n * 2. Writes the file and links to Xcode as a resource file.\n * 3. Sets the build configuration `SWIFT_OBJC_BRIDGING_HEADER = [PROJECT_NAME]-Bridging-Header.h`\n */\nexport const withSwiftBridgingHeader: ConfigPlugin = config => {\n return withXcodeProject(config, config => {\n config.modResults = ensureSwiftBridgingHeaderSetup({\n project: config.modResults,\n projectRoot: config.modRequest.projectRoot,\n });\n return config;\n });\n};\n\nexport function ensureSwiftBridgingHeaderSetup({\n projectRoot,\n project,\n}: {\n projectRoot: string;\n project: XcodeProject;\n}) {\n // Only create a bridging header if using objective-c\n if (shouldCreateSwiftBridgingHeader({ projectRoot, project })) {\n const projectName = getProjectName(projectRoot);\n const bridgingHeader = createBridgingHeaderFileName(projectName);\n // Ensure a bridging header is created in the Xcode project.\n project = createBridgingHeaderFile({\n project,\n projectName,\n projectRoot,\n bridgingHeader,\n });\n // Designate the newly created file as the Swift bridging header in the Xcode project.\n project = linkBridgingHeaderFile({\n project,\n bridgingHeader: path.join(projectName, bridgingHeader),\n });\n }\n return project;\n}\n\nfunction shouldCreateSwiftBridgingHeader({\n projectRoot,\n project,\n}: {\n projectRoot: string;\n project: XcodeProject;\n}): boolean {\n // Only create a bridging header if the project is using in Objective C (AppDelegate is written in Objc).\n const isObjc = getAppDelegate(projectRoot).language === 'objc';\n return isObjc && !getDesignatedSwiftBridgingHeaderFileReference({ project });\n}\n\n/**\n * @returns String matching the default name used when Xcode automatically creates a bridging header file.\n */\nfunction createBridgingHeaderFileName(projectName: string): string {\n return `${projectName}-Bridging-Header.h`;\n}\n\nexport function getDesignatedSwiftBridgingHeaderFileReference({\n project,\n}: {\n project: XcodeProject;\n}): string | null {\n const configurations = project.pbxXCBuildConfigurationSection();\n // @ts-ignore\n for (const { buildSettings } of Object.values(configurations || {})) {\n // Guessing that this is the best way to emulate Xcode.\n // Using `project.addToBuildSettings` modifies too many targets.\n if (typeof buildSettings?.PRODUCT_NAME !== 'undefined') {\n if (\n typeof buildSettings.SWIFT_OBJC_BRIDGING_HEADER === 'string' &&\n buildSettings.SWIFT_OBJC_BRIDGING_HEADER\n ) {\n return buildSettings.SWIFT_OBJC_BRIDGING_HEADER;\n }\n }\n }\n return null;\n}\n\n/**\n *\n * @param bridgingHeader The bridging header filename ex: `ExpoAPIs-Bridging-Header.h`\n * @returns\n */\nexport function linkBridgingHeaderFile({\n project,\n bridgingHeader,\n}: {\n project: XcodeProject;\n bridgingHeader: string;\n}): XcodeProject {\n const configurations = project.pbxXCBuildConfigurationSection();\n // @ts-ignore\n for (const { buildSettings } of Object.values(configurations || {})) {\n // Guessing that this is the best way to emulate Xcode.\n // Using `project.addToBuildSettings` modifies too many targets.\n if (typeof buildSettings?.PRODUCT_NAME !== 'undefined') {\n buildSettings.SWIFT_OBJC_BRIDGING_HEADER = bridgingHeader;\n }\n }\n\n return project;\n}\n\nexport function createBridgingHeaderFile({\n projectRoot,\n projectName,\n project,\n bridgingHeader,\n}: {\n project: XcodeProject;\n projectName: string;\n projectRoot: string;\n bridgingHeader: string;\n}): XcodeProject {\n const bridgingHeaderProjectPath = path.join(getSourceRoot(projectRoot), bridgingHeader);\n if (!fs.existsSync(bridgingHeaderProjectPath)) {\n // Create the file\n fs.writeFileSync(bridgingHeaderProjectPath, templateBridgingHeader, 'utf8');\n }\n\n // This is non-standard, Xcode generates the bridging header in `/ios` which is kinda annoying.\n // Instead, this'll generate the default header in the application code folder `/ios/myproject/`.\n const filePath = `${projectName}/${bridgingHeader}`;\n // Ensure the file is linked with Xcode resource files\n if (!project.hasFile(filePath)) {\n project = addResourceFileToGroup({\n filepath: filePath,\n groupName: projectName,\n project,\n // Not sure why, but this is how Xcode generates it.\n isBuildFile: false,\n verbose: false,\n });\n }\n return project;\n}\n\nexport const withNoopSwiftFile: ConfigPlugin = config => {\n return withBuildSourceFile(config, {\n filePath: 'noop-file.swift',\n contents: [\n '//',\n '// @generated',\n '// A blank Swift file must be created for native modules with Swift files to work correctly.',\n '//',\n '',\n ].join('\\n'),\n });\n};\n"],"file":"Swift.js"}
|
package/build/ios/Target.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare enum TargetType {
|
|
|
4
4
|
APPLICATION = "com.apple.product-type.application",
|
|
5
5
|
EXTENSION = "com.apple.product-type.app-extension",
|
|
6
6
|
WATCH = "com.apple.product-type.application.watchapp",
|
|
7
|
+
APP_CLIP = "com.apple.product-type.application.on-demand-install-capable",
|
|
7
8
|
STICKER_PACK_EXTENSION = "com.apple.product-type.app-extension.messages-sticker-pack",
|
|
8
9
|
OTHER = "other"
|
|
9
10
|
}
|
package/build/ios/Target.js
CHANGED
|
@@ -49,6 +49,7 @@ exports.TargetType = TargetType;
|
|
|
49
49
|
TargetType["APPLICATION"] = "com.apple.product-type.application";
|
|
50
50
|
TargetType["EXTENSION"] = "com.apple.product-type.app-extension";
|
|
51
51
|
TargetType["WATCH"] = "com.apple.product-type.application.watchapp";
|
|
52
|
+
TargetType["APP_CLIP"] = "com.apple.product-type.application.on-demand-install-capable";
|
|
52
53
|
TargetType["STICKER_PACK_EXTENSION"] = "com.apple.product-type.app-extension.messages-sticker-pack";
|
|
53
54
|
TargetType["OTHER"] = "other";
|
|
54
55
|
})(TargetType || (exports.TargetType = TargetType = {}));
|
|
@@ -109,7 +110,16 @@ function getNativeTargets(project) {
|
|
|
109
110
|
|
|
110
111
|
function findSignableTargets(project) {
|
|
111
112
|
const targets = getNativeTargets(project);
|
|
112
|
-
const
|
|
113
|
+
const signableTargetTypes = [TargetType.APPLICATION, TargetType.APP_CLIP, TargetType.EXTENSION, TargetType.WATCH, TargetType.STICKER_PACK_EXTENSION];
|
|
114
|
+
const applicationTargets = targets.filter(([, target]) => {
|
|
115
|
+
for (const targetType of signableTargetTypes) {
|
|
116
|
+
if (isTargetOfType(target, targetType)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return false;
|
|
122
|
+
});
|
|
113
123
|
|
|
114
124
|
if (applicationTargets.length === 0) {
|
|
115
125
|
throw new Error(`Could not find any signable targets in project.pbxproj`);
|
package/build/ios/Target.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Target.ts"],"names":["TargetType","getXCBuildConfigurationFromPbxproj","project","targetName","buildConfiguration","nativeTarget","findNativeTargetByName","findFirstNativeTarget","xcBuildConfiguration","configurationListId","buildConfigurationList","findApplicationTargetWithDependenciesAsync","projectRoot","scheme","applicationTargetName","applicationTarget","dependencies","getTargetDependencies","name","type","APPLICATION","parentTarget","length","undefined","map","value","target","targetId","getPBXGroupByKeyAndType","findNativeTargetById","isTargetOfType","EXTENSION","OTHER","targetType","productType","getNativeTargets","section","pbxNativeTargetSection","Object","entries","filter","isNotComment","findSignableTargets","targets","
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Target.ts"],"names":["TargetType","getXCBuildConfigurationFromPbxproj","project","targetName","buildConfiguration","nativeTarget","findNativeTargetByName","findFirstNativeTarget","xcBuildConfiguration","configurationListId","buildConfigurationList","findApplicationTargetWithDependenciesAsync","projectRoot","scheme","applicationTargetName","applicationTarget","dependencies","getTargetDependencies","name","type","APPLICATION","parentTarget","length","undefined","map","value","target","targetId","getPBXGroupByKeyAndType","findNativeTargetById","isTargetOfType","EXTENSION","OTHER","targetType","productType","getNativeTargets","section","pbxNativeTargetSection","Object","entries","filter","isNotComment","findSignableTargets","targets","signableTargetTypes","APP_CLIP","WATCH","STICKER_PACK_EXTENSION","applicationTargets","Error","nativeTargets","nativeTargetEntry","find","i","key"],"mappings":";;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;IAEYA,U;;;WAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,0BAAAA,U;;AAeL,SAASC,kCAAT,CACLC,OADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,kBAAkB,GAAG;AAFvB,IAG0D,EALrD,EAMwB;AAC7B,QAAM,GAAGC,YAAH,IAAmBF,UAAU,GAC/BG,sBAAsB,CAACJ,OAAD,EAAUC,UAAV,CADS,GAE/BI,qBAAqB,CAACL,OAAD,CAFzB;AAGA,QAAM,GAAGM,oBAAH,IAA2B,wDAAsCN,OAAtC,EAA+C;AAC9EO,IAAAA,mBAAmB,EAAEJ,YAAY,CAACK,sBAD4C;AAE9EN,IAAAA;AAF8E,GAA/C,CAAjC;AAIA,SAAOI,oBAAP,aAAOA,oBAAP,cAAOA,oBAAP,GAA+B,IAA/B;AACD;;AAEM,eAAeG,0CAAf,CACLC,WADK,EAELC,MAFK,EAGY;AACjB,QAAMC,qBAAqB,GAAG,MAAM,2DAAuCF,WAAvC,EAA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AJ,CAAW,0DAAX,CAAN;AACD;;AACD,SAAOD,kBAAkB,CAAC,CAAD,CAAzB;AACD;;AAEM,SAAS1C,sBAAT,CACLJ,OADK,EAELC,UAFK,EAGqB;AAC1B,QAAM+C,aAAa,GAAGf,gBAAgB,CAACjC,OAAD,CAAtC;AACA,QAAMiD,iBAAiB,GAAGD,aAAa,CAACE,IAAd,CAAmB,CAAC,GAAGC,CAAH,CAAD,KAAW,0BAAWA,CAAC,CAACnC,IAAb,MAAuBf,UAArD,CAA1B;;AACA,MAAI,CAACgD,iBAAL,EAAwB;AACtB,UAAM,IAAIF,KAAJ,CAAW,0BAAyB9C,UAAW,sBAA/C,CAAN;AACD;;AACD,SAAOgD,iBAAP;AACD;;AAED,SAAStB,oBAAT,CAA8B3B,OAA9B,EAAqDyB,QAArD,EAAiG;AAC/F,QAAMuB,aAAa,GAAGf,gBAAgB,CAACjC,OAAD,CAAtC;AACA,QAAMiD,iBAAiB,GAAGD,aAAa,CAACE,IAAd,CAAmB,CAAC,CAACE,GAAD,CAAD,KAAWA,GAAG,KAAK3B,QAAtC,CAA1B;;AACA,MAAI,CAACwB,iBAAL,EAAwB;AACtB,UAAM,IAAIF,KAAJ,CAAW,kCAAiCtB,QAAS,sBAArD,CAAN;AACD;;AACD,SAAOwB,iBAAP;AACD","sourcesContent":["import { PBXNativeTarget, PBXTargetDependency, XCBuildConfiguration, XcodeProject } from 'xcode';\n\nimport { getApplicationTargetNameForSchemeAsync } from './BuildScheme';\nimport {\n getBuildConfigurationForListIdAndName,\n getPbxproj,\n isNotComment,\n NativeTargetSectionEntry,\n} from './utils/Xcodeproj';\nimport { trimQuotes } from './utils/string';\n\nexport enum TargetType {\n APPLICATION = 'com.apple.product-type.application',\n EXTENSION = 'com.apple.product-type.app-extension',\n WATCH = 'com.apple.product-type.application.watchapp',\n APP_CLIP = 'com.apple.product-type.application.on-demand-install-capable',\n STICKER_PACK_EXTENSION = 'com.apple.product-type.app-extension.messages-sticker-pack',\n OTHER = 'other',\n}\n\nexport interface Target {\n name: string;\n type: TargetType;\n dependencies?: Target[];\n}\n\nexport function getXCBuildConfigurationFromPbxproj(\n project: XcodeProject,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): XCBuildConfiguration | null {\n const [, nativeTarget] = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [, xcBuildConfiguration] = getBuildConfigurationForListIdAndName(project, {\n configurationListId: nativeTarget.buildConfigurationList,\n buildConfiguration,\n });\n return xcBuildConfiguration ?? null;\n}\n\nexport async function findApplicationTargetWithDependenciesAsync(\n projectRoot: string,\n scheme: string\n): Promise<Target> {\n const applicationTargetName = await getApplicationTargetNameForSchemeAsync(projectRoot, scheme);\n const project = getPbxproj(projectRoot);\n const [, applicationTarget] = findNativeTargetByName(project, applicationTargetName);\n const dependencies = getTargetDependencies(project, applicationTarget);\n return {\n name: trimQuotes(applicationTarget.name),\n type: TargetType.APPLICATION,\n dependencies,\n };\n}\n\nfunction getTargetDependencies(\n project: XcodeProject,\n parentTarget: PBXNativeTarget\n): Target[] | undefined {\n if (!parentTarget.dependencies || parentTarget.dependencies.length === 0) {\n return undefined;\n }\n return parentTarget.dependencies.map(({ value }) => {\n const { target: targetId } = project.getPBXGroupByKeyAndType(\n value,\n 'PBXTargetDependency'\n ) as PBXTargetDependency;\n\n const [, target] = findNativeTargetById(project, targetId);\n\n const type = isTargetOfType(target, TargetType.EXTENSION)\n ? TargetType.EXTENSION\n : TargetType.OTHER;\n return {\n name: trimQuotes(target.name),\n type,\n dependencies: getTargetDependencies(project, target),\n };\n });\n}\n\nexport function isTargetOfType(target: PBXNativeTarget, targetType: TargetType): boolean {\n return trimQuotes(target.productType) === targetType;\n}\n\nexport function getNativeTargets(project: XcodeProject): NativeTargetSectionEntry[] {\n const section = project.pbxNativeTargetSection();\n return Object.entries(section).filter(isNotComment);\n}\n\nexport function findSignableTargets(project: XcodeProject): NativeTargetSectionEntry[] {\n const targets = getNativeTargets(project);\n\n const signableTargetTypes = [\n TargetType.APPLICATION,\n TargetType.APP_CLIP,\n TargetType.EXTENSION,\n TargetType.WATCH,\n TargetType.STICKER_PACK_EXTENSION,\n ];\n\n const applicationTargets = targets.filter(([, target]) => {\n for (const targetType of signableTargetTypes) {\n if (isTargetOfType(target, targetType)) {\n return true;\n }\n }\n return false;\n });\n if (applicationTargets.length === 0) {\n throw new Error(`Could not find any signable targets in project.pbxproj`);\n }\n return applicationTargets;\n}\n\nexport function findFirstNativeTarget(project: XcodeProject): NativeTargetSectionEntry {\n const targets = getNativeTargets(project);\n const applicationTargets = targets.filter(([, target]) =>\n isTargetOfType(target, TargetType.APPLICATION)\n );\n if (applicationTargets.length === 0) {\n throw new Error(`Could not find any application target in project.pbxproj`);\n }\n return applicationTargets[0];\n}\n\nexport function findNativeTargetByName(\n project: XcodeProject,\n targetName: string\n): NativeTargetSectionEntry {\n const nativeTargets = getNativeTargets(project);\n const nativeTargetEntry = nativeTargets.find(([, i]) => trimQuotes(i.name) === targetName);\n if (!nativeTargetEntry) {\n throw new Error(`Could not find target '${targetName}' in project.pbxproj`);\n }\n return nativeTargetEntry;\n}\n\nfunction findNativeTargetById(project: XcodeProject, targetId: string): NativeTargetSectionEntry {\n const nativeTargets = getNativeTargets(project);\n const nativeTargetEntry = nativeTargets.find(([key]) => key === targetId);\n if (!nativeTargetEntry) {\n throw new Error(`Could not find target with id '${targetId}' in project.pbxproj`);\n }\n return nativeTargetEntry;\n}\n"],"file":"Target.js"}
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createBuildSourceFile = createBuildSourceFile;
|
|
7
7
|
exports.withBuildSourceFile = void 0;
|
|
8
8
|
|
|
9
|
-
function
|
|
10
|
-
const data = _interopRequireDefault(require("fs
|
|
9
|
+
function _fs() {
|
|
10
|
+
const data = _interopRequireDefault(require("fs"));
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
_fs = function () {
|
|
13
13
|
return data;
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -95,9 +95,9 @@ function createBuildSourceFile({
|
|
|
95
95
|
}) {
|
|
96
96
|
const absoluteFilePath = _path().default.join(nativeProjectRoot, filePath);
|
|
97
97
|
|
|
98
|
-
if (overwrite || !
|
|
98
|
+
if (overwrite || !_fs().default.existsSync(absoluteFilePath)) {
|
|
99
99
|
// Create the file
|
|
100
|
-
|
|
100
|
+
_fs().default.writeFileSync(absoluteFilePath, fileContents, 'utf8');
|
|
101
101
|
} // `myapp`
|
|
102
102
|
|
|
103
103
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/XcodeProjectFile.ts"],"names":["withBuildSourceFile","config","filePath","contents","overwrite","projectName","modRequest","projectRoot","modResults","createBuildSourceFile","project","nativeProjectRoot","platformProjectRoot","fileContents","path","join","absoluteFilePath","fs","existsSync","writeFileSync","groupName","dirname","hasFile","filepath"],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAIX,GAAG,CAACC,MAAD,EAAS;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAT,KAA+C;AAClD,SAAO,oCAAiBH,MAAjB,EAAyBA,MAAM,IAAI;AACxC,UAAMI,WAAW,GAAG,iCAAeJ,MAAM,CAACK,UAAP,CAAkBC,WAAjC,CAApB;AAEAN,IAAAA,MAAM,CAACO,UAAP,GAAoBC,qBAAqB,CAAC;AACxCC,MAAAA,OAAO,EAAET,MAAM,CAACO,UADwB;AAExCG,MAAAA,iBAAiB,EAAEV,MAAM,CAACK,UAAP,CAAkBM,mBAFG;AAGxCC,MAAAA,YAAY,EAAEV,QAH0B;AAIxCD,MAAAA,QAAQ,EAAEY,gBAAKC,IAAL,CAAUV,WAAV,EAAuBH,QAAvB,CAJ8B;AAKxCE,MAAAA;AALwC,KAAD,CAAzC;AAOA,WAAOH,MAAP;AACD,GAXM,CAAP;AAYD,CAjBM;AAmBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASQ,qBAAT,CAA+B;AACpCC,EAAAA,OADoC;AAEpCC,EAAAA,iBAFoC;AAGpCT,EAAAA,QAHoC;AAIpCW,EAAAA,YAJoC;AAKpCT,EAAAA;AALoC,CAA/B,EAYU;AACf,QAAMY,gBAAgB,GAAGF,gBAAKC,IAAL,CAAUJ,iBAAV,EAA6BT,QAA7B,CAAzB;;AACA,MAAIE,SAAS,IAAI,CAACa,
|
|
1
|
+
{"version":3,"sources":["../../src/ios/XcodeProjectFile.ts"],"names":["withBuildSourceFile","config","filePath","contents","overwrite","projectName","modRequest","projectRoot","modResults","createBuildSourceFile","project","nativeProjectRoot","platformProjectRoot","fileContents","path","join","absoluteFilePath","fs","existsSync","writeFileSync","groupName","dirname","hasFile","filepath"],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAIX,GAAG,CAACC,MAAD,EAAS;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,QAAZ;AAAsBC,EAAAA;AAAtB,CAAT,KAA+C;AAClD,SAAO,oCAAiBH,MAAjB,EAAyBA,MAAM,IAAI;AACxC,UAAMI,WAAW,GAAG,iCAAeJ,MAAM,CAACK,UAAP,CAAkBC,WAAjC,CAApB;AAEAN,IAAAA,MAAM,CAACO,UAAP,GAAoBC,qBAAqB,CAAC;AACxCC,MAAAA,OAAO,EAAET,MAAM,CAACO,UADwB;AAExCG,MAAAA,iBAAiB,EAAEV,MAAM,CAACK,UAAP,CAAkBM,mBAFG;AAGxCC,MAAAA,YAAY,EAAEV,QAH0B;AAIxCD,MAAAA,QAAQ,EAAEY,gBAAKC,IAAL,CAAUV,WAAV,EAAuBH,QAAvB,CAJ8B;AAKxCE,MAAAA;AALwC,KAAD,CAAzC;AAOA,WAAOH,MAAP;AACD,GAXM,CAAP;AAYD,CAjBM;AAmBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASQ,qBAAT,CAA+B;AACpCC,EAAAA,OADoC;AAEpCC,EAAAA,iBAFoC;AAGpCT,EAAAA,QAHoC;AAIpCW,EAAAA,YAJoC;AAKpCT,EAAAA;AALoC,CAA/B,EAYU;AACf,QAAMY,gBAAgB,GAAGF,gBAAKC,IAAL,CAAUJ,iBAAV,EAA6BT,QAA7B,CAAzB;;AACA,MAAIE,SAAS,IAAI,CAACa,cAAGC,UAAH,CAAcF,gBAAd,CAAlB,EAAmD;AACjD;AACAC,kBAAGE,aAAH,CAAiBH,gBAAjB,EAAmCH,YAAnC,EAAiD,MAAjD;AACD,GALc,CAOf;;;AACA,QAAMO,SAAS,GAAGN,gBAAKO,OAAL,CAAanB,QAAb,CAAlB,CARe,CAUf;;;AACA,MAAI,CAACQ,OAAO,CAACY,OAAR,CAAgBpB,QAAhB,CAAL,EAAgC;AAC9BQ,IAAAA,OAAO,GAAG,4CAA0B;AAClCa,MAAAA,QAAQ,EAAErB,QADwB;AAElCkB,MAAAA,SAFkC;AAGlCV,MAAAA;AAHkC,KAA1B,CAAV;AAKD;;AACD,SAAOA,OAAP;AACD","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { ConfigPlugin, XcodeProject } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { addBuildSourceFileToGroup, getProjectName } from './utils/Xcodeproj';\n\n/**\n * Create a build source file and link it to Xcode.\n *\n * @param config\n * @param props.filePath relative to the build source folder. ex: `ViewController.swift` would be created in `ios/myapp/ViewController.swift`.\n * @param props.contents file contents to write.\n * @param props.overwrite should the contents overwrite any existing file in the same location on disk.\n * @returns\n */\nexport const withBuildSourceFile: ConfigPlugin<{\n filePath: string;\n contents: string;\n overwrite?: boolean;\n}> = (config, { filePath, contents, overwrite }) => {\n return withXcodeProject(config, config => {\n const projectName = getProjectName(config.modRequest.projectRoot);\n\n config.modResults = createBuildSourceFile({\n project: config.modResults,\n nativeProjectRoot: config.modRequest.platformProjectRoot,\n fileContents: contents,\n filePath: path.join(projectName, filePath),\n overwrite,\n });\n return config;\n });\n};\n\n/**\n * Add a source file to the Xcode project and write it to the file system.\n *\n * @param nativeProjectRoot absolute path to the native app root `user/app/ios`\n * @param filePath path relative to the `nativeProjectRoot` for the file to create `user/app/ios/myapp/foobar.swift`\n * @param fileContents string file contents to write to the `filePath`\n * @param overwrite should write file even if one already exists\n */\nexport function createBuildSourceFile({\n project,\n nativeProjectRoot,\n filePath,\n fileContents,\n overwrite,\n}: {\n project: XcodeProject;\n nativeProjectRoot: string;\n filePath: string;\n fileContents: string;\n overwrite?: boolean;\n}): XcodeProject {\n const absoluteFilePath = path.join(nativeProjectRoot, filePath);\n if (overwrite || !fs.existsSync(absoluteFilePath)) {\n // Create the file\n fs.writeFileSync(absoluteFilePath, fileContents, 'utf8');\n }\n\n // `myapp`\n const groupName = path.dirname(filePath);\n\n // Ensure the file is linked with Xcode resource files\n if (!project.hasFile(filePath)) {\n project = addBuildSourceFileToGroup({\n filepath: filePath,\n groupName,\n project,\n });\n }\n return project;\n}\n"],"file":"XcodeProjectFile.js"}
|