Skip to content
This repository was archived by the owner on Jun 14, 2026. It is now read-only.

Commit 839bbfb

Browse files
Fix Xcode build cycle between Crashlytics script and appex embedding
Xcode's new build system detects a dependency cycle: copy appex → Crashlytics script → dSYM → Info.plist → copy appex. Fix by reordering the main target's build phases so all script phases (Crashlytics, etc.) run after the copy-files phase that embeds the notification extension. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6cbda3b commit 839bbfb

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

hooks/after_platform_add/010_create_notification_extension.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,32 @@ module.exports = function(context) {
124124
});
125125
}
126126

127+
// Fix build cycle: move script phases (Crashlytics, etc.) to the end
128+
// of the main target's build phases so they run after "Embed App
129+
// Extensions" (the copy-files phase for the appex). Without this,
130+
// Xcode sees: copy appex → Crashlytics → dSYM → copy appex = cycle.
131+
console.log('Reordering build phases to break dependency cycle');
132+
let nativeTargets = proj.hash.project.objects['PBXNativeTarget'];
133+
Object.keys(nativeTargets).forEach(key => {
134+
let nt = nativeTargets[key];
135+
if (!nt || !nt.buildPhases || nt.name !== `"${appName}"`) return;
136+
let phases = nt.buildPhases;
137+
let scriptPhaseIndices = [];
138+
let scriptPhases = [];
139+
phases.forEach((p, idx) => {
140+
// Check if this phase ref is a shell script phase
141+
if (shellScriptPhases && shellScriptPhases[p.value]) {
142+
scriptPhaseIndices.push(idx);
143+
scriptPhases.push(p);
144+
}
145+
});
146+
// Remove script phases from their current position and append at end
147+
for (let i = scriptPhaseIndices.length - 1; i >= 0; i--) {
148+
phases.splice(scriptPhaseIndices[i], 1);
149+
}
150+
scriptPhases.forEach(p => phases.push(p));
151+
});
152+
127153
console.log('Write the changes to the iOS project file');
128154
fs.writeFileSync(projPath, proj.writeSync());
129155
console.log(`Added ${extName} notification extension to project`);

0 commit comments

Comments
 (0)