@capgo/capacitor-appsflyer 8.1.5 → 8.1.7
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/package.json +5 -2
- package/scripts/configure-ios-dsyms.js +351 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-appsflyer",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.7",
|
|
4
4
|
"iosSdkVersion": "6.17.8",
|
|
5
5
|
"androidSdkVersion": "6.17.5",
|
|
6
6
|
"buildNumber": "1",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"ios/Sources",
|
|
17
17
|
"ios/Tests",
|
|
18
18
|
"Package.swift",
|
|
19
|
-
"CapgoCapacitorAppsflyer.podspec"
|
|
19
|
+
"CapgoCapacitorAppsflyer.podspec",
|
|
20
|
+
"scripts/configure-ios-dsyms.js"
|
|
20
21
|
],
|
|
21
22
|
"author": "Martin Donadieu <martin@capgo.app>",
|
|
22
23
|
"license": "MIT",
|
|
@@ -37,6 +38,8 @@
|
|
|
37
38
|
"deeplink"
|
|
38
39
|
],
|
|
39
40
|
"scripts": {
|
|
41
|
+
"capacitor:sync:after": "node scripts/configure-ios-dsyms.js",
|
|
42
|
+
"capacitor:update:after": "node scripts/configure-ios-dsyms.js",
|
|
40
43
|
"verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
|
|
41
44
|
"verify:ios": "xcodebuild -scheme CapgoCapacitorAppsflyer -destination generic/platform=iOS",
|
|
42
45
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const pluginName = 'CapgoCapacitorAppsflyer';
|
|
8
|
+
const frameworkNames = ['AppsFlyerLib'];
|
|
9
|
+
const phaseName = 'Capgo dSYMs for AppsFlyerLib';
|
|
10
|
+
|
|
11
|
+
function log(message) {
|
|
12
|
+
console.log(`[${pluginName}] ${message}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function warn(message) {
|
|
16
|
+
console.warn(`[${pluginName}] ${message}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function exists(filePath) {
|
|
20
|
+
return fs.existsSync(filePath);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function hasApplicationTarget(projectFile) {
|
|
24
|
+
try {
|
|
25
|
+
return fs.readFileSync(projectFile, 'utf8').includes('productType = "com.apple.product-type.application";');
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function stablePbxId(seed) {
|
|
32
|
+
return crypto.createHash('sha1').update(seed).digest('hex').slice(0, 24).toUpperCase();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function escapeRegExp(value) {
|
|
36
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function findExistingPhaseId(content) {
|
|
40
|
+
const pattern = new RegExp(
|
|
41
|
+
`([A-F0-9]{24}) /\\* ${escapeRegExp(phaseName)} \\*/ = \\{[\\s\\S]*?isa = PBXShellScriptBuildPhase;`,
|
|
42
|
+
'm',
|
|
43
|
+
);
|
|
44
|
+
return pattern.exec(content)?.[1] || '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function findProjectFile(rootDir) {
|
|
48
|
+
const preferred = path.join(rootDir, 'ios', 'App', 'App.xcodeproj', 'project.pbxproj');
|
|
49
|
+
if (exists(preferred)) {
|
|
50
|
+
return preferred;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const iosDir = path.join(rootDir, 'ios');
|
|
54
|
+
if (!exists(iosDir)) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const stack = [iosDir];
|
|
59
|
+
while (stack.length) {
|
|
60
|
+
const current = stack.pop();
|
|
61
|
+
const entries = fs.readdirSync(current, { withFileTypes: true });
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (entry.name === 'Pods') {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const entryPath = path.join(current, entry.name);
|
|
68
|
+
if (entry.isDirectory() && entry.name.endsWith('.xcodeproj')) {
|
|
69
|
+
if (entry.name === 'Pods.xcodeproj') {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const pbxproj = path.join(entryPath, 'project.pbxproj');
|
|
74
|
+
if (exists(pbxproj) && hasApplicationTarget(pbxproj)) {
|
|
75
|
+
return pbxproj;
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (entry.isDirectory()) {
|
|
80
|
+
stack.push(entryPath);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function shellScript() {
|
|
89
|
+
return [
|
|
90
|
+
'set -u',
|
|
91
|
+
'',
|
|
92
|
+
'if [ "${ACTION:-}" != "install" ]; then',
|
|
93
|
+
' exit 0',
|
|
94
|
+
'fi',
|
|
95
|
+
'',
|
|
96
|
+
`log() { echo "[${pluginName} dSYMs] $1"; }`,
|
|
97
|
+
'',
|
|
98
|
+
'if [ -z "${DWARF_DSYM_FOLDER_PATH:-}" ]; then',
|
|
99
|
+
' log "Skipping because DWARF_DSYM_FOLDER_PATH is not set."',
|
|
100
|
+
' exit 0',
|
|
101
|
+
'fi',
|
|
102
|
+
'',
|
|
103
|
+
'find_dsym_roots() {',
|
|
104
|
+
' for root in \\',
|
|
105
|
+
' "${PODS_ROOT:-}" \\',
|
|
106
|
+
' "${SRCROOT:-}" \\',
|
|
107
|
+
' "${PROJECT_DIR:-}" \\',
|
|
108
|
+
' "${BUILD_DIR:-}/../../../../../SourcePackages/artifacts" \\',
|
|
109
|
+
' "${BUILD_DIR:-}/../../SourcePackages/artifacts" \\',
|
|
110
|
+
' "${BUILD_DIR:-}/../SourcePackages/artifacts" \\',
|
|
111
|
+
' "${HOME:-}/Library/Developer/Xcode/DerivedData"',
|
|
112
|
+
' do',
|
|
113
|
+
' [ -d "$root" ] || continue',
|
|
114
|
+
' printf "%s\\n" "$root"',
|
|
115
|
+
' done',
|
|
116
|
+
'}',
|
|
117
|
+
'',
|
|
118
|
+
'find_framework_binary_in_roots() {',
|
|
119
|
+
' framework="$1"',
|
|
120
|
+
' old_ifs="$IFS"',
|
|
121
|
+
" IFS='",
|
|
122
|
+
"'",
|
|
123
|
+
' for root in $(find_dsym_roots); do',
|
|
124
|
+
' for binary in $(find "$root" -type f -path "*/$framework.framework/$framework" 2>/dev/null); do',
|
|
125
|
+
' case "$binary" in',
|
|
126
|
+
' *simulator*|*Simulator*) continue ;;',
|
|
127
|
+
' esac',
|
|
128
|
+
' if [ -f "$binary" ]; then',
|
|
129
|
+
' printf "%s\\n" "$binary"',
|
|
130
|
+
' IFS="$old_ifs"',
|
|
131
|
+
' return 0',
|
|
132
|
+
' fi',
|
|
133
|
+
' done',
|
|
134
|
+
' done',
|
|
135
|
+
' IFS="$old_ifs"',
|
|
136
|
+
' return 1',
|
|
137
|
+
'}',
|
|
138
|
+
'',
|
|
139
|
+
'find_framework_binary() {',
|
|
140
|
+
' framework="$1"',
|
|
141
|
+
' for dir in \\',
|
|
142
|
+
' "${TARGET_BUILD_DIR:-}/${FRAMEWORKS_FOLDER_PATH:-}" \\',
|
|
143
|
+
' "${BUILT_PRODUCTS_DIR:-}/${FRAMEWORKS_FOLDER_PATH:-}" \\',
|
|
144
|
+
' "${TARGET_BUILD_DIR:-}/${WRAPPER_NAME:-}/Frameworks" \\',
|
|
145
|
+
' "${BUILT_PRODUCTS_DIR:-}/${WRAPPER_NAME:-}/Frameworks" \\',
|
|
146
|
+
' "${TARGET_BUILD_DIR:-}/Frameworks" \\',
|
|
147
|
+
' "${BUILT_PRODUCTS_DIR:-}/Frameworks"',
|
|
148
|
+
' do',
|
|
149
|
+
' [ -n "$dir" ] || continue',
|
|
150
|
+
' binary="$dir/$framework.framework/$framework"',
|
|
151
|
+
' if [ -f "$binary" ]; then',
|
|
152
|
+
' printf "%s\\n" "$binary"',
|
|
153
|
+
' return 0',
|
|
154
|
+
' fi',
|
|
155
|
+
' done',
|
|
156
|
+
' find_framework_binary_in_roots "$framework"',
|
|
157
|
+
'}',
|
|
158
|
+
'',
|
|
159
|
+
'copy_prebuilt_dsym() {',
|
|
160
|
+
' framework="$1"',
|
|
161
|
+
' dsym_path="$2"',
|
|
162
|
+
' binary="$3"',
|
|
163
|
+
' binary_uuid="$(dwarfdump --uuid "$binary" 2>/dev/null | awk \'NR == 1 {print $2}\')"',
|
|
164
|
+
' [ -n "$binary_uuid" ] || return 1',
|
|
165
|
+
'',
|
|
166
|
+
' old_ifs="$IFS"',
|
|
167
|
+
" IFS='",
|
|
168
|
+
"'",
|
|
169
|
+
' for root in $(find_dsym_roots); do',
|
|
170
|
+
' for candidate in $(find "$root" -type d -name "$framework.framework.dSYM" 2>/dev/null); do',
|
|
171
|
+
' if dwarfdump --uuid "$candidate" 2>/dev/null | awk \'{print $2}\' | grep -qi "^$binary_uuid$"; then',
|
|
172
|
+
' rm -rf "$dsym_path"',
|
|
173
|
+
' cp -R "$candidate" "$dsym_path"',
|
|
174
|
+
' IFS="$old_ifs"',
|
|
175
|
+
' log "Copied vendor $framework.framework.dSYM."',
|
|
176
|
+
' return 0',
|
|
177
|
+
' fi',
|
|
178
|
+
' done',
|
|
179
|
+
' done',
|
|
180
|
+
' IFS="$old_ifs"',
|
|
181
|
+
' return 1',
|
|
182
|
+
'}',
|
|
183
|
+
'',
|
|
184
|
+
'copy_to_archive() {',
|
|
185
|
+
' dsym_path="$1"',
|
|
186
|
+
' framework="$2"',
|
|
187
|
+
' for archive_dsyms in "${ARCHIVE_DSYMS_PATH:-}" "${ARCHIVE_PATH:-}/dSYMs"; do',
|
|
188
|
+
' case "$archive_dsyms" in',
|
|
189
|
+
' ""|"/dSYMs") continue ;;',
|
|
190
|
+
' esac',
|
|
191
|
+
' mkdir -p "$archive_dsyms"',
|
|
192
|
+
' rm -rf "$archive_dsyms/$framework.framework.dSYM"',
|
|
193
|
+
' cp -R "$dsym_path" "$archive_dsyms/"',
|
|
194
|
+
' done',
|
|
195
|
+
'}',
|
|
196
|
+
'',
|
|
197
|
+
'mkdir -p "$DWARF_DSYM_FOLDER_PATH"',
|
|
198
|
+
'',
|
|
199
|
+
`for framework in ${frameworkNames.join(' ')}; do`,
|
|
200
|
+
' binary="$(find_framework_binary "$framework" || true)"',
|
|
201
|
+
' if [ -z "$binary" ]; then',
|
|
202
|
+
' log "Skipping $framework because a framework binary was not found."',
|
|
203
|
+
' continue',
|
|
204
|
+
' fi',
|
|
205
|
+
'',
|
|
206
|
+
' dsym_path="$DWARF_DSYM_FOLDER_PATH/$framework.framework.dSYM"',
|
|
207
|
+
' rm -rf "$dsym_path"',
|
|
208
|
+
' if copy_prebuilt_dsym "$framework" "$dsym_path" "$binary"; then',
|
|
209
|
+
' copy_to_archive "$dsym_path" "$framework"',
|
|
210
|
+
' continue',
|
|
211
|
+
' fi',
|
|
212
|
+
'',
|
|
213
|
+
' if xcrun dsymutil "$binary" -o "$dsym_path" >/dev/null; then',
|
|
214
|
+
' log "Prepared $framework.framework.dSYM."',
|
|
215
|
+
' copy_to_archive "$dsym_path" "$framework"',
|
|
216
|
+
' else',
|
|
217
|
+
' log "Failed to generate $framework.framework.dSYM."',
|
|
218
|
+
' fi',
|
|
219
|
+
'done',
|
|
220
|
+
'',
|
|
221
|
+
].join('\n');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function phaseObject(phaseId) {
|
|
225
|
+
const quotedScript = JSON.stringify(shellScript());
|
|
226
|
+
return `\t\t${phaseId} /* ${phaseName} */ = {
|
|
227
|
+
\t\t\tisa = PBXShellScriptBuildPhase;
|
|
228
|
+
\t\t\talwaysOutOfDate = 1;
|
|
229
|
+
\t\t\tbuildActionMask = 2147483647;
|
|
230
|
+
\t\t\tfiles = (
|
|
231
|
+
\t\t\t);
|
|
232
|
+
\t\t\tinputFileListPaths = (
|
|
233
|
+
\t\t\t);
|
|
234
|
+
\t\t\tinputPaths = (
|
|
235
|
+
\t\t\t\t"$(BUILD_DIR)",
|
|
236
|
+
\t\t\t\t"$(BUILD_DIR)/../../../../../SourcePackages/artifacts",
|
|
237
|
+
\t\t\t\t"$(BUILD_DIR)/../../SourcePackages/artifacts",
|
|
238
|
+
\t\t\t\t"$(BUILD_DIR)/../SourcePackages/artifacts",
|
|
239
|
+
\t\t\t\t"$(HOME)/Library/Developer/Xcode/DerivedData",
|
|
240
|
+
\t\t\t\t"$(PODS_ROOT)",
|
|
241
|
+
\t\t\t\t"$(PROJECT_DIR)",
|
|
242
|
+
\t\t\t\t"$(SRCROOT)",
|
|
243
|
+
\t\t\t);
|
|
244
|
+
\t\t\tname = "${phaseName}";
|
|
245
|
+
\t\t\toutputFileListPaths = (
|
|
246
|
+
\t\t\t);
|
|
247
|
+
\t\t\toutputPaths = (
|
|
248
|
+
\t\t\t\t"$(ARCHIVE_PATH)/dSYMs/AppsFlyerLib.framework.dSYM",
|
|
249
|
+
\t\t\t\t"$(DWARF_DSYM_FOLDER_PATH)/AppsFlyerLib.framework.dSYM",
|
|
250
|
+
\t\t\t);
|
|
251
|
+
\t\t\trunOnlyForDeploymentPostprocessing = 0;
|
|
252
|
+
\t\t\tshellPath = /bin/sh;
|
|
253
|
+
\t\t\tshellScript = ${quotedScript};
|
|
254
|
+
\t\t};`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function addShellScriptPhase(content, phaseId) {
|
|
258
|
+
const object = phaseObject(phaseId);
|
|
259
|
+
const existingPhaseId = findExistingPhaseId(content);
|
|
260
|
+
if (existingPhaseId) {
|
|
261
|
+
const existingPhasePattern = new RegExp(
|
|
262
|
+
`\\t\\t${escapeRegExp(existingPhaseId)} /\\* ${escapeRegExp(phaseName)} \\*/ = \\{[\\s\\S]*?\\n\\t\\t\\};`,
|
|
263
|
+
'm',
|
|
264
|
+
);
|
|
265
|
+
return content.replace(existingPhasePattern, object);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (content.includes('/* Begin PBXShellScriptBuildPhase section */')) {
|
|
269
|
+
return content.replace(
|
|
270
|
+
'/* End PBXShellScriptBuildPhase section */',
|
|
271
|
+
`${object}\n/* End PBXShellScriptBuildPhase section */`,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return content.replace(
|
|
276
|
+
'/* Begin PBXSourcesBuildPhase section */',
|
|
277
|
+
`/* Begin PBXShellScriptBuildPhase section */\n${object}\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */`,
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function addPhaseToApplicationTarget(content, phaseId) {
|
|
282
|
+
const targetPattern = /[A-F0-9]{24} \/\* [^*]+ \*\/ = \{[\s\S]*?\n\t\t\};/g;
|
|
283
|
+
let foundApplicationTarget = false;
|
|
284
|
+
let updatedApplicationTarget = false;
|
|
285
|
+
|
|
286
|
+
const nextContent = content.replace(targetPattern, (targetBlock) => {
|
|
287
|
+
if (
|
|
288
|
+
!targetBlock.includes('isa = PBXNativeTarget;') ||
|
|
289
|
+
!targetBlock.includes('productType = "com.apple.product-type.application";')
|
|
290
|
+
) {
|
|
291
|
+
return targetBlock;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
foundApplicationTarget = true;
|
|
295
|
+
if (targetBlock.includes(`${phaseId} /* ${phaseName} */`)) {
|
|
296
|
+
return targetBlock;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const nextTargetBlock = targetBlock.replace(/buildPhases = \(([\s\S]*?)\n\t\t\t\);/, (_match, phases) => {
|
|
300
|
+
return `buildPhases = (${phases}\n\t\t\t\t${phaseId} /* ${phaseName} */,\n\t\t\t);`;
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
if (nextTargetBlock === targetBlock) {
|
|
304
|
+
warn('Skipping one iOS dSYM configuration because an application target build phases list could not be updated.');
|
|
305
|
+
return targetBlock;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
updatedApplicationTarget = true;
|
|
309
|
+
return nextTargetBlock;
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
if (!foundApplicationTarget) {
|
|
313
|
+
warn('Skipping iOS dSYM configuration because no application target was found.');
|
|
314
|
+
return content;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (!updatedApplicationTarget) {
|
|
318
|
+
return content;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return nextContent;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function configureIosDsyms() {
|
|
325
|
+
if (process.env.CAPACITOR_PLATFORM_NAME !== 'ios') {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const rootDir = process.env.CAPACITOR_ROOT_DIR || process.cwd();
|
|
330
|
+
|
|
331
|
+
const projectFile = findProjectFile(rootDir);
|
|
332
|
+
if (!projectFile) {
|
|
333
|
+
warn('Skipping iOS dSYM configuration because no Xcode project was found.');
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const currentContent = fs.readFileSync(projectFile, 'utf8');
|
|
338
|
+
const phaseId = findExistingPhaseId(currentContent) || stablePbxId(phaseName);
|
|
339
|
+
let nextContent = addShellScriptPhase(currentContent, phaseId);
|
|
340
|
+
nextContent = addPhaseToApplicationTarget(nextContent, phaseId);
|
|
341
|
+
|
|
342
|
+
if (nextContent === currentContent) {
|
|
343
|
+
log('iOS vendor dSYM archive phase is already configured.');
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
fs.writeFileSync(projectFile, nextContent, 'utf8');
|
|
348
|
+
log('Configured iOS vendor dSYM archive phase.');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
configureIosDsyms();
|