@expo/config-plugins 5.0.3 → 6.0.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/build/Plugin.types.d.ts +7 -7
- package/build/Plugin.types.js +0 -9
- package/build/Plugin.types.js.map +1 -1
- package/build/android/AllowBackup.js +0 -15
- package/build/android/AllowBackup.js.map +1 -1
- package/build/android/BuildProperties.js +2 -16
- package/build/android/BuildProperties.js.map +1 -1
- package/build/android/Colors.js +3 -25
- package/build/android/Colors.js.map +1 -1
- package/build/android/EasBuild.js +2 -22
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/EasBuildGradleScript.js.map +1 -1
- package/build/android/GoogleMapsApiKey.js +0 -12
- package/build/android/GoogleMapsApiKey.js.map +1 -1
- package/build/android/GoogleServices.js +10 -48
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/IntentFilters.d.ts +1 -1
- package/build/android/IntentFilters.js +8 -24
- package/build/android/IntentFilters.js.map +1 -1
- package/build/android/Manifest.d.ts +19 -19
- package/build/android/Manifest.js +7 -66
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Name.js +6 -27
- package/build/android/Name.js.map +1 -1
- package/build/android/Orientation.js +2 -12
- package/build/android/Orientation.js.map +1 -1
- package/build/android/Package.js +26 -111
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.d.ts +2 -2
- package/build/android/Paths.js +0 -47
- package/build/android/Paths.js.map +1 -1
- package/build/android/Permissions.js +8 -52
- package/build/android/Permissions.js.map +1 -1
- package/build/android/PrimaryColor.js +0 -18
- package/build/android/PrimaryColor.js.map +1 -1
- package/build/android/Properties.d.ts +1 -1
- package/build/android/Properties.js +0 -9
- package/build/android/Properties.js.map +1 -1
- package/build/android/Resources.d.ts +4 -4
- package/build/android/Resources.js +9 -29
- package/build/android/Resources.js.map +1 -1
- package/build/android/Scheme.d.ts +1 -1
- package/build/android/Scheme.js +13 -66
- package/build/android/Scheme.js.map +1 -1
- package/build/android/StatusBar.js +5 -33
- package/build/android/StatusBar.js.map +1 -1
- package/build/android/Strings.js +0 -14
- package/build/android/Strings.js.map +1 -1
- package/build/android/Styles.js +7 -34
- package/build/android/Styles.js.map +1 -1
- package/build/android/Updates.d.ts +2 -0
- package/build/android/Updates.js +50 -47
- package/build/android/Updates.js.map +1 -1
- package/build/android/Version.js +3 -29
- package/build/android/Version.js.map +1 -1
- package/build/android/WindowSoftInputMode.js +0 -14
- package/build/android/WindowSoftInputMode.js.map +1 -1
- package/build/android/codeMod.js +6 -22
- package/build/android/codeMod.js.map +1 -1
- package/build/android/index.js +0 -94
- package/build/android/index.js.map +1 -1
- package/build/index.js +2 -65
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +1 -1
- package/build/ios/Bitcode.js +8 -28
- package/build/ios/Bitcode.js.map +1 -1
- package/build/ios/BuildProperties.js +2 -14
- package/build/ios/BuildProperties.js.map +1 -1
- package/build/ios/BuildScheme.js +2 -34
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +13 -72
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/DeviceFamily.js +6 -24
- package/build/ios/DeviceFamily.js.map +1 -1
- package/build/ios/Entitlements.js +4 -45
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +2 -2
- package/build/ios/Google.js +11 -66
- package/build/ios/Google.js.map +1 -1
- package/build/ios/IosConfig.types.d.ts +6 -11
- package/build/ios/IosConfig.types.js.map +1 -1
- package/build/ios/Locales.d.ts +3 -3
- package/build/ios/Locales.js +12 -43
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +15 -53
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.js +7 -31
- package/build/ios/Name.js.map +1 -1
- package/build/ios/Orientation.js +2 -10
- package/build/ios/Orientation.js.map +1 -1
- package/build/ios/Paths.d.ts +2 -2
- package/build/ios/Paths.js +8 -73
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Permissions.js +1 -16
- package/build/ios/Permissions.js.map +1 -1
- package/build/ios/ProvisioningProfile.d.ts +1 -1
- package/build/ios/ProvisioningProfile.js +0 -18
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/RequiresFullScreen.js +19 -31
- package/build/ios/RequiresFullScreen.js.map +1 -1
- package/build/ios/Scheme.js +12 -34
- package/build/ios/Scheme.js.map +1 -1
- package/build/ios/Swift.js +16 -50
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.js +0 -30
- package/build/ios/Target.js.map +1 -1
- package/build/ios/Updates.js +10 -49
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/UsesNonExemptEncryption.js +4 -10
- package/build/ios/UsesNonExemptEncryption.js.map +1 -1
- package/build/ios/Version.js +4 -11
- package/build/ios/Version.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -23
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/codeMod.js +19 -60
- package/build/ios/codeMod.js.map +1 -1
- package/build/ios/index.js +0 -97
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +6 -6
- package/build/ios/utils/Xcodeproj.js +15 -101
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/ios/utils/getInfoPlistPath.js +2 -15
- package/build/ios/utils/getInfoPlistPath.js.map +1 -1
- package/build/ios/utils/string.js +0 -1
- package/build/ios/utils/string.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +2 -2
- package/build/plugins/android-plugins.js +11 -42
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/createBaseMod.d.ts +3 -3
- package/build/plugins/createBaseMod.js +8 -25
- package/build/plugins/createBaseMod.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +2 -2
- package/build/plugins/ios-plugins.js +8 -48
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/mod-compiler.js +21 -72
- package/build/plugins/mod-compiler.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +1 -1
- package/build/plugins/withAndroidBaseMods.js +4 -89
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withDangerousMod.js +0 -5
- package/build/plugins/withDangerousMod.js.map +1 -1
- package/build/plugins/withIosBaseMods.d.ts +1 -1
- package/build/plugins/withIosBaseMods.js +26 -118
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/plugins/withMod.d.ts +1 -1
- package/build/plugins/withMod.js +24 -59
- package/build/plugins/withMod.js.map +1 -1
- package/build/plugins/withPlugins.js +0 -9
- package/build/plugins/withPlugins.js.map +1 -1
- package/build/plugins/withRunOnce.js +3 -9
- package/build/plugins/withRunOnce.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +21 -43
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +2 -2
- package/build/utils/BuildProperties.types.js.map +1 -1
- package/build/utils/Updates.d.ts +3 -1
- package/build/utils/Updates.js +18 -77
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -1
- package/build/utils/XML.js +7 -44
- package/build/utils/XML.js.map +1 -1
- package/build/utils/commonCodeMod.js +2 -10
- package/build/utils/commonCodeMod.js.map +1 -1
- package/build/utils/errors.d.ts +1 -1
- package/build/utils/errors.js +3 -11
- package/build/utils/errors.js.map +1 -1
- package/build/utils/fs.js +1 -12
- package/build/utils/fs.js.map +1 -1
- package/build/utils/generateCode.d.ts +1 -1
- package/build/utils/generateCode.js +8 -25
- package/build/utils/generateCode.js.map +1 -1
- package/build/utils/history.d.ts +1 -1
- package/build/utils/history.js +0 -6
- package/build/utils/history.js.map +1 -1
- package/build/utils/matchBrackets.d.ts +3 -3
- package/build/utils/matchBrackets.js +2 -17
- package/build/utils/matchBrackets.js.map +1 -1
- package/build/utils/modules.js +0 -10
- package/build/utils/modules.js.map +1 -1
- package/build/utils/obj.js +0 -4
- package/build/utils/obj.js.map +1 -1
- package/build/utils/plugin-resolver.js +25 -69
- package/build/utils/plugin-resolver.js.map +1 -1
- package/build/utils/sortObject.js +4 -10
- package/build/utils/sortObject.js.map +1 -1
- package/build/utils/versions.js +0 -10
- package/build/utils/versions.js.map +1 -1
- package/build/utils/warnings.js +1 -9
- package/build/utils/warnings.js.map +1 -1
- package/package.json +5 -5
package/build/ios/Swift.js
CHANGED
|
@@ -8,73 +8,54 @@ exports.ensureSwiftBridgingHeaderSetup = ensureSwiftBridgingHeaderSetup;
|
|
|
8
8
|
exports.getDesignatedSwiftBridgingHeaderFileReference = getDesignatedSwiftBridgingHeaderFileReference;
|
|
9
9
|
exports.linkBridgingHeaderFile = linkBridgingHeaderFile;
|
|
10
10
|
exports.withSwiftBridgingHeader = exports.withNoopSwiftFile = void 0;
|
|
11
|
-
|
|
12
11
|
function _fs() {
|
|
13
12
|
const data = _interopRequireDefault(require("fs"));
|
|
14
|
-
|
|
15
13
|
_fs = function () {
|
|
16
14
|
return data;
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
return data;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
function _path() {
|
|
23
19
|
const data = _interopRequireDefault(require("path"));
|
|
24
|
-
|
|
25
20
|
_path = function () {
|
|
26
21
|
return data;
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
return data;
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
function _iosPlugins() {
|
|
33
26
|
const data = require("../plugins/ios-plugins");
|
|
34
|
-
|
|
35
27
|
_iosPlugins = function () {
|
|
36
28
|
return data;
|
|
37
29
|
};
|
|
38
|
-
|
|
39
30
|
return data;
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
function _Paths() {
|
|
43
33
|
const data = require("./Paths");
|
|
44
|
-
|
|
45
34
|
_Paths = function () {
|
|
46
35
|
return data;
|
|
47
36
|
};
|
|
48
|
-
|
|
49
37
|
return data;
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
function _XcodeProjectFile() {
|
|
53
40
|
const data = require("./XcodeProjectFile");
|
|
54
|
-
|
|
55
41
|
_XcodeProjectFile = function () {
|
|
56
42
|
return data;
|
|
57
43
|
};
|
|
58
|
-
|
|
59
44
|
return data;
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
function _Xcodeproj() {
|
|
63
47
|
const data = require("./utils/Xcodeproj");
|
|
64
|
-
|
|
65
48
|
_Xcodeproj = function () {
|
|
66
49
|
return data;
|
|
67
50
|
};
|
|
68
|
-
|
|
69
51
|
return data;
|
|
70
52
|
}
|
|
71
|
-
|
|
72
53
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
73
|
-
|
|
74
54
|
const templateBridgingHeader = `//
|
|
75
55
|
// Use this file to import your target's public headers that you would like to expose to Swift.
|
|
76
56
|
//
|
|
77
57
|
`;
|
|
58
|
+
|
|
78
59
|
/**
|
|
79
60
|
* Ensure a Swift bridging header is created for the project.
|
|
80
61
|
* This helps fix problems related to using modules that are written in Swift (lottie, FBSDK).
|
|
@@ -83,7 +64,6 @@ const templateBridgingHeader = `//
|
|
|
83
64
|
* 2. Writes the file and links to Xcode as a resource file.
|
|
84
65
|
* 3. Sets the build configuration `SWIFT_OBJC_BRIDGING_HEADER = [PROJECT_NAME]-Bridging-Header.h`
|
|
85
66
|
*/
|
|
86
|
-
|
|
87
67
|
const withSwiftBridgingHeader = config => {
|
|
88
68
|
return (0, _iosPlugins().withXcodeProject)(config, config => {
|
|
89
69
|
config.modResults = ensureSwiftBridgingHeaderSetup({
|
|
@@ -93,9 +73,7 @@ const withSwiftBridgingHeader = config => {
|
|
|
93
73
|
return config;
|
|
94
74
|
});
|
|
95
75
|
};
|
|
96
|
-
|
|
97
76
|
exports.withSwiftBridgingHeader = withSwiftBridgingHeader;
|
|
98
|
-
|
|
99
77
|
function ensureSwiftBridgingHeaderSetup({
|
|
100
78
|
projectRoot,
|
|
101
79
|
project
|
|
@@ -106,24 +84,22 @@ function ensureSwiftBridgingHeaderSetup({
|
|
|
106
84
|
project
|
|
107
85
|
})) {
|
|
108
86
|
const projectName = (0, _Xcodeproj().getProjectName)(projectRoot);
|
|
109
|
-
const bridgingHeader = createBridgingHeaderFileName(projectName);
|
|
110
|
-
|
|
87
|
+
const bridgingHeader = createBridgingHeaderFileName(projectName);
|
|
88
|
+
// Ensure a bridging header is created in the Xcode project.
|
|
111
89
|
project = createBridgingHeaderFile({
|
|
112
90
|
project,
|
|
113
91
|
projectName,
|
|
114
92
|
projectRoot,
|
|
115
93
|
bridgingHeader
|
|
116
|
-
});
|
|
117
|
-
|
|
94
|
+
});
|
|
95
|
+
// Designate the newly created file as the Swift bridging header in the Xcode project.
|
|
118
96
|
project = linkBridgingHeaderFile({
|
|
119
97
|
project,
|
|
120
98
|
bridgingHeader: _path().default.join(projectName, bridgingHeader)
|
|
121
99
|
});
|
|
122
100
|
}
|
|
123
|
-
|
|
124
101
|
return project;
|
|
125
102
|
}
|
|
126
|
-
|
|
127
103
|
function shouldCreateSwiftBridgingHeader({
|
|
128
104
|
projectRoot,
|
|
129
105
|
project
|
|
@@ -134,20 +110,18 @@ function shouldCreateSwiftBridgingHeader({
|
|
|
134
110
|
project
|
|
135
111
|
});
|
|
136
112
|
}
|
|
113
|
+
|
|
137
114
|
/**
|
|
138
115
|
* @returns String matching the default name used when Xcode automatically creates a bridging header file.
|
|
139
116
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
117
|
function createBridgingHeaderFileName(projectName) {
|
|
143
118
|
return `${projectName}-Bridging-Header.h`;
|
|
144
119
|
}
|
|
145
|
-
|
|
146
120
|
function getDesignatedSwiftBridgingHeaderFileReference({
|
|
147
121
|
project
|
|
148
122
|
}) {
|
|
149
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
150
|
-
|
|
123
|
+
const configurations = project.pbxXCBuildConfigurationSection();
|
|
124
|
+
// @ts-ignore
|
|
151
125
|
for (const {
|
|
152
126
|
buildSettings
|
|
153
127
|
} of Object.values(configurations || {})) {
|
|
@@ -159,22 +133,20 @@ function getDesignatedSwiftBridgingHeaderFileReference({
|
|
|
159
133
|
}
|
|
160
134
|
}
|
|
161
135
|
}
|
|
162
|
-
|
|
163
136
|
return null;
|
|
164
137
|
}
|
|
138
|
+
|
|
165
139
|
/**
|
|
166
140
|
*
|
|
167
141
|
* @param bridgingHeader The bridging header filename ex: `ExpoAPIs-Bridging-Header.h`
|
|
168
142
|
* @returns
|
|
169
143
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
144
|
function linkBridgingHeaderFile({
|
|
173
145
|
project,
|
|
174
146
|
bridgingHeader
|
|
175
147
|
}) {
|
|
176
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
177
|
-
|
|
148
|
+
const configurations = project.pbxXCBuildConfigurationSection();
|
|
149
|
+
// @ts-ignore
|
|
178
150
|
for (const {
|
|
179
151
|
buildSettings
|
|
180
152
|
} of Object.values(configurations || {})) {
|
|
@@ -184,10 +156,8 @@ function linkBridgingHeaderFile({
|
|
|
184
156
|
buildSettings.SWIFT_OBJC_BRIDGING_HEADER = bridgingHeader;
|
|
185
157
|
}
|
|
186
158
|
}
|
|
187
|
-
|
|
188
159
|
return project;
|
|
189
160
|
}
|
|
190
|
-
|
|
191
161
|
function createBridgingHeaderFile({
|
|
192
162
|
projectRoot,
|
|
193
163
|
projectName,
|
|
@@ -195,16 +165,15 @@ function createBridgingHeaderFile({
|
|
|
195
165
|
bridgingHeader
|
|
196
166
|
}) {
|
|
197
167
|
const bridgingHeaderProjectPath = _path().default.join((0, _Paths().getSourceRoot)(projectRoot), bridgingHeader);
|
|
198
|
-
|
|
199
168
|
if (!_fs().default.existsSync(bridgingHeaderProjectPath)) {
|
|
200
169
|
// Create the file
|
|
201
170
|
_fs().default.writeFileSync(bridgingHeaderProjectPath, templateBridgingHeader, 'utf8');
|
|
202
|
-
}
|
|
203
|
-
// Instead, this'll generate the default header in the application code folder `/ios/myproject/`.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const filePath = `${projectName}/${bridgingHeader}`; // Ensure the file is linked with Xcode resource files
|
|
171
|
+
}
|
|
207
172
|
|
|
173
|
+
// This is non-standard, Xcode generates the bridging header in `/ios` which is kinda annoying.
|
|
174
|
+
// Instead, this'll generate the default header in the application code folder `/ios/myproject/`.
|
|
175
|
+
const filePath = `${projectName}/${bridgingHeader}`;
|
|
176
|
+
// Ensure the file is linked with Xcode resource files
|
|
208
177
|
if (!project.hasFile(filePath)) {
|
|
209
178
|
project = (0, _Xcodeproj().addResourceFileToGroup)({
|
|
210
179
|
filepath: filePath,
|
|
@@ -215,16 +184,13 @@ function createBridgingHeaderFile({
|
|
|
215
184
|
verbose: false
|
|
216
185
|
});
|
|
217
186
|
}
|
|
218
|
-
|
|
219
187
|
return project;
|
|
220
188
|
}
|
|
221
|
-
|
|
222
189
|
const withNoopSwiftFile = config => {
|
|
223
190
|
return (0, _XcodeProjectFile().withBuildSourceFile)(config, {
|
|
224
191
|
filePath: 'noop-file.swift',
|
|
225
192
|
contents: ['//', '// @generated', '// A blank Swift file must be created for native modules with Swift files to work correctly.', '//', ''].join('\n')
|
|
226
193
|
});
|
|
227
194
|
};
|
|
228
|
-
|
|
229
195
|
exports.withNoopSwiftFile = withNoopSwiftFile;
|
|
230
196
|
//# sourceMappingURL=Swift.js.map
|
package/build/ios/Swift.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swift.js","names":["templateBridgingHeader","withSwiftBridgingHeader","config","withXcodeProject","modResults","ensureSwiftBridgingHeaderSetup","project","projectRoot","modRequest","shouldCreateSwiftBridgingHeader","projectName","getProjectName","bridgingHeader","createBridgingHeaderFileName","createBridgingHeaderFile","linkBridgingHeaderFile","path","join","isObjc","getAppDelegate","language","getDesignatedSwiftBridgingHeaderFileReference","configurations","pbxXCBuildConfigurationSection","buildSettings","Object","values","PRODUCT_NAME","SWIFT_OBJC_BRIDGING_HEADER","bridgingHeaderProjectPath","getSourceRoot","fs","existsSync","writeFileSync","filePath","hasFile","addResourceFileToGroup","filepath","groupName","isBuildFile","verbose","withNoopSwiftFile","withBuildSourceFile","contents"],"sources":["../../src/ios/Swift.ts"],"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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Swift.js","names":["templateBridgingHeader","withSwiftBridgingHeader","config","withXcodeProject","modResults","ensureSwiftBridgingHeaderSetup","project","projectRoot","modRequest","shouldCreateSwiftBridgingHeader","projectName","getProjectName","bridgingHeader","createBridgingHeaderFileName","createBridgingHeaderFile","linkBridgingHeaderFile","path","join","isObjc","getAppDelegate","language","getDesignatedSwiftBridgingHeaderFileReference","configurations","pbxXCBuildConfigurationSection","buildSettings","Object","values","PRODUCT_NAME","SWIFT_OBJC_BRIDGING_HEADER","bridgingHeaderProjectPath","getSourceRoot","fs","existsSync","writeFileSync","filePath","hasFile","addResourceFileToGroup","filepath","groupName","isBuildFile","verbose","withNoopSwiftFile","withBuildSourceFile","contents"],"sources":["../../src/ios/Swift.ts"],"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"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2E;AAE3E,MAAMA,sBAAsB,GAAI;AAChC;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,uBAAqC,GAAIC,MAAM,IAAK;EAC/D,OAAO,IAAAC,8BAAgB,EAACD,MAAM,EAAGA,MAAM,IAAK;IAC1CA,MAAM,CAACE,UAAU,GAAGC,8BAA8B,CAAC;MACjDC,OAAO,EAAEJ,MAAM,CAACE,UAAU;MAC1BG,WAAW,EAAEL,MAAM,CAACM,UAAU,CAACD;IACjC,CAAC,CAAC;IACF,OAAOL,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC;AAEK,SAASG,8BAA8B,CAAC;EAC7CE,WAAW;EACXD;AAIF,CAAC,EAAE;EACD;EACA,IAAIG,+BAA+B,CAAC;IAAEF,WAAW;IAAED;EAAQ,CAAC,CAAC,EAAE;IAC7D,MAAMI,WAAW,GAAG,IAAAC,2BAAc,EAACJ,WAAW,CAAC;IAC/C,MAAMK,cAAc,GAAGC,4BAA4B,CAACH,WAAW,CAAC;IAChE;IACAJ,OAAO,GAAGQ,wBAAwB,CAAC;MACjCR,OAAO;MACPI,WAAW;MACXH,WAAW;MACXK;IACF,CAAC,CAAC;IACF;IACAN,OAAO,GAAGS,sBAAsB,CAAC;MAC/BT,OAAO;MACPM,cAAc,EAAEI,eAAI,CAACC,IAAI,CAACP,WAAW,EAAEE,cAAc;IACvD,CAAC,CAAC;EACJ;E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AEA,OAAON,OAAO;AAChB;AAEO,SAASQ,wBAAwB,CAAC;EACvCP,WAAW;EACXG,WAAW;EACXJ,OAAO;EACPM;AAMF,CAAC,EAAgB;EACf,MAAMiB,yBAAyB,GAAGb,eAAI,CAACC,IAAI,CAAC,IAAAa,sBAAa,EAACvB,WAAW,CAAC,EAAEK,cAAc,CAAC;EACvF,IAAI,CAACmB,aAAE,CAACC,UAAU,CAACH,yBAAyB,CAAC,EAAE;IAC7C;IACAE,aAAE,CAACE,aAAa,CAACJ,yBAAyB,EAAE7B,sBAAsB,EAAE,MAAM,CAAC;EAC7E;;EAEA;EACA;EACA,MAAMkC,QAAQ,GAAI,GAAExB,WAAY,IAAGE,cAAe,EAAC;EACnD;EACA,IAAI,CAACN,OAAO,CAAC6B,OAAO,CAACD,QAAQ,CAAC,EAAE;IAC9B5B,OAAO,GAAG,IAAA8B,mCAAsB,EAAC;MAC/BC,QAAQ,EAAEH,QAAQ;MAClBI,SAAS,EAAE5B,WAAW;MACtBJ,OAAO;MACP;MACAiC,WAAW,EAAE,KAAK;MAClBC,OAAO,EAAE;IACX,CAAC,CAAC;EACJ;EACA,OAAOlC,OAAO;AAChB;AAEO,MAAMmC,iBAA+B,GAAIvC,MAAM,IAAK;EACzD,OAAO,IAAAwC,uCAAmB,EAACxC,MAAM,EAAE;IACjCgC,QAAQ,EAAE,iBAAiB;IAC3BS,QAAQ,EAAE,CACR,IAAI,EACJ,eAAe,EACf,8FAA8F,EAC9F,IAAI,EACJ,EAAE,CACH,CAAC1B,IAAI,CAAC,IAAI;EACb,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
package/build/ios/Target.js
CHANGED
|
@@ -11,40 +11,29 @@ exports.findSignableTargets = findSignableTargets;
|
|
|
11
11
|
exports.getNativeTargets = getNativeTargets;
|
|
12
12
|
exports.getXCBuildConfigurationFromPbxproj = getXCBuildConfigurationFromPbxproj;
|
|
13
13
|
exports.isTargetOfType = isTargetOfType;
|
|
14
|
-
|
|
15
14
|
function _BuildScheme() {
|
|
16
15
|
const data = require("./BuildScheme");
|
|
17
|
-
|
|
18
16
|
_BuildScheme = function () {
|
|
19
17
|
return data;
|
|
20
18
|
};
|
|
21
|
-
|
|
22
19
|
return data;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
function _Xcodeproj() {
|
|
26
22
|
const data = require("./utils/Xcodeproj");
|
|
27
|
-
|
|
28
23
|
_Xcodeproj = function () {
|
|
29
24
|
return data;
|
|
30
25
|
};
|
|
31
|
-
|
|
32
26
|
return data;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
function _string() {
|
|
36
29
|
const data = require("./utils/string");
|
|
37
|
-
|
|
38
30
|
_string = function () {
|
|
39
31
|
return data;
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
return data;
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
let TargetType;
|
|
46
36
|
exports.TargetType = TargetType;
|
|
47
|
-
|
|
48
37
|
(function (TargetType) {
|
|
49
38
|
TargetType["APPLICATION"] = "com.apple.product-type.application";
|
|
50
39
|
TargetType["EXTENSION"] = "com.apple.product-type.app-extension";
|
|
@@ -53,7 +42,6 @@ exports.TargetType = TargetType;
|
|
|
53
42
|
TargetType["STICKER_PACK_EXTENSION"] = "com.apple.product-type.app-extension.messages-sticker-pack";
|
|
54
43
|
TargetType["OTHER"] = "other";
|
|
55
44
|
})(TargetType || (exports.TargetType = TargetType = {}));
|
|
56
|
-
|
|
57
45
|
function getXCBuildConfigurationFromPbxproj(project, {
|
|
58
46
|
targetName,
|
|
59
47
|
buildConfiguration = 'Release'
|
|
@@ -65,7 +53,6 @@ function getXCBuildConfigurationFromPbxproj(project, {
|
|
|
65
53
|
});
|
|
66
54
|
return xcBuildConfiguration !== null && xcBuildConfiguration !== void 0 ? xcBuildConfiguration : null;
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
async function findApplicationTargetWithDependenciesAsync(projectRoot, scheme) {
|
|
70
57
|
const applicationTargetName = await (0, _BuildScheme().getApplicationTargetNameForSchemeAsync)(projectRoot, scheme);
|
|
71
58
|
const project = (0, _Xcodeproj().getPbxproj)(projectRoot);
|
|
@@ -77,12 +64,10 @@ async function findApplicationTargetWithDependenciesAsync(projectRoot, scheme) {
|
|
|
77
64
|
dependencies
|
|
78
65
|
};
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
function getTargetDependencies(project, parentTarget) {
|
|
82
68
|
if (!parentTarget.dependencies || parentTarget.dependencies.length === 0) {
|
|
83
69
|
return undefined;
|
|
84
70
|
}
|
|
85
|
-
|
|
86
71
|
return parentTarget.dependencies.map(({
|
|
87
72
|
value
|
|
88
73
|
}) => {
|
|
@@ -98,16 +83,13 @@ function getTargetDependencies(project, parentTarget) {
|
|
|
98
83
|
};
|
|
99
84
|
});
|
|
100
85
|
}
|
|
101
|
-
|
|
102
86
|
function isTargetOfType(target, targetType) {
|
|
103
87
|
return (0, _string().trimQuotes)(target.productType) === targetType;
|
|
104
88
|
}
|
|
105
|
-
|
|
106
89
|
function getNativeTargets(project) {
|
|
107
90
|
const section = project.pbxNativeTargetSection();
|
|
108
91
|
return Object.entries(section).filter(_Xcodeproj().isNotComment);
|
|
109
92
|
}
|
|
110
|
-
|
|
111
93
|
function findSignableTargets(project) {
|
|
112
94
|
const targets = getNativeTargets(project);
|
|
113
95
|
const signableTargetTypes = [TargetType.APPLICATION, TargetType.APP_CLIP, TargetType.EXTENSION, TargetType.WATCH, TargetType.STICKER_PACK_EXTENSION];
|
|
@@ -117,47 +99,35 @@ function findSignableTargets(project) {
|
|
|
117
99
|
return true;
|
|
118
100
|
}
|
|
119
101
|
}
|
|
120
|
-
|
|
121
102
|
return false;
|
|
122
103
|
});
|
|
123
|
-
|
|
124
104
|
if (applicationTargets.length === 0) {
|
|
125
105
|
throw new Error(`Could not find any signable targets in project.pbxproj`);
|
|
126
106
|
}
|
|
127
|
-
|
|
128
107
|
return applicationTargets;
|
|
129
108
|
}
|
|
130
|
-
|
|
131
109
|
function findFirstNativeTarget(project) {
|
|
132
110
|
const targets = getNativeTargets(project);
|
|
133
111
|
const applicationTargets = targets.filter(([, target]) => isTargetOfType(target, TargetType.APPLICATION));
|
|
134
|
-
|
|
135
112
|
if (applicationTargets.length === 0) {
|
|
136
113
|
throw new Error(`Could not find any application target in project.pbxproj`);
|
|
137
114
|
}
|
|
138
|
-
|
|
139
115
|
return applicationTargets[0];
|
|
140
116
|
}
|
|
141
|
-
|
|
142
117
|
function findNativeTargetByName(project, targetName) {
|
|
143
118
|
const nativeTargets = getNativeTargets(project);
|
|
144
119
|
const nativeTargetEntry = nativeTargets.find(([, i]) => (0, _string().trimQuotes)(i.name) === targetName);
|
|
145
|
-
|
|
146
120
|
if (!nativeTargetEntry) {
|
|
147
121
|
throw new Error(`Could not find target '${targetName}' in project.pbxproj`);
|
|
148
122
|
}
|
|
149
|
-
|
|
150
123
|
return nativeTargetEntry;
|
|
151
124
|
}
|
|
152
|
-
|
|
153
125
|
function findNativeTargetById(project, targetId) {
|
|
154
126
|
const nativeTargets = getNativeTargets(project);
|
|
155
127
|
const nativeTargetEntry = nativeTargets.find(([key]) => key === targetId);
|
|
156
|
-
|
|
157
128
|
if (!nativeTargetEntry) {
|
|
158
129
|
throw new Error(`Could not find target with id '${targetId}' in project.pbxproj`);
|
|
159
130
|
}
|
|
160
|
-
|
|
161
131
|
return nativeTargetEntry;
|
|
162
132
|
}
|
|
163
133
|
//# sourceMappingURL=Target.js.map
|
package/build/ios/Target.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Target.js","names":["TargetType","getXCBuildConfigurationFromPbxproj","project","targetName","buildConfiguration","nativeTarget","findNativeTargetByName","findFirstNativeTarget","xcBuildConfiguration","getBuildConfigurationForListIdAndName","configurationListId","buildConfigurationList","findApplicationTargetWithDependenciesAsync","projectRoot","scheme","applicationTargetName","getApplicationTargetNameForSchemeAsync","getPbxproj","applicationTarget","dependencies","getTargetDependencies","name","trimQuotes","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"],"sources":["../../src/ios/Target.ts"],"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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Target.js","names":["TargetType","getXCBuildConfigurationFromPbxproj","project","targetName","buildConfiguration","nativeTarget","findNativeTargetByName","findFirstNativeTarget","xcBuildConfiguration","getBuildConfigurationForListIdAndName","configurationListId","buildConfigurationList","findApplicationTargetWithDependenciesAsync","projectRoot","scheme","applicationTargetName","getApplicationTargetNameForSchemeAsync","getPbxproj","applicationTarget","dependencies","getTargetDependencies","name","trimQuotes","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"],"sources":["../../src/ios/Target.ts"],"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"],"mappings":";;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA4C,IAEhCA,UAAU;AAAA;AAAA,WAAVA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