yonaskolb / yonaskolb/XcodeGen

`static.framework` is not completely treated as a framework by Xcode when building

Open
#1,030 3 comments 1 reaction 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'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 ModuleA and ModuleB
  • ModuleA static framework with both Swift and ObjC code, with a dependency on ModuleB
  • ModuleB static 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:
Screen Shot 2021-02-24 at 10 26 56

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:
Screen Shot 2021-02-24 at 10 39 39

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:
Screen Shot 2021-02-24 at 10 43 30

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:
Screen Shot 2021-02-24 at 11 21 19

XcodeGen-created target:
Screen Shot 2021-02-24 at 11 21 50

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.