yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project
MIT License
6.92k stars 810 forks source link

"file reference member of multiple groups" warning in Xcode 10 #405

Open LinusU opened 5 years ago

LinusU commented 5 years ago

After upgrading to Xcode 10, I'm getting the following warning when building my project:

2018-09-19 13:29:32.267 xcodebuild[17317:5682171] warning:  The file reference for "Sources/Components" is a member of multiple groups ("Sources" and ""); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
2018-09-19 13:29:32.267 xcodebuild[17317:5682171] warning:  The file reference for "Sources/Coordinators" is a member of multiple groups ("Sources" and ""); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
2018-09-19 13:29:32.267 xcodebuild[17317:5682171] warning:  The file reference for "Sources/Extensions" is a member of multiple groups ("Sources" and ""); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
2018-09-19 13:29:32.287 xcodebuild[17317:5682171] warning:  The file reference for "Sources/Pages" is a member of multiple groups ("Sources" and ""); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
2018-09-19 13:29:32.287 xcodebuild[17317:5682171] warning:  The file reference for "Sources/Stores" is a member of multiple groups ("Sources" and ""); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.

My directory structure looks like this:

Sources/
  Components/
    *.swift
  Coordinators/
    *.swift
  Extensions/
    *.swift
  Pages/
    *.swift
  Stores/
    *.swift
  *.swift
project.yml
yonaskolb commented 5 years ago

Hi @LinusU. Was your version of XcodeGen compiled with Swift 4.2?

LinusU commented 5 years ago

I'm getting the warning both on a version compiled with an older version (I guess Swift 4.1, XcodeGen version 1.7.0), and with the newer version 1.11.2 compiled with Swift 4.2.

yonaskolb commented 5 years ago

Could you share some more details of your spec? Do multiple targets use the same source paths? Better yet if you could submit a PR to the TestProject fixture that highlighted the issue, even better šŸ˜„šŸ‘

LinusU commented 5 years ago

Sorry for the lack of detail ā˜ŗļø

I have multiple targets that use the same paths, it looks something like this (very simplified):

name: Ctrlpanel
options:
  bundleIdPrefix: com.ctrlaltdeseat
targets:
  Ctrlpanel:
    type: application
    platform: iOS
    deploymentTarget: "12.0"
    sources:
      - path: Sources
        excludes:
          - AppInfo.plist
          - Coordinators/FindLogin.swift
          - CredentialProvider.swift
          - CredentialProviderInfo.plist
    settings:
      INFOPLIST_FILE: Sources/AppInfo.plist
    dependencies:
      - target: CredentialProvider
  CredentialProvider:
    type: app-extension
    platform: iOS
    deploymentTarget: "12.0"
    sources:
      - path: Sources/Assets.xcassets
      - path: Sources/Constants.swift
      - path: Sources/Coordinators/FindLogin.swift
      - path: Sources/CredentialProvider.swift
      - path: Sources/LaunchScreen.storyboard
      - path: Sources/Pages/AccountList.swift
      - path: Sources/Pages/Unlock.swift
      - path: Sources/Settings.swift
      - path: Sources/Stores/Auth.swift
    settings:
      INFOPLIST_FILE: Sources/CredentialProviderInfo.plist

I'll try and submit a PR as soon as I get some time šŸ‘

yonaskolb commented 5 years ago

@LinusU is this still an issue for you?

LinusU commented 5 years ago

Yes, sorry for not providing more info šŸ˜“

Still an issue in 2.0.0

LinusU commented 5 years ago

Hmm, I tried to reproduce it here, but haven't been able to yet šŸ¤”

https://github.com/yonaskolb/XcodeGen/compare/master...LinusU:warning-test-case

LinusU commented 5 years ago

Really went down the rabbit hole on this one. The bug is only triggered with certain app names šŸ˜‚

e.g. Ctrlpanel and Ctrlalala triggers the behaviour, but AppWithExtension and BiBaBo doesn't šŸ˜®

edit: DishWasher triggers the bug, but AishWasher doesn't, seems to have something to do with lexicographical ordering šŸ¤”

edit2: Credentiaq triggers the bug, but Crendetiaa doesn't šŸ˜‚

LinusU commented 5 years ago

@yonaskolb okay, I've added a test case here: https://github.com/yonaskolb/XcodeGen/compare/master...LinusU:warning-test-case

I did the following to see it:

cd Tests/Fixtures/TestProject
mint run yonaskolb/xcodegen
xcodebuild -project Project.xcodeproj -target Zapp -quiet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

The first line of the output is the warning

grigorye commented 4 years ago

I was able to workaround this by adding createIntermediateGroups: true option to the (root) options section of .yml.

xxi511 commented 1 year ago

Just have this issue.
In my case, it is caused by typo.
e.g. some place is Sources/Components and some place is Sources/components