yonaskolb / yonaskolb/XcodeGen
`static.framework` is not completely treated as a framework by Xcode when building
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 8.8k
- Forks
- 908
- Avg merge
- 17d 14h
- Merged PRs (30d)
- 2
Description
I'm trying to have a project with mixed ObjC-Swift modules, using static frameworks.
I created a project.yml that describes:
- An app target with dependency on
ModuleAandModuleB ModuleAstatic framework with both Swift and ObjC code, with a dependency onModuleBModuleBstatic framework with both Swift and ObjC code
However, it seems like ModuleA and ModuleB are being treated as libraries with respect to some regards, with for example the generated interface <module-name>-Swift.h not being copied to the expected Products path (<ModuleName>.framework/Headers), and instead being copied to DerivedSource (just like it happens with static libraries) and so Xcode fails to find it with this error:

When taking a look at the build log, it becomes clear that the generated interface is being created, but being copied to DerivedSources instead of the expected <ModuleName>.framework/Headers:

If I remove the target generated by XcodeGen and create it from scratch using Xcode (as a dynamic framework but then manually change Mach-O type to static, specify modulemap, and then change embed to Do Not Embed in the app target), then everything works fine, and the copy path for the generated interface is the right one:

Also for some reason the icon shown in the build log is different. With the Xcode-created target, the icon is the framework one 🧳 (the suitcase), but with XcodeGen the icon is the target one 🎯 (not sure if this actually means anything...)
Also, when navigating to the Products folder, I noticed that the <ModuleName>.swiftmodule for the Xcode-created target is generated within the framework, however with the XcodeGen one, it's created outside of it:
Xcode-created target:

XcodeGen-created target:

Here's how the project.yml looks like:
name: XcodegenTest
options:
bundleIdPrefix: com.xcodegentest
deploymentTarget:
iOS: "14.0"
minimumXcodeGenVersion: 2.18.0
usesTabs: false
indentWidth: 4
tabWidth: 4
xcodeVersion: 12.0
targets:
XcodegenTest:
type: application
platform: iOS
info:
path: App/Info.plist
sources:
- path: App
dependencies:
- target: ModuleA
- target: ModuleB
ModuleA:
type: framework.static
platform: iOS
info:
path: ModuleA/Info.plist
sources:
- path: ModuleA
settings:
MODULEMAP_FILE: ModuleA/ModuleA.modulemap
dependencies:
- target: ModuleB
ModuleB:
type: framework.static
platform: iOS
info:
path: ModuleB/Info.plist
sources:
- path: ModuleB
settings:
MODULEMAP_FILE: ModuleB/ModuleB.modulemap
And this is the attached sample project:
XcodegenTest.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached XcodegenTest.zip and the project.yml configuration, then compare the generated project with the manually created Xcode target. Check the generated paths for the Swift interface, modulemap, and .swiftmodule; done means the mixed Swift/Objective-C static frameworks build with those products inside the expected framework directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c, swift, yaml
- Domain
- build-system, mobile-dev, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100