yonaskolb / yonaskolb/XcodeGen

Project w/ 2 app targets loses linked libraries to 2nd app after Xcode modification

Open
#1,017 7 comments 4 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

I have a moderately complex XcodeGen set up involving multiple internal libraries/frameworks and produces multiple application targets. It works great, until you try to modify the project in Xcode (e.g. by adding a new file). Xcode then ends up stripping the libraries from all but the first application target(!)

Simplified Reproduction

I've created a simplified example project to illustrate the issue:
XcodeGenBugExample.zip

  1. Download the .zip, use make to run xcodegen on the 3 included projects
➜  XcodeGenBugExample
 make
⚙️  Generating plists...
⚙️  Generating project...
⚙️  Writing project...
Created project at /Users/mthole/XcodeGenTest/LibraryA/LibraryA.xcodeproj
⚙️  Generating plists...
⚙️  Generating project...
⚙️  Writing project...
Created project at /Users/mthole/XcodeGenTest/LibraryB/LibraryB.xcodeproj
⚙️  Generating plists...
⚙️  Generating project...
⚙️  Writing project...
Created project at /Users/mthole/XcodeGenTest/App/App.xcodeproj
  1. Open the App.xcodeproj, and examine the App1 and App2 targets. They both link to the libLibraryA.a and libLibraryB.a libraries. All is well.

image
image

  1. Go and add a new .swift file to the App target. (Or do a number of other Xcode operations that trigger whatever re-evaluation is happening...). I added File.swift to the App1 and App2 targets.

  2. Examine the App1 and App2 targets. Notice that App2 is now missing both libLibraryA.a and libLibraryB.a. Sadface!

image
image

We expect App1 and App2 to still be linked to both libraries. Mysteriously, only App1 is!?

Next Steps

I've been using Xcode 12.4. If anyone has any ideas, I'm happy to help investigate further here.

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

Use the attached XcodeGenBugExample.zip and run make to generate the three projects, then inspect App.xcodeproj with its App1 and App2 targets. Reproduce the issue by adding a Swift file to both targets in Xcode; done means both targets still link libLibraryA.a and libLibraryB.a after the modification.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.