Removing a target referenced by PBXFileSystemSynchronizedBuildFileExceptionSet crashes serialization
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- swift
- Ambito
- build-system, devtools
Direzione di ricerca
Parti da PBXNativeTarget#remove_from_project e PBXFileSystemSynchronizedBuildFileExceptionSet#display_name, quindi riproduci il caso AppA/AppB dell’issue con la gem Ruby xcodeproj. Traccia il modo in cui vengono rimosse le references ai target e in cui la serializzazione raggiunge l’exception set. Il lavoro è completato quando la rimozione di un target referenziato ripulisce i suoi exception sets e il salvataggio non va più in crash; considera le voci orfane elencate se rientrano nell’ambito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Calling removeFromProject() on a PBXNativeTarget does not cascade to PBXFileSystemSynchronizedBuildFileExceptionSet objects that reference that target. The orphaned exception sets retain a nil target reference, which crashes during serialization when generating the plist annotation (target.name on nil).
Minimal reproduction
Setup (Xcode 16+):
- Create a project with two app targets: AppA and AppB
- Create a folder
SharedSrc/containingShared.swiftandInfo.plist - In Xcode, drag
SharedSrc/into the project as a synchronized folder reference, with both targets checked - Select
Info.plistin the navigator, open the File Inspector, and uncheck AppB from Target Membership
This creates a PBXFileSystemSynchronizedBuildFileExceptionSet with target = AppB inside the SharedSrc synchronized root group — meaning "exclude Info.plist from AppB's build."
Reproduction (Ruby xcodeproj gem v1.27.0):
require "xcodeproj"
proj = Xcodeproj::Project.open("Repro.xcodeproj")
# Removing AppA works fine (not referenced by any exception set)
proj.targets.find { |t| t.name == "AppA" }.remove_from_project
proj.save # => OK
# Removing AppB crashes (referenced by the exception set)
proj.targets.find { |t| t.name == "AppB" }.remove_from_project
proj.save # => CRASH
Crash:
PBXFileSystemSynchronizedBuildFileExceptionSet#display_name: undefined method 'name' for nil (NoMethodError)
"Exceptions for \"#{GroupableHelper.parent(self).display_name}\" in \"#{target.name}\" target"
What happens
removeFromProject()on the target removes thePBXNativeTargetobject, its build configuration list, and its build phases- It does not remove
PBXFileSystemSynchronizedBuildFileExceptionSetobjects whosetargetproperty pointed to the removed target - On save, the serializer calls
display_nameon each exception set, which accessestarget.name— now nil — and crashes
What should happen
removeFromProject() on a PBXNativeTarget should also remove any PBXFileSystemSynchronizedBuildFileExceptionSet whose target references the removed target. Xcode's UI does this cleanup when deleting a target — the programmatic API should match.
Additional incomplete cascading
Beyond exception sets, removeFromProject() also leaves behind:
PBXFileReferencefor the target's product (.app,.xctest)- The product reference in the Products group
PBXGroupentries for the target's source directory
These don't crash serialization but leave orphaned entries in the project file.
Workaround
Clean up orphaned exception sets manually before saving:
proj.objects.select { |o|
o.isa == "PBXFileSystemSynchronizedBuildFileExceptionSet" &&
o.respond_to?(:target) && o.target.nil?
}.each { |o| o.remove_from_project }
Environment
- Ruby xcodeproj gem 1.27.0
- Project created with Xcode 26 beta (uses synchronized folders /
PBXFileSystemSynchronizedRootGroup) - Also reproduced via xcodeproj-mcp-server v1.5.0, which uses the Swift tuist/XcodeProj library — same crash (exit code 133 / SIGTRAP, the Swift equivalent of nil access)
- Lingua principale
- Swift
- Stelle
- 2.2k
- Fork
- 356
- Merge medio
- 5h 54m
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tuist/XcodeProj
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
New Xcode 26 formatAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
PBXProjEncoder crashes when sorting projectReferences if ProjectRef file element has nil nameForse già presa @Ant-tree l’ha presa 262 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Tutte le issue di tuist/XcodeProj
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
lognorman20/monaco#7428 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
🎉 Add BossanovaAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jaywcjlove/awesome-mac#4096 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] FluidMeet: Google Meet browser calls not detected after Meet moved rooms to /meet/<code>Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
altic-dev/FluidVoice#1264 ·
I maintainer di solito rispondono entro 1 giorno