BUG - addTargetDependency - If project doesn't contain PBXTargetDependency or PBXContainerItemProxy
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- ios, javascript, nodejs
Direzione di ricerca
Inizia in lib/pbxProject.js, in corrispondenza di addTargetDependency, e controlla la suite di test esistente per verificare la copertura di addTarget o addTargetDependency. Riproduci il caso di un .xcodeproj con un singolo Target senza PBXTargetDependency o PBXContainerItemProxy, quindi aggiungi un test di regressione. Il lavoro è completato quando le dipendenze vengono create o elaborate correttamente e i test esistenti continuano a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
One Line Summary
addTargetDependency misses some dependency links if PBXTargetDependency or PBXContainerItemProxy are not present.
Affected Projects
Calls made to addTarget or addTargetDependency with any .xcodeproj that only has one target, these do NOT have PBXTargetDependency or PBXContainerItemProxy.
Details
The root cause
The following if statement in the addTargetDependency function skips the dependencies and other steps if it is missing.
https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
Possible fixes
Option 1 - Smallest number changes
A simple way to fix this would be to use short-circuit evaluation where these vars are assigned to handle null, undefined, or if no key exists when reading from hash.project.objects.
https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L834-L835
This could become the following to fix this issue:
pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency] || {},
pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy] || {};
I have tested this on some projects on my machine and was able to successfully run an App Extension on an iOS device to confirm the solution works.
Option 2 - Larger Refactor - Fix some clean up
Same fix as option 1, but clean up the hard coded strings.
- Put these at the top of the file:
const PBX_TARGET_DEPENDECY = "PBXTargetDependency";
const PBX_CONTAINER_ITEM_PROXY = "PBXContainerItemProxy";
- Use them here and remove the old vars:
const pbxTargetDependencySection = this.hash.project.objects[PBXTargetDependency] || {};
const pbxContainerItemProxySection = this.hash.project.objects[PBXContainerItemProxy] || {};
Workaround
// Add code anytime before calling addTarget or addTargetDependency
const projObjects = xcodeProject.hash.project.objects;
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
Related issues
PR #12 also made a note of this issue:
2.
addTargetDependency()is indirectly called as well fromproj.addTarget('AppExtension', 'app_extension'). In my project,PBXTargetDependencyandPBXContainerItemProxysections did not yet exist which results in the necessary dependencies not being set up properly for building the extension with the main app. Create these sections if they do not exist.
They attempted to fix this in a similar way I am suggesting with commit 2e09d78efdb1d667dd513a3c97c46dc448305f5f.
This PR was not merged however, so this is still an active issue.
There is another issue #37, that references PR #12, notes that targetDependency is still an issue.
Submitting a PR - Is this an active library?
It has been over a year since there has been a release or even a commit. If the maintainers could chime in I'd be happy to create one.
I have read the CONTRIBUTING.md guide, is there any more to it than that? I see there is a good number of tests, I'll make sure to add one to cover the code change. Lastly let me know which of the possible fixes you prefer or if you have another idea.
- Lingua principale
- JavaScript
- Stelle
- 217
- Fork
- 102
- Merge medio
- 2g 9h
- PR unite (30g)
- 8
Guida per i contributori
Apri la 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 apache/cordova-node-xcode
-
Add & Improve JSDocs Apertaenhancement
apache/cordova-node-xcode#171 · 1 assegnatario ·
-
🔖 New release Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
apache/cordova-node-xcode#162 · 4 commenti · 2 reazioni ·
-
Install .xcframework Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 28/100
apache/cordova-node-xcode#139 · 2 commenti ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
apache/cordova-node-xcode#138 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
apache/cordova-node-xcode#137 · 2 reazioni ·
Tutte le issue di apache/cordova-node-xcode
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Theme loads third-party resources on every page (jsdelivr web font, cdnjs Font Awesome) – GDPR Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
docToolchain/docToolchain#1705 ·
-
Timezone select lists one option per character; duplicate "Failed" reason; shared tracker popover id Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
nightscout/nocturne#1414 ·
-
bug v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modelcontextprotocol/inspector#2458 · 1 commento ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
carbon-design-system/ibm-products#9907 ·