XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Not embedding project reference targets in multiple targets

Open duarteffc opened this issue 4 years ago • 14 comments

I have a project reference to be embedded in my main project, using its targets, but it only gets embedded in one target.

projectReferences:
  MyProject:
    path: Projects/MyProject/MyProject.xcodeproj

Targets:

MyTarget:
  dependencies:
      - target: MyProject/MyProject
        link: true
        embed: true

MyTargetOne:
  dependencies:
      - target: MyProject/MyProject
        link: true
        embed: true

Only one of the targets embeds the dependency.

duarteffc avatar Aug 13 '20 15:08 duarteffc

This is happening with my project too 😕

MatheusMBispo avatar Oct 16 '20 14:10 MatheusMBispo

For me too. The depended targets are embedded only on the alphabetical sorted first target. I have 4 targets, which are defined by a template. The template define the dependencies. The dependencies are only embedded in the first target.

officebluesource avatar Oct 30 '20 10:10 officebluesource

Could I ask this is intended spec.. or bug? Are there any updates?

mqzkim avatar May 18 '21 07:05 mqzkim

This is not intended behaviour, and should be treated a bug. I haven't had a chance to look into this. PR's welcome, even if all the PR does is add a test case that demonstrates this.

yonaskolb avatar May 18 '21 11:05 yonaskolb

I just made a project which can reproduce this bug 100%. When I add a file in TargetExample target, Core framework disappeared.

(cf. When I made the application target to top order of targets in project, the bug doesn't occur. -> ex. If I change the name TargetExample to 000_TargetExample, Core framework doesn't disappear.)

https://github.com/mqzkim/xcodegen-test

Here are project.yml files below.

Core/project.yml

name: Core
options:
  bundleIdPrefix: com.xcodgentest
targets:
  Core:
    sources: Core
    type: framework
    platform: iOS
    deploymentTarget: "11.0"

Target/project.yml

name: Target
options:
  bundleIdPrefix: com.xcodgentest
projectReferences:
  Core:
    path: ../Core/Core.xcodeproj
targets:
  Target:
    sources: Target
    type: framework
    platform: iOS
    deploymentTarget: "11.0"
    dependencies:
      - target: Core/Core
  TargetExample:
    sources: TargetExample
    type: application
    platform: iOS
    deploymentTarget: "12.0"
    dependencies:
      - target: Target
      - target: Core/Core

mqzkim avatar Jul 19 '21 06:07 mqzkim

스크린샷 2021-07-19 오후 3 36 02

This is a screenshot from Target.xcodeproj/project.pbxproj file. Products has two Core.framework files with different hash. When I removed one of Core.framework file reference and related codes(38C96BECA2E477A652351E8D), the bug not occurred.

mqzkim avatar Jul 19 '21 06:07 mqzkim

This is not intended behaviour, and should be treated a bug. I haven't had a chance to look into this. PR's welcome, even if all the PR does is add a test case that demonstrates this.

@yonaskolb I just added PR with test case. #1108 Thanks.

mqzkim avatar Jul 19 '21 18:07 mqzkim

Hi, guys! Could you finish this bug fix? The issue is very annoying 😩

ildar-gilfanov avatar Aug 23 '21 14:08 ildar-gilfanov

This might be related to https://github.com/yonaskolb/XcodeGen/issues/1017 ?

mthole avatar Sep 22 '21 21:09 mthole

Hi, I have an xcodeproject and I am migrating it using xcodegen. I too have the same issue that is only one of the targets embeds the dependency. However, if I open the original project and generate the new one. I don't have the problem. Could you please let me know the possible reason and the way to overcome this issue without openening original xcodeproject.

Thanks.

kbhavyas avatar Mar 03 '22 11:03 kbhavyas

I found a solution:

original code:

MyTarget:
  dependencies:
      - target: MyProject/MyProject
        link: true
        embed: true

MyTargetOne:
  dependencies:
      - target: MyProject/MyProject
        link: true
        embed: true

CHANGE TO:

MyTarget:
  dependencies:
      - framework: MyProject/MyProject
        implicit: true
        link: true
        embed: true

MyTargetOne:
  dependencies:
      - framework: MyProject/MyProject
        implicit: true
        link: true
        embed: true

change target to framework, and add implicit: true work well for me.

zencodex avatar Apr 06 '22 14:04 zencodex

I can take an other look at this. I would really love to fix this issue. Anyone has more information before I start a deep dive on this? https://github.com/yonaskolb/XcodeGen/pull/1108#issuecomment-1470897451

simonpierreroy avatar Mar 15 '23 21:03 simonpierreroy

@zencodex, thank you for sharing. Why do you think your workaround works?

ajRiverav avatar Aug 06 '23 17:08 ajRiverav

Also, in case somebody knows -> https://github.com/yonaskolb/XcodeGen/issues/1017#issuecomment-1666942673 @yonaskolb

ajRiverav avatar Aug 06 '23 18:08 ajRiverav