Add support for generated Objective-C asset symbols#93
Open
Frank-728 wants to merge 2 commits intoonevcat:masterfrom
Open
Add support for generated Objective-C asset symbols#93Frank-728 wants to merge 2 commits intoonevcat:masterfrom
Frank-728 wants to merge 2 commits intoonevcat:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR extends FengNiao’s detection of generated asset symbols to Objective‑C and refactors string-to-symbol conversion to a shared helper. It ensures resources referenced via generated symbol constants (both Swift-style .name and Objective‑C-style ACImageNameFoo) are treated as used when scanning a project.
Why?
Projects that generate Objective‑C constants for assets (or use ObjC code referencing generated symbols) were previously not recognized, which could cause FengNiao to incorrectly mark used resources as unused. This PR closes that gap and consolidates the conversion logic to reduce duplication.
What changed?
Introduced convertToCamelCase(prefix:uppercaseFirst:) to centralize camel-case conversions.
Simplified generatedAssetSymbolKey and added objcGeneratedAssetSymbolKey for Objective‑C symbol names (e.g. ACImageNameIcFlag).
Detect resources referenced by generated symbols in both Swift (.name) and Objective‑C (ACImageName...).
Broadened member-access search to consider Objective‑C file extensions (.m, .mm, .h) and dispatch per-file to the appropriate search rule.
Added ObjCMemberAccessSearchRule to find Objective‑C generated symbol constants (e.g. ACImageNameIcFlag).
Added unit tests for ObjCMemberAccessSearchRule and for objcGeneratedAssetSymbolKey in SearchRuleTests.swift and StringExtensionsTests.swift.
Compatibility & notes?
Backward compatible: existing Swift detection remains unchanged; Objective‑C detection is additive.
A private helper was added; public APIs are unaffected.
Tests added to cover new behavior—please run the test suite and try scanning a sample project that contains Objective‑C references to generated asset symbols.