yonaskolb / yonaskolb/XcodeGen

Consistency issue: unexpected multiple parents for object `xcconfig`

Open
#771 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
8.8k
Forks
908
Avg merge
17d 14h
Merged PRs (30d)
2

Description

When using custom xcconfigs at the project level, it seems that Xcodegen generates an orphaned group for the xcconfigs, which causes CocoaPods to fail until the project file is "fixed" by Xcode.

For example, given the following project.yml:

name: PRODUCTNAME
options:
  bundleIdPrefix: com.rightpoint
packages:
  BonMot:
    url: https://github.com/Rightpoint/BonMot.git
    from: 5.5.0
  Anchorage:
    url: https://github.com/Rightpoint/Anchorage.git
    from: 4.4.0
configs:
  Debug: debug
  Develop: release
  Sprint: release
  AppStore: release
configFiles:
  Debug: PRODUCTNAME/Resources/xcconfig/Debug.xcconfig
  Develop: PRODUCTNAME/Resources/xcconfig/Develop.xcconfig
  Sprint: PRODUCTNAME/Resources/xcconfig/Sprint.xcconfig
  AppStore: PRODUCTNAME/Resources/xcconfig/AppStore.xcconfig
targets:
  PRODUCTNAME:
    type: application
    platform: iOS
    deploymentTarget: "12.0"
    sources: [PRODUCTNAME]
    dependencies:
      - target: Services
      - package: BonMot
      - package: Anchorage
  PRODUCTNAMETests:
    type: bundle.unit-test
    platform: iOS
    deploymentTarget: "12.0"
    sources: [PRODUCTNAMETests]
    dependencies:
      - target: Services
  Services:
    type: framework
    platform: iOS
    sources: [Services]

It will generate an Xcode project that is deemed invalid by the Xcodeproj gem:

$ bundle exec pod install
...
RuntimeError - [Xcodeproj] Consistency issue: unexpected multiple parents for object `xcconfig`: [<PBXGroup path=`Resources` UUID=`42D132E167CA6DBCCDED2615`>, <PBXGroup UUID=`65C752E3E9E65C0DF852998A`>]

Curiously, if you simply open the PRODUCTNAME.xcodeproj in Xcode, change any setting back and forth, and then run pod install again, it succeeds. It looks like this is because Xcode does some sort of error correction on the generated project file. Here's an interesting part of the diff.

-                               F1BE11E77973887FDB838436 /* xcconfig */,

Although this is sort of an issue at the intersection of XcodeGen and CocoaPods - because allowing Xcode to auto-fix the project file fixes the CocoaPods/Xcodeproj issue - I think that ultimately this is a defect in XcodeGen.

Workaround
  • Open generated .xcodeproj file in Xcode, change any setting back and forth to allow Xcode to fix the orphaned group
  • Another workaround, inspired by: https://github.com/yonaskolb/XcodeGen/issues/647 Move all xcconfig files to a folder in the root of the repository, for instance: PRODUCTNAME/Resources/xcconfig/ ====> xcconfig/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the project.yml example's project-level configFiles and inspect the generated .xcodeproj structure, comparing it with the Xcode-corrected diff shown in the issue. Reproduce with pod install and verify that the generated project has no orphaned or multiply-parented xcconfig object and is accepted without opening it in Xcode.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.