expo-modules-autolinking 0.7.1 → 0.8.0
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/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.8.0 — 2022-05-06
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Setting `EXPO_CONFIGURATION_DEBUG` or `EXPO_CONFIGURATION_RELEASE` Swift flags on project targets. ([#17378](https://github.com/expo/expo/pull/17378) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Fix debug-only modules weren't installed if the `DEBUG` flag wasn't present in `OTHER_SWIFT_FLAGS`. ([#17383](https://github.com/expo/expo/pull/17383) by [@lukmccall](https://github.com/lukmccall))
|
|
22
|
+
|
|
13
23
|
## 0.7.1 — 2022-05-05
|
|
14
24
|
|
|
15
25
|
### 🎉 New features
|
package/build/platforms/ios.js
CHANGED
|
@@ -115,20 +115,18 @@ ${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDeleg
|
|
|
115
115
|
`;
|
|
116
116
|
}
|
|
117
117
|
function generateCommonImportList(swiftModules) {
|
|
118
|
-
return swiftModules.map((moduleName) => `import ${moduleName}
|
|
118
|
+
return swiftModules.map((moduleName) => `import ${moduleName}`).join('\n');
|
|
119
119
|
}
|
|
120
120
|
function generateDebugOnlyImportList(swiftModules) {
|
|
121
121
|
if (!swiftModules.length) {
|
|
122
122
|
return '';
|
|
123
123
|
}
|
|
124
|
-
return
|
|
125
|
-
.map((moduleName) => `import ${moduleName}\n`)
|
|
126
|
-
.join('')}#endif\n`;
|
|
124
|
+
return (wrapInDebugConfigurationCheck(0, swiftModules.map((moduleName) => `import ${moduleName}`).join('\n')) + '\n');
|
|
127
125
|
}
|
|
128
126
|
function generateModuleClasses(classNames, debugOnlyClassName) {
|
|
129
127
|
const commonClassNames = formatArrayOfClassNames(classNames);
|
|
130
128
|
if (debugOnlyClassName.length > 0) {
|
|
131
|
-
return
|
|
129
|
+
return wrapInDebugConfigurationCheck(2, `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`, `return ${commonClassNames}`);
|
|
132
130
|
}
|
|
133
131
|
else {
|
|
134
132
|
return `${indent.repeat(2)}return ${commonClassNames}`;
|
|
@@ -144,7 +142,7 @@ ${indent.repeat(2)}]`;
|
|
|
144
142
|
function generateReactDelegateHandlers(module, debugOnlyModules) {
|
|
145
143
|
const commonModules = formatArrayOfReactDelegateHandler(module);
|
|
146
144
|
if (debugOnlyModules.length > 0) {
|
|
147
|
-
return
|
|
145
|
+
return wrapInDebugConfigurationCheck(2, `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`, `return ${commonModules}`);
|
|
148
146
|
}
|
|
149
147
|
else {
|
|
150
148
|
return `${indent.repeat(2)}return ${commonModules}`;
|
|
@@ -164,4 +162,10 @@ function formatArrayOfReactDelegateHandler(modules) {
|
|
|
164
162
|
${indent.repeat(2)}]`;
|
|
165
163
|
}
|
|
166
164
|
exports.formatArrayOfReactDelegateHandler = formatArrayOfReactDelegateHandler;
|
|
165
|
+
function wrapInDebugConfigurationCheck(indentationLevel, debugBlock, releaseBlock = null) {
|
|
166
|
+
if (releaseBlock) {
|
|
167
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(indentationLevel)}${debugBlock}\n${indent.repeat(indentationLevel)}#else\n${indent.repeat(indentationLevel)}${releaseBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
168
|
+
}
|
|
169
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(indentationLevel)}${debugBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
170
|
+
}
|
|
167
171
|
//# sourceMappingURL=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MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,WAAW,eAAe,OAAO,QAAQ,CAAC,CAAC;SACjF;KACF;IACD,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC3E,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC;AATD,8EASC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport {\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\n\nconst indent = ' ';\n\nasync function findPodspecFiles(revision: PackageRevision): Promise<string[]> {\n const configPodspecPaths = revision.config?.iosPodspecPaths();\n if (configPodspecPaths && configPodspecPaths.length) {\n return configPodspecPaths;\n }\n\n const podspecFiles = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n return podspecFiles;\n}\n\nexport function getSwiftModuleNames(\n pods: ModuleIosPodspecInfo[],\n swiftModuleNames: string[] | undefined\n): string[] {\n if (swiftModuleNames && swiftModuleNames.length) {\n return swiftModuleNames;\n }\n // by default, non-alphanumeric characters in the pod name are replaced by _ in the module name\n return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));\n}\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise<ModuleDescriptorIos | null> {\n const podspecFiles = await findPodspecFiles(revision);\n if (!podspecFiles.length) {\n return null;\n }\n\n const pods = podspecFiles.map((podspecFile) => ({\n podName: path.basename(podspecFile, path.extname(podspecFile)),\n podspecDir: path.dirname(path.join(revision.path, podspecFile)),\n }));\n\n const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.iosSwiftModuleNames());\n\n return {\n packageName,\n pods,\n swiftModuleNames,\n flags: options.flags,\n modules: revision.config?.iosModules() ?? [],\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [],\n reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [],\n debugOnly: revision.config?.iosDebugOnly() ?? false,\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptorIos[],\n className: string\n): Promise<string> {\n const iosModules = modules.filter(\n (module) =>\n module.modules.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n\n const modulesToImport = iosModules.filter((module) => !module.debugOnly);\n const debugOnlyModules = iosModules.filter((module) => module.debugOnly);\n\n const swiftModules = ([] as string[])\n .concat(...modulesToImport.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const debugOnlySwiftModules = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const modulesClassNames = ([] as string[])\n .concat(...modulesToImport.map((module) => module.modules))\n .filter(Boolean);\n\n const debugOnlyModulesClassNames = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.modules))\n .filter(Boolean);\n\n const appDelegateSubscribers = ([] as string[]).concat(\n ...modulesToImport.map((module) => module.appDelegateSubscribers)\n );\n\n const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(\n ...debugOnlyModules.map((module) => module.appDelegateSubscribers)\n );\n\n const reactDelegateHandlerModules = modulesToImport.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${generateCommonImportList(swiftModules)}\n${generateDebugOnlyImportList(debugOnlySwiftModules)}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}\n }\n}\n`;\n}\n\nfunction generateCommonImportList(swiftModules: string[]): string {\n return swiftModules.map((moduleName) => `import ${moduleName}\\n`).join('');\n}\n\nfunction generateDebugOnlyImportList(swiftModules: string[]): string {\n if (!swiftModules.length) {\n return '';\n }\n\n return `#if DEBUG\\n${swiftModules\n .map((moduleName) => `import ${moduleName}\\n`)\n .join('')}#endif\\n`;\n}\n\nfunction generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {\n const commonClassNames = formatArrayOfClassNames(classNames);\n if (debugOnlyClassName.length > 0) {\n return `#if DEBUG\\n${indent.repeat(2)}return ${formatArrayOfClassNames(\n classNames.concat(debugOnlyClassName)\n )}\\n#else\\n${indent.repeat(2)}return ${commonClassNames}\\n#endif`;\n } else {\n return `${indent.repeat(2)}return ${commonClassNames}`;\n }\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction generateReactDelegateHandlers(\n module: ModuleDescriptorIos[],\n debugOnlyModules: ModuleDescriptorIos[]\n): string {\n const commonModules = formatArrayOfReactDelegateHandler(module);\n if (debugOnlyModules.length > 0) {\n return `#if DEBUG\\n${indent.repeat(2)}return ${formatArrayOfReactDelegateHandler(\n module.concat(debugOnlyModules)\n )}\\n#else\\n${indent.repeat(2)}return ${commonModules}\\n#endif`;\n } else {\n return `${indent.repeat(2)}return ${commonModules}`;\n }\n}\n\n/**\n * Formats an array of modules to Swift's array containing ReactDelegateHandlers\n */\nexport function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]): string {\n const values: string[] = [];\n for (const module of modules) {\n for (const handler of module.reactDelegateHandlers) {\n values.push(`(packageName: \"${module.packageName}\", handler: ${handler}.self)`);\n }\n }\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AASxB,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,KAAK,UAAU,gBAAgB,CAAC,QAAyB;;IACvD,MAAM,kBAAkB,GAAG,MAAA,QAAQ,CAAC,MAAM,0CAAE,eAAe,EAAE,CAAC;IAC9D,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,EAAE;QACnD,OAAO,kBAAkB,CAAC;KAC3B;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAI,EAAC,aAAa,EAAE;QAC7C,GAAG,EAAE,QAAQ,CAAC,IAAI;QAClB,MAAM,EAAE,CAAC,oBAAoB,CAAC;KAC/B,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,mBAAmB,CACjC,IAA4B,EAC5B,gBAAsC;IAE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,MAAM,CAAC,MAAM,CACvE,gBAAgB,CACjB,GAAG,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;KAC9D;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AAC7D,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport {\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\n\nconst indent = ' ';\n\nasync function findPodspecFiles(revision: PackageRevision): Promise<string[]> {\n const configPodspecPaths = revision.config?.iosPodspecPaths();\n if (configPodspecPaths && configPodspecPaths.length) {\n return configPodspecPaths;\n }\n\n const podspecFiles = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n return podspecFiles;\n}\n\nexport function getSwiftModuleNames(\n pods: ModuleIosPodspecInfo[],\n swiftModuleNames: string[] | undefined\n): string[] {\n if (swiftModuleNames && swiftModuleNames.length) {\n return swiftModuleNames;\n }\n // by default, non-alphanumeric characters in the pod name are replaced by _ in the module name\n return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));\n}\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise<ModuleDescriptorIos | null> {\n const podspecFiles = await findPodspecFiles(revision);\n if (!podspecFiles.length) {\n return null;\n }\n\n const pods = podspecFiles.map((podspecFile) => ({\n podName: path.basename(podspecFile, path.extname(podspecFile)),\n podspecDir: path.dirname(path.join(revision.path, podspecFile)),\n }));\n\n const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.iosSwiftModuleNames());\n\n return {\n packageName,\n pods,\n swiftModuleNames,\n flags: options.flags,\n modules: revision.config?.iosModules() ?? [],\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [],\n reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [],\n debugOnly: revision.config?.iosDebugOnly() ?? false,\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptorIos[],\n className: string\n): Promise<string> {\n const iosModules = modules.filter(\n (module) =>\n module.modules.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n\n const modulesToImport = iosModules.filter((module) => !module.debugOnly);\n const debugOnlyModules = iosModules.filter((module) => module.debugOnly);\n\n const swiftModules = ([] as string[])\n .concat(...modulesToImport.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const debugOnlySwiftModules = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const modulesClassNames = ([] as string[])\n .concat(...modulesToImport.map((module) => module.modules))\n .filter(Boolean);\n\n const debugOnlyModulesClassNames = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.modules))\n .filter(Boolean);\n\n const appDelegateSubscribers = ([] as string[]).concat(\n ...modulesToImport.map((module) => module.appDelegateSubscribers)\n );\n\n const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(\n ...debugOnlyModules.map((module) => module.appDelegateSubscribers)\n );\n\n const reactDelegateHandlerModules = modulesToImport.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${generateCommonImportList(swiftModules)}\n${generateDebugOnlyImportList(debugOnlySwiftModules)}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}\n }\n}\n`;\n}\n\nfunction generateCommonImportList(swiftModules: string[]): string {\n return swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n');\n}\n\nfunction generateDebugOnlyImportList(swiftModules: string[]): string {\n if (!swiftModules.length) {\n return '';\n }\n\n return (\n wrapInDebugConfigurationCheck(\n 0,\n swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n')\n ) + '\\n'\n );\n}\n\nfunction generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {\n const commonClassNames = formatArrayOfClassNames(classNames);\n if (debugOnlyClassName.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,\n `return ${commonClassNames}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonClassNames}`;\n }\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction generateReactDelegateHandlers(\n module: ModuleDescriptorIos[],\n debugOnlyModules: ModuleDescriptorIos[]\n): string {\n const commonModules = formatArrayOfReactDelegateHandler(module);\n if (debugOnlyModules.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,\n `return ${commonModules}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonModules}`;\n }\n}\n\n/**\n * Formats an array of modules to Swift's array containing ReactDelegateHandlers\n */\nexport function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]): string {\n const values: string[] = [];\n for (const module of modules) {\n for (const handler of module.reactDelegateHandlers) {\n values.push(`(packageName: \"${module.packageName}\", handler: ${handler}.self)`);\n }\n }\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction wrapInDebugConfigurationCheck(\n indentationLevel: number,\n debugBlock: string,\n releaseBlock: string | null = null\n) {\n if (releaseBlock) {\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#else\\n${indent.repeat(\n indentationLevel\n )}${releaseBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n }\n\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Scripts that autolink Expo modules.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"find-up": "^5.0.0",
|
|
49
49
|
"fs-extra": "^9.1.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3769aac131c449afca54c63148549b31fd4f1ad4"
|
|
52
52
|
}
|
|
@@ -44,6 +44,7 @@ module Pod
|
|
|
44
44
|
|
|
45
45
|
Expo::ProjectIntegrator::integrate_targets_in_project(project_targets, project)
|
|
46
46
|
Expo::ProjectIntegrator::remove_nils_from_source_files(project)
|
|
47
|
+
Expo::ProjectIntegrator::set_autolinking_configuration(project)
|
|
47
48
|
|
|
48
49
|
# CocoaPods saves the projects to integrate at the next step,
|
|
49
50
|
# but in some cases we're modifying other projects as well.
|
|
@@ -3,6 +3,9 @@ module Expo
|
|
|
3
3
|
module ProjectIntegrator
|
|
4
4
|
include Pod
|
|
5
5
|
|
|
6
|
+
CONFIGURATION_FLAG_PREFIX = 'EXPO_CONFIGURATION_'
|
|
7
|
+
SWIFT_FLAGS = 'OTHER_SWIFT_FLAGS'
|
|
8
|
+
|
|
6
9
|
# Integrates targets in the project and generates modules providers.
|
|
7
10
|
def self.integrate_targets_in_project(targets, project)
|
|
8
11
|
# Find the targets that use expo modules and need the modules provider
|
|
@@ -98,5 +101,32 @@ module Expo
|
|
|
98
101
|
project.main_group.find_subpath(Constants::GENERATED_GROUP_NAME, autocreate)
|
|
99
102
|
end
|
|
100
103
|
|
|
104
|
+
# Sets EXPO_CONFIGURATION_* compiler flag for Swift.
|
|
105
|
+
def self.set_autolinking_configuration(project)
|
|
106
|
+
project.native_targets.each do |native_target|
|
|
107
|
+
native_target.build_configurations.each do |build_configuration|
|
|
108
|
+
configuration_flag = "-D #{CONFIGURATION_FLAG_PREFIX}#{build_configuration.name.upcase}"
|
|
109
|
+
build_settings = build_configuration.build_settings
|
|
110
|
+
|
|
111
|
+
# For some targets it might be `nil` by default which is an equivalent to `$(inherited)`
|
|
112
|
+
if build_settings[SWIFT_FLAGS].nil?
|
|
113
|
+
build_settings[SWIFT_FLAGS] ||= '$(inherited)'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# If the correct flag is not set yet
|
|
117
|
+
if !build_settings[SWIFT_FLAGS].include?(configuration_flag)
|
|
118
|
+
# Remove existing flag to make sure we don't put another one each time
|
|
119
|
+
build_settings[SWIFT_FLAGS] = build_settings[SWIFT_FLAGS].gsub(/\b-D\s+#{Regexp.quote(CONFIGURATION_FLAG_PREFIX)}\w+/, '')
|
|
120
|
+
|
|
121
|
+
# Add the correct flag
|
|
122
|
+
build_settings[SWIFT_FLAGS] << ' ' << configuration_flag
|
|
123
|
+
|
|
124
|
+
# Make sure the project will be saved as we did some changes
|
|
125
|
+
project.mark_dirty!
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
101
131
|
end # module ExpoAutolinkingExtension
|
|
102
132
|
end # module Expo
|
package/src/platforms/ios.ts
CHANGED
|
@@ -158,7 +158,7 @@ ${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDeleg
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
function generateCommonImportList(swiftModules: string[]): string {
|
|
161
|
-
return swiftModules.map((moduleName) => `import ${moduleName}
|
|
161
|
+
return swiftModules.map((moduleName) => `import ${moduleName}`).join('\n');
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
function generateDebugOnlyImportList(swiftModules: string[]): string {
|
|
@@ -166,17 +166,22 @@ function generateDebugOnlyImportList(swiftModules: string[]): string {
|
|
|
166
166
|
return '';
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
return
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
return (
|
|
170
|
+
wrapInDebugConfigurationCheck(
|
|
171
|
+
0,
|
|
172
|
+
swiftModules.map((moduleName) => `import ${moduleName}`).join('\n')
|
|
173
|
+
) + '\n'
|
|
174
|
+
);
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
function generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {
|
|
175
178
|
const commonClassNames = formatArrayOfClassNames(classNames);
|
|
176
179
|
if (debugOnlyClassName.length > 0) {
|
|
177
|
-
return
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
return wrapInDebugConfigurationCheck(
|
|
181
|
+
2,
|
|
182
|
+
`return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,
|
|
183
|
+
`return ${commonClassNames}`
|
|
184
|
+
);
|
|
180
185
|
} else {
|
|
181
186
|
return `${indent.repeat(2)}return ${commonClassNames}`;
|
|
182
187
|
}
|
|
@@ -196,9 +201,11 @@ function generateReactDelegateHandlers(
|
|
|
196
201
|
): string {
|
|
197
202
|
const commonModules = formatArrayOfReactDelegateHandler(module);
|
|
198
203
|
if (debugOnlyModules.length > 0) {
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
|
|
204
|
+
return wrapInDebugConfigurationCheck(
|
|
205
|
+
2,
|
|
206
|
+
`return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,
|
|
207
|
+
`return ${commonModules}`
|
|
208
|
+
);
|
|
202
209
|
} else {
|
|
203
210
|
return `${indent.repeat(2)}return ${commonModules}`;
|
|
204
211
|
}
|
|
@@ -217,3 +224,21 @@ export function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]
|
|
|
217
224
|
return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
|
|
218
225
|
${indent.repeat(2)}]`;
|
|
219
226
|
}
|
|
227
|
+
|
|
228
|
+
function wrapInDebugConfigurationCheck(
|
|
229
|
+
indentationLevel: number,
|
|
230
|
+
debugBlock: string,
|
|
231
|
+
releaseBlock: string | null = null
|
|
232
|
+
) {
|
|
233
|
+
if (releaseBlock) {
|
|
234
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(
|
|
235
|
+
indentationLevel
|
|
236
|
+
)}${debugBlock}\n${indent.repeat(indentationLevel)}#else\n${indent.repeat(
|
|
237
|
+
indentationLevel
|
|
238
|
+
)}${releaseBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(
|
|
242
|
+
indentationLevel
|
|
243
|
+
)}${debugBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
244
|
+
}
|