extractInfoPlistBundleID extracts CFBundleIdentifier from Info.plist content. Returns empty string if absent or if the value is a build variable reference (e.g. "$(..)").
(content string)
| 579 | // extractInfoPlistBundleID extracts CFBundleIdentifier from Info.plist content. |
| 580 | // Returns empty string if absent or if the value is a build variable reference (e.g. "$(..)"). |
| 581 | func extractInfoPlistBundleID(content string) string { |
| 582 | matches := infoPlistBundleIDRegex.FindStringSubmatch(content) |
| 583 | if len(matches) < 2 { |
| 584 | return "" |
| 585 | } |
| 586 | id := strings.TrimSpace(matches[1]) |
| 587 | // Skip Xcode variable references such as "$(PRODUCT_BUNDLE_IDENTIFIER)". |
| 588 | if strings.Contains(id, "$") { |
| 589 | return "" |
| 590 | } |
| 591 | return id |
| 592 | } |
| 593 | |
| 594 | // gradleAppIDRegex matches applicationId in build.gradle (Groovy and Kotlin DSL forms). |
| 595 | var gradleAppIDRegex = regexp.MustCompile(`applicationId\s*=?\s*["']([a-zA-Z][a-zA-Z0-9._-]*)["']`) |