Skip to content

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

Description

@mgueregath

Description

A real app (backend Go service + plain HTML/JS frontend) built for iOS via `wails3 ios xcode:gen` + Xcode crashes immediately on launch, on both the Simulator and (presumably, untested) real devices, with:

```
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'Unable to instantiate the UIApplication delegate instance. No class named WailsAppDelegate is loaded.'
```

Root cause

The Go c-archive (`bin/*.a`) genuinely contains `WailsAppDelegate` — confirmed with `nm bin/app.a | grep WailsAppDelegate`, both the class and its methods are present in the archive. But `main.m` (also generated by `wails3 ios xcode:gen`) looks it up by string, not by C symbol:

```objc
return UIApplicationMain(argc, argv, nil, @"WailsAppDelegate");
```

The linker has no direct symbol reference to force it to keep the Objective-C class metadata from the static archive, so with `-dead_strip` (which the generated project's Ld step uses) it gets stripped. This is the classic "`-ObjC` linker flag required when using `NSClassFromString`/string-based class lookup against a static library" issue — well documented Apple platform behavior, not specific to this project, but the generated `.pbxproj` doesn't set it.

Reproduction

  1. `wails3 init -t vanilla`, then set up for iOS per the mobile guide.
  2. `wails3 ios overlay:gen` + `wails3 ios xcode:gen` (both work fine on `v3.0.0-beta.4` — no complaints about the CLI itself).
  3. Build in Xcode (Debug, Simulator or device) — build succeeds.
  4. Install + launch — instant crash with the exception above.
  5. `grep OTHER_LDFLAGS build/ios/xcode/main.xcodeproj/project.pbxproj` → no match.

Fix

Add `OTHER_LDFLAGS = "-ObjC";` to the generated `project.pbxproj`'s Debug/Release `XCBuildConfiguration` blocks (or wherever the template for that lives — I patched it locally in my own project's build script rather than in the Wails source, so I don't have a ready-made PR for this one).

Verification

After manually adding `OTHER_LDFLAGS = "-ObjC";` to the generated project, the same app installs and launches successfully in the iOS Simulator, rendering the actual app UI. Screenshot-verified, not just log inspection.

Environment

  • wails3 CLI: v3.0.0-beta.4
  • github.com/wailsapp/wails/v3: v3.0.0-beta.4
  • Go: go1.26.3 darwin/arm64
  • macOS 26.6, Xcode 26.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingP1High priorityv3v3-alpha

    Type

    No type

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions