Skip to content

Default requiresObjCLinking to true for static frameworks - #1674

Merged
yonaskolb merged 1 commit into
yonaskolb:masterfrom
toyeshhm:fix-605-static-framework-objc-linking
Nov 24, 2026
Merged

yonaskolb merged 1 commit into
yonaskolb:masterfrom
toyeshhm:fix-605-static-framework-objc-linking

Conversation

@toyeshhm

Copy link
Copy Markdown
Contributor

Fixes #605.

Problem

requiresObjCLinking defaults to true for library.static, but not for static frameworks. An app that links a framework.static target doesn't get -ObjC, so the linker can drop Objective-C categories from that framework.

Root cause

The default only checks for the .staticLibrary product type. That check exists in two places: one for targets in the same project, and one for targets from an external project reference.

Fix

The default now uses the existing defaultLinkage == .static. This covers library.static, framework.static, and a framework with MACH_O_TYPE: staticlib.

For external targets, the value now stays nil unless OTHER_LDFLAGS is a string, so they go through the same default. Setting requiresObjCLinking: false still opts a target out. Docs/ProjectSpec.md describes the new default.

Tests

  • Extended sets -ObjC for targets that depend on requiresObjCLinking targets with a framework.static, a framework with MACH_O_TYPE: staticlib, an opted-out static framework, and a dynamic framework.
  • Added sets -ObjC for targets that depend on a static framework in an external project.

Both failed before the fix with false is not equal to true. swift test passes, and scripts/gen-fixtures.sh followed by scripts/diff-fixtures.sh shows no fixture changes.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@yonaskolb yonaskolb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @toyeshhm, this is a clean fix and the tests cover both the local and project-reference paths nicely. Reusing defaultLinkage so MACH_O_TYPE: staticlib frameworks are included too is a nice touch. Looks good to me!


Generated by Claude Code

@yonaskolb
yonaskolb merged commit 4abd425 into yonaskolb:master Nov 24, 2026
4 checks passed
yonaskolb pushed a commit that referenced this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should requiresObjCLinking be true for framework.static?

3 participants