Skip to content

fix(ios): retain Objective-C classes in Xcode builds - #5915

Open
mortenolsrud wants to merge 2 commits into
wailsapp:masterfrom
mortenolsrud:fix/ios-objc-linker-flag
Open

fix(ios): retain Objective-C classes in Xcode builds#5915
mortenolsrud wants to merge 2 commits into
wailsapp:masterfrom
mortenolsrud:fix/ios-objc-linker-flag

Conversation

@mortenolsrud

@mortenolsrud mortenolsrud commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

Generated iOS Xcode projects link the Go c-archive without -ObjC. Because WailsAppDelegate is referenced by class name through UIApplicationMain, the linker can omit the archive member that contains the Objective-C class. The generated app can then crash at launch with:

No class named WailsAppDelegate is loaded.

This adds -ObjC to OTHER_LDFLAGS for both Debug and Release configurations in the generated Xcode project. $(inherited) is retained so project or environment linker flags continue to compose normally.

A regression test renders the project template and verifies that both build configurations independently contain the linker setting.

Fixes #5913.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • go test -count=1 ./internal/commands
  • Rendered-project regression coverage for both Debug and Release.
  • Reviewed the generated pbxproj syntax and linker behavior against the existing Go c-archive integration.

Honest caveat: the generated project was not launched on an iOS device or simulator from this Linux host.

  • Windows
  • macOS
  • Linux

Test Configuration

  • Go: go1.26.5
  • OS: Ubuntu 24.04.4 LTS, amd64

Checklist:

  • (v2 only) I have updated website/src/pages/changelog.mdx with details of this PR (v3 changelog entries are added automatically) — n/a (v3)
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes

    • Improved iOS builds to preserve existing linker settings and reliably include Objective-C classes.
    • Applied the linker configuration consistently to both Debug and Release builds.
  • Tests

    • Added coverage to verify the iOS project configurations contain the expected linker settings without duplication.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b2cd1901-7402-4df2-b460-c3f03b9c5ec1

📥 Commits

Reviewing files that changed from the base of the PR and between f80dad5 and 06e0efd.

📒 Files selected for processing (2)
  • v3/internal/commands/ios_xcode_gen_test.go
  • v3/internal/commands/updatable_build_assets/ios/project.pbxproj.tmpl

Walkthrough

The iOS Xcode project template now adds inherited linker flags and -ObjC to Debug and Release configurations. A test renders the template and verifies both configurations contain the expected linker flags exactly once.

Changes

iOS linker configuration

Layer / File(s) Summary
Configure and validate Objective-C retention
v3/internal/commands/updatable_build_assets/ios/project.pbxproj.tmpl, v3/internal/commands/ios_xcode_gen_test.go
Debug and Release configurations preserve inherited linker flags and add -ObjC. The test verifies each configuration contains one linker-flag block with both values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: leaanthony

Poem

A rabbit checks the flags with care,
-ObjC now waits inside there.
Debug hops, Release follows,
Classes stay through linker shadows.
Xcode launches bright and fair.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the iOS Xcode linker fix and the retained Objective-C classes.
Description check ✅ Passed The description covers the cause, fix, linked issue, testing, environment, caveat, and checklist status.
Linked Issues check ✅ Passed The changes add -ObjC and preserve $(inherited) in both configurations, with tests covering the issue requirements.
Out of Scope Changes check ✅ Passed The changes are limited to the iOS project template and its regression test, with no unrelated scope detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

v3 mobile (iOS): generated Xcode project is missing -ObjC linker flag, crashes at launch on real devices/Simulator

2 participants