Skip to content

fix(darwin): sanitize CFBundleIdentifier to comply with Apple requirements#5231

Merged
leaanthony merged 2 commits into
masterfrom
fix/4866-plist-bundle-id-sanitize
May 31, 2026
Merged

fix(darwin): sanitize CFBundleIdentifier to comply with Apple requirements#5231
leaanthony merged 2 commits into
masterfrom
fix/4866-plist-bundle-id-sanitize

Conversation

@leaanthony

@leaanthony leaanthony commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a safeBundleID template function that lowercases and replaces non-alphanumeric characters with hyphens
  • Updates CFBundleIdentifier in both plist templates to use {{safeBundleID .Name}}
  • Ensures bundle identifiers like com.wails.My Fab Application become com.wails.my-fab-application

Test

  • v2/pkg/buildassets/safebundleid_test.go — tests various inputs including spaces, special chars, underscores

Fixes #4866

Summary by CodeRabbit

  • Bug Fixes

    • macOS app bundle identifiers are now properly formatted and sanitized during generation to prevent invalid identifiers.
  • Tests

    • Added comprehensive test coverage for bundle identifier sanitization logic.

…ments

CFBundleIdentifier was generated as com.wails.{{.Name}} which could
contain spaces and special characters, violating Apple's requirement
that bundle identifiers only contain [A-Za-z0-9.-].

Add a safeBundleID template function that lowercases and replaces
non-alphanumeric runs with hyphens, then strips leading/trailing
dashes. Applied to both Info.plist and Info.dev.plist templates.

Fixes #4866
@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a9b96a69-3868-47ff-8e5d-96469810967e

📥 Commits

Reviewing files that changed from the base of the PR and between ce6a836 and 5984412.

📒 Files selected for processing (4)
  • v2/pkg/buildassets/build/darwin/Info.dev.plist
  • v2/pkg/buildassets/build/darwin/Info.plist
  • v2/pkg/buildassets/buildassets.go
  • v2/pkg/buildassets/safebundleid_test.go

Walkthrough

The PR fixes macOS bundle identifier compliance by introducing a safeBundleID helper function that normalizes app names to Apple's alphanumeric-hyphen-period requirements, registering it with the template function map, and updating both Info.plist and Info.dev.plist templates to apply the sanitization during rendering.

Changes

Bundle ID Sanitization

Layer / File(s) Summary
Safe bundle ID helper and template function registration
v2/pkg/buildassets/buildassets.go, v2/pkg/buildassets/safebundleid_test.go
safeBundleID helper function normalizes identifiers by lowercasing, replacing non-alphanumerics with -, and trimming dashes. resolveProjectData registers safeBundleID and xmlEscape in a template.FuncMap for use in template expressions. Table-driven tests cover normalization scenarios including spaces, underscores, mixed case, and leading/trailing dashes.
Apply safe bundle ID to macOS Info.plist templates
v2/pkg/buildassets/build/darwin/Info.plist, v2/pkg/buildassets/build/darwin/Info.dev.plist
CFBundleIdentifier template expressions updated from com.wails.{{.Name}} to com.wails.{{safeBundleID .Name}} in both production and dev Info.plist templates, ensuring generated bundle identifiers comply with Apple's requirements.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Bug

Poem

🐰 Happy hop through bundle names,
Spaces trimmed and dashes tamed,
Apple's rules now all aligned,
macOS packages, sanitized and signed!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4866-plist-bundle-id-sanitize

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 and usage tips.

@leaanthony

Copy link
Copy Markdown
Member Author

🤖 PR Triage Review

Accepted

Sanitizes CFBundleIdentifier to comply with Apple packaging requirements. Important for App Store distribution.

Platform: macOS (v2-only)

Next Steps: Dispatching for Mac testing.


Reviewed by Wails PR Reviewer Bot

@leaanthony leaanthony marked this pull request as ready for review May 31, 2026 12:50
Copilot AI review requested due to automatic review settings May 31, 2026 12:50
@leaanthony leaanthony merged commit 230a627 into master May 31, 2026
12 of 15 checks passed
@leaanthony leaanthony deleted the fix/4866-plist-bundle-id-sanitize branch May 31, 2026 12:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wails' default Info.plist configuration can result in broken macOS packaging

2 participants