{"owner":"marmelroy","repo":"PhoneNumberKit","hasSkills":true,"totalSkillsCount":1,"totalTokensCount":1443,"categories":["claude-rule"],"hasMcp":false,"mcpConfig":null,"found":["CLAUDE.md"],"skills":{"CLAUDE.md":"# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Project Overview\n\nPhoneNumberKit is a Swift framework for parsing, formatting, and validating international phone numbers. It's inspired by Google's libphonenumber and supports iOS, macOS, tvOS, and watchOS platforms.\n\n## Common Commands\n\n### Testing\n```bash\n# Run tests via Swift Package Manager (works on Linux and macOS)\nswift test\n\n# Run tests for iOS using Xcode\nxcodebuild test -scheme PhoneNumberKit -destination 'platform=iOS Simulator,name=iPhone 15'\n\n# Run tests for macOS using Xcode\nxcodebuild test -scheme PhoneNumberKit-macOS -destination 'platform=macOS'\n```\n\n### Building\n```bash\n# Build via Swift Package Manager\nswift build\n\n# Build for iOS (Carthage-style)\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit -destination 'generic/platform=iOS' build\n\n# Build for macOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-macOS -destination 'generic/platform=macOS' build\n\n# Build for tvOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-tvOS -destination 'generic/platform=tvOS' build\n\n# Build for watchOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-watchOS -destination 'generic/platform=watchOS' build\n```\n\n### CocoaPods\n```bash\n# Validate podspec\npod lib lint PhoneNumberKit.podspec\n\n# Push to CocoaPods trunk\npod trunk push PhoneNumberKit.podspec\n```\n\n### Metadata Updates\n```bash\n# Update phone number metadata from Google's libphonenumber (requires Python 3.12+ and xmljson)\ncd PhoneNumberKit/Resources && sh ./update_metadata.sh\n```\n\n## Architecture\n\n### Core Components\n\n**PhoneNumberUtility** (PhoneNumberKit/PhoneNumberUtility.swift)\n- The main entry point for all phone number operations\n- Relatively expensive to allocate (parses and keeps metadata in memory)\n- Should be instantiated once and reused throughout the app lifecycle\n- Provides parsing, formatting, validation, and country/region code queries\n\n**PhoneNumber** (PhoneNumberKit/PhoneNumber.swift)\n- Immutable struct representing a parsed phone number\n- Contains: numberString, countryCode, leadingZero, nationalNumber, numberExtension, type, regionID\n- Implements Equatable, Hashable, and Codable\n\n**MetadataManager** (PhoneNumberKit/MetadataManager.swift)\n- Loads and manages phone number metadata from PhoneNumberMetadata.json\n- Maintains dictionaries for fast lookup by country code and country ID\n- Handles territories with multiple countries sharing calling codes (e.g., NANPA)\n\n**PhoneNumberParser** (PhoneNumberKit/PhoneNumberParser.swift)\n- Internal parser handling normalization, extraction, and validation\n- Strips international/national prefixes and extensions\n- Determines phone number type (mobile, fixed line, etc.)\n\n**ParseManager** (PhoneNumberKit/ParseManager.swift)\n- Coordinates between parser and metadata manager\n- Handles single and batch parsing operations\n\n### Formatting Components\n\n**Formatter** (PhoneNumberKit/Formatter.swift)\n- Formats PhoneNumber objects to different formats: E164, international, national\n\n**PartialFormatter** (PhoneNumberKit/PartialFormatter.swift)\n- Provides as-you-type formatting for user input\n- Used internally by PhoneNumberTextField\n- Only available on platforms with ObjectiveC support (not available on Linux)\n\n### UI Components (iOS only)\n\n**PhoneNumberTextField** (PhoneNumberKit/UI/PhoneNumberTextField.swift)\n- Custom UITextField with automatic phone number formatting\n- Features: flag display, example placeholder, prefix handling\n- Integrates PartialFormatter for real-time formatting\n\n**CountryCodePickerViewController** (PhoneNumberKit/UI/CountryCodePickerViewController.swift)\n- Country code picker UI for PhoneNumberTextField\n- Customizable via CountryCodePickerOptions\n\n## Key Design Patterns\n\n### Metadata Loading\n- Metadata is loaded once during PhoneNumberUtility initialization via a callback\n- Default callback reads from bundled PhoneNumberMetadata.json\n- Custom metadata sources can be provided via metadataCallback parameter\n\n### Region Detection\n- Uses CNContactsUserDefaults.shared().countryCode for iOS 12+\n- Falls back to Locale.current for region detection\n- Handles edge cases (e.g., Korean language on macCatalyst returns \"ko\" instead of \"kr\")\n\n### Type Validation\n- Parser checks number against metadata patterns for each phone type\n- Can be skipped via `ignoreType` parameter for performance\n- Type hierarchy: specific types (mobile, pager, etc.) → fixedOrMobile → unknown\n\n### Performance Optimization\n- Batch parsing with `parse(_:withRegion:ignoreType:)` for arrays\n- Regex patterns are cached in RegexManager\n- Metadata dictionaries provide O(1) lookup by code/country\n\n## Platform Specifics\n\n### Swift Package Manager\n- Target: `PhoneNumberKit` at PhoneNumberKit/\n- Resources: PhoneNumberMetadata.json, PrivacyInfo.xcprivacy\n- Test target: `PhoneNumberKitTests` at PhoneNumberKitTests/\n- Supports iOS 12+, macOS 10.13+, tvOS 12+, watchOS 4+\n\n### CocoaPods\n- Two subspecs: PhoneNumberKitCore (core parsing) and UIKit (UI components)\n- UIKit subspec requires iOS 12+ and depends on PhoneNumberKitCore\n\n### Xcode Project\n- Schemes: PhoneNumberKit (iOS), PhoneNumberKit-macOS, PhoneNumberKit-tvOS, PhoneNumberKit-watchOS\n- No workspace file (uses .xcodeproj directly)\n- Example apps in examples/ directory (AsYouType, PhoneBook)\n\n### UI Components\n- Only available on iOS (guarded by `#if os(iOS)`)\n- PhoneNumberTextField requires UIKit\n\n## Testing Strategy\n\n- Tests in PhoneNumberKitTests/ directory\n- Run via `swift test` for SPM (works on both Linux and macOS)\n- Run via xcodebuild for platform-specific tests\n- CI runs tests on both Linux and macOS using `swift test`\n- CI also validates builds for iOS and macOS using xcodebuild\n\n## Metadata Updates\n\n- Metadata comes from Google's libphonenumber project\n- Update script: PhoneNumberKit/Resources/update_metadata.sh\n- Automated via GitHub Actions workflow (.github/workflows/update_metadata.yml)\n- Runs every 12 hours and can be triggered manually\n- Requires Python 3.12+ with xmljson package installed\n- Creates PRs automatically when new metadata versions are available\n\n## Important Notes\n\n- PhoneNumber objects should be created via PhoneNumberUtility, not directly (deprecated initializers will fail)\n- PhoneNumberUtility instances should be reused, not recreated frequently (they're expensive to allocate)\n- PartialFormatter requires ObjectiveC support (not available on Linux)\n- The `ignoreType` parameter can significantly improve parsing performance when type validation isn't needed\n- For batch operations, use the array parsing method for better performance\n- All builds in CI use `set -o pipefail` to catch errors in piped commands\n"},"files":{"CLAUDE.md":"# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Project Overview\n\nPhoneNumberKit is a Swift framework for parsing, formatting, and validating international phone numbers. It's inspired by Google's libphonenumber and supports iOS, macOS, tvOS, and watchOS platforms.\n\n## Common Commands\n\n### Testing\n```bash\n# Run tests via Swift Package Manager (works on Linux and macOS)\nswift test\n\n# Run tests for iOS using Xcode\nxcodebuild test -scheme PhoneNumberKit -destination 'platform=iOS Simulator,name=iPhone 15'\n\n# Run tests for macOS using Xcode\nxcodebuild test -scheme PhoneNumberKit-macOS -destination 'platform=macOS'\n```\n\n### Building\n```bash\n# Build via Swift Package Manager\nswift build\n\n# Build for iOS (Carthage-style)\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit -destination 'generic/platform=iOS' build\n\n# Build for macOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-macOS -destination 'generic/platform=macOS' build\n\n# Build for tvOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-tvOS -destination 'generic/platform=tvOS' build\n\n# Build for watchOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-watchOS -destination 'generic/platform=watchOS' build\n```\n\n### CocoaPods\n```bash\n# Validate podspec\npod lib lint PhoneNumberKit.podspec\n\n# Push to CocoaPods trunk\npod trunk push PhoneNumberKit.podspec\n```\n\n### Metadata Updates\n```bash\n# Update phone number metadata from Google's libphonenumber (requires Python 3.12+ and xmljson)\ncd PhoneNumberKit/Resources && sh ./update_metadata.sh\n```\n\n## Architecture\n\n### Core Components\n\n**PhoneNumberUtility** (PhoneNumberKit/PhoneNumberUtility.swift)\n- The main entry point for all phone number operations\n- Relatively expensive to allocate (parses and keeps metadata in memory)\n- Should be instantiated once and reused throughout the app lifecycle\n- Provides parsing, formatting, validation, and country/region code queries\n\n**PhoneNumber** (PhoneNumberKit/PhoneNumber.swift)\n- Immutable struct representing a parsed phone number\n- Contains: numberString, countryCode, leadingZero, nationalNumber, numberExtension, type, regionID\n- Implements Equatable, Hashable, and Codable\n\n**MetadataManager** (PhoneNumberKit/MetadataManager.swift)\n- Loads and manages phone number metadata from PhoneNumberMetadata.json\n- Maintains dictionaries for fast lookup by country code and country ID\n- Handles territories with multiple countries sharing calling codes (e.g., NANPA)\n\n**PhoneNumberParser** (PhoneNumberKit/PhoneNumberParser.swift)\n- Internal parser handling normalization, extraction, and validation\n- Strips international/national prefixes and extensions\n- Determines phone number type (mobile, fixed line, etc.)\n\n**ParseManager** (PhoneNumberKit/ParseManager.swift)\n- Coordinates between parser and metadata manager\n- Handles single and batch parsing operations\n\n### Formatting Components\n\n**Formatter** (PhoneNumberKit/Formatter.swift)\n- Formats PhoneNumber objects to different formats: E164, international, national\n\n**PartialFormatter** (PhoneNumberKit/PartialFormatter.swift)\n- Provides as-you-type formatting for user input\n- Used internally by PhoneNumberTextField\n- Only available on platforms with ObjectiveC support (not available on Linux)\n\n### UI Components (iOS only)\n\n**PhoneNumberTextField** (PhoneNumberKit/UI/PhoneNumberTextField.swift)\n- Custom UITextField with automatic phone number formatting\n- Features: flag display, example placeholder, prefix handling\n- Integrates PartialFormatter for real-time formatting\n\n**CountryCodePickerViewController** (PhoneNumberKit/UI/CountryCodePickerViewController.swift)\n- Country code picker UI for PhoneNumberTextField\n- Customizable via CountryCodePickerOptions\n\n## Key Design Patterns\n\n### Metadata Loading\n- Metadata is loaded once during PhoneNumberUtility initialization via a callback\n- Default callback reads from bundled PhoneNumberMetadata.json\n- Custom metadata sources can be provided via metadataCallback parameter\n\n### Region Detection\n- Uses CNContactsUserDefaults.shared().countryCode for iOS 12+\n- Falls back to Locale.current for region detection\n- Handles edge cases (e.g., Korean language on macCatalyst returns \"ko\" instead of \"kr\")\n\n### Type Validation\n- Parser checks number against metadata patterns for each phone type\n- Can be skipped via `ignoreType` parameter for performance\n- Type hierarchy: specific types (mobile, pager, etc.) → fixedOrMobile → unknown\n\n### Performance Optimization\n- Batch parsing with `parse(_:withRegion:ignoreType:)` for arrays\n- Regex patterns are cached in RegexManager\n- Metadata dictionaries provide O(1) lookup by code/country\n\n## Platform Specifics\n\n### Swift Package Manager\n- Target: `PhoneNumberKit` at PhoneNumberKit/\n- Resources: PhoneNumberMetadata.json, PrivacyInfo.xcprivacy\n- Test target: `PhoneNumberKitTests` at PhoneNumberKitTests/\n- Supports iOS 12+, macOS 10.13+, tvOS 12+, watchOS 4+\n\n### CocoaPods\n- Two subspecs: PhoneNumberKitCore (core parsing) and UIKit (UI components)\n- UIKit subspec requires iOS 12+ and depends on PhoneNumberKitCore\n\n### Xcode Project\n- Schemes: PhoneNumberKit (iOS), PhoneNumberKit-macOS, PhoneNumberKit-tvOS, PhoneNumberKit-watchOS\n- No workspace file (uses .xcodeproj directly)\n- Example apps in examples/ directory (AsYouType, PhoneBook)\n\n### UI Components\n- Only available on iOS (guarded by `#if os(iOS)`)\n- PhoneNumberTextField requires UIKit\n\n## Testing Strategy\n\n- Tests in PhoneNumberKitTests/ directory\n- Run via `swift test` for SPM (works on both Linux and macOS)\n- Run via xcodebuild for platform-specific tests\n- CI runs tests on both Linux and macOS using `swift test`\n- CI also validates builds for iOS and macOS using xcodebuild\n\n## Metadata Updates\n\n- Metadata comes from Google's libphonenumber project\n- Update script: PhoneNumberKit/Resources/update_metadata.sh\n- Automated via GitHub Actions workflow (.github/workflows/update_metadata.yml)\n- Runs every 12 hours and can be triggered manually\n- Requires Python 3.12+ with xmljson package installed\n- Creates PRs automatically when new metadata versions are available\n\n## Important Notes\n\n- PhoneNumber objects should be created via PhoneNumberUtility, not directly (deprecated initializers will fail)\n- PhoneNumberUtility instances should be reused, not recreated frequently (they're expensive to allocate)\n- PartialFormatter requires ObjectiveC support (not available on Linux)\n- The `ignoreType` parameter can significantly improve parsing performance when type validation isn't needed\n- For batch operations, use the array parsing method for better performance\n- All builds in CI use `set -o pipefail` to catch errors in piped commands\n"},"items":[{"name":"CLAUDE.md","path":"CLAUDE.md","rawUrl":"https://raw.githubusercontent.com/marmelroy/PhoneNumberKit/HEAD/CLAUDE.md","title":"Claude Agent Guidelines & System Prompt","category":"claude-rule","format":"markdown","content":"# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Project Overview\n\nPhoneNumberKit is a Swift framework for parsing, formatting, and validating international phone numbers. It's inspired by Google's libphonenumber and supports iOS, macOS, tvOS, and watchOS platforms.\n\n## Common Commands\n\n### Testing\n```bash\n# Run tests via Swift Package Manager (works on Linux and macOS)\nswift test\n\n# Run tests for iOS using Xcode\nxcodebuild test -scheme PhoneNumberKit -destination 'platform=iOS Simulator,name=iPhone 15'\n\n# Run tests for macOS using Xcode\nxcodebuild test -scheme PhoneNumberKit-macOS -destination 'platform=macOS'\n```\n\n### Building\n```bash\n# Build via Swift Package Manager\nswift build\n\n# Build for iOS (Carthage-style)\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit -destination 'generic/platform=iOS' build\n\n# Build for macOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-macOS -destination 'generic/platform=macOS' build\n\n# Build for tvOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-tvOS -destination 'generic/platform=tvOS' build\n\n# Build for watchOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-watchOS -destination 'generic/platform=watchOS' build\n```\n\n### CocoaPods\n```bash\n# Validate podspec\npod lib lint PhoneNumberKit.podspec\n\n# Push to CocoaPods trunk\npod trunk push PhoneNumberKit.podspec\n```\n\n### Metadata Updates\n```bash\n# Update phone number metadata from Google's libphonenumber (requires Python 3.12+ and xmljson)\ncd PhoneNumberKit/Resources && sh ./update_metadata.sh\n```\n\n## Architecture\n\n### Core Components\n\n**PhoneNumberUtility** (PhoneNumberKit/PhoneNumberUtility.swift)\n- The main entry point for all phone number operations\n- Relatively expensive to allocate (parses and keeps metadata in memory)\n- Should be instantiated once and reused throughout the app lifecycle\n- Provides parsing, formatting, validation, and country/region code queries\n\n**PhoneNumber** (PhoneNumberKit/PhoneNumber.swift)\n- Immutable struct representing a parsed phone number\n- Contains: numberString, countryCode, leadingZero, nationalNumber, numberExtension, type, regionID\n- Implements Equatable, Hashable, and Codable\n\n**MetadataManager** (PhoneNumberKit/MetadataManager.swift)\n- Loads and manages phone number metadata from PhoneNumberMetadata.json\n- Maintains dictionaries for fast lookup by country code and country ID\n- Handles territories with multiple countries sharing calling codes (e.g., NANPA)\n\n**PhoneNumberParser** (PhoneNumberKit/PhoneNumberParser.swift)\n- Internal parser handling normalization, extraction, and validation\n- Strips international/national prefixes and extensions\n- Determines phone number type (mobile, fixed line, etc.)\n\n**ParseManager** (PhoneNumberKit/ParseManager.swift)\n- Coordinates between parser and metadata manager\n- Handles single and batch parsing operations\n\n### Formatting Components\n\n**Formatter** (PhoneNumberKit/Formatter.swift)\n- Formats PhoneNumber objects to different formats: E164, international, national\n\n**PartialFormatter** (PhoneNumberKit/PartialFormatter.swift)\n- Provides as-you-type formatting for user input\n- Used internally by PhoneNumberTextField\n- Only available on platforms with ObjectiveC support (not available on Linux)\n\n### UI Components (iOS only)\n\n**PhoneNumberTextField** (PhoneNumberKit/UI/PhoneNumberTextField.swift)\n- Custom UITextField with automatic phone number formatting\n- Features: flag display, example placeholder, prefix handling\n- Integrates PartialFormatter for real-time formatting\n\n**CountryCodePickerViewController** (PhoneNumberKit/UI/CountryCodePickerViewController.swift)\n- Country code picker UI for PhoneNumberTextField\n- Customizable via CountryCodePickerOptions\n\n## Key Design Patterns\n\n### Metadata Loading\n- Metadata is loaded once during PhoneNumberUtility initialization via a callback\n- Default callback reads from bundled PhoneNumberMetadata.json\n- Custom metadata sources can be provided via metadataCallback parameter\n\n### Region Detection\n- Uses CNContactsUserDefaults.shared().countryCode for iOS 12+\n- Falls back to Locale.current for region detection\n- Handles edge cases (e.g., Korean language on macCatalyst returns \"ko\" instead of \"kr\")\n\n### Type Validation\n- Parser checks number against metadata patterns for each phone type\n- Can be skipped via `ignoreType` parameter for performance\n- Type hierarchy: specific types (mobile, pager, etc.) → fixedOrMobile → unknown\n\n### Performance Optimization\n- Batch parsing with `parse(_:withRegion:ignoreType:)` for arrays\n- Regex patterns are cached in RegexManager\n- Metadata dictionaries provide O(1) lookup by code/country\n\n## Platform Specifics\n\n### Swift Package Manager\n- Target: `PhoneNumberKit` at PhoneNumberKit/\n- Resources: PhoneNumberMetadata.json, PrivacyInfo.xcprivacy\n- Test target: `PhoneNumberKitTests` at PhoneNumberKitTests/\n- Supports iOS 12+, macOS 10.13+, tvOS 12+, watchOS 4+\n\n### CocoaPods\n- Two subspecs: PhoneNumberKitCore (core parsing) and UIKit (UI components)\n- UIKit subspec requires iOS 12+ and depends on PhoneNumberKitCore\n\n### Xcode Project\n- Schemes: PhoneNumberKit (iOS), PhoneNumberKit-macOS, PhoneNumberKit-tvOS, PhoneNumberKit-watchOS\n- No workspace file (uses .xcodeproj directly)\n- Example apps in examples/ directory (AsYouType, PhoneBook)\n\n### UI Components\n- Only available on iOS (guarded by `#if os(iOS)`)\n- PhoneNumberTextField requires UIKit\n\n## Testing Strategy\n\n- Tests in PhoneNumberKitTests/ directory\n- Run via `swift test` for SPM (works on both Linux and macOS)\n- Run via xcodebuild for platform-specific tests\n- CI runs tests on both Linux and macOS using `swift test`\n- CI also validates builds for iOS and macOS using xcodebuild\n\n## Metadata Updates\n\n- Metadata comes from Google's libphonenumber project\n- Update script: PhoneNumberKit/Resources/update_metadata.sh\n- Automated via GitHub Actions workflow (.github/workflows/update_metadata.yml)\n- Runs every 12 hours and can be triggered manually\n- Requires Python 3.12+ with xmljson package installed\n- Creates PRs automatically when new metadata versions are available\n\n## Important Notes\n\n- PhoneNumber objects should be created via PhoneNumberUtility, not directly (deprecated initializers will fail)\n- PhoneNumberUtility instances should be reused, not recreated frequently (they're expensive to allocate)\n- PartialFormatter requires ObjectiveC support (not available on Linux)\n- The `ignoreType` parameter can significantly improve parsing performance when type validation isn't needed\n- For batch operations, use the array parsing method for better performance\n- All builds in CI use `set -o pipefail` to catch errors in piped commands\n","isInternal":false,"tokens":1443,"sizeBytes":6780}],"systemPromptSnippet":"<yakaai_skills repo=\"marmelroy/PhoneNumberKit\">\n<!-- File: CLAUDE.md (Tokens: ~1443 | Category: claude-rule) -->\n# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## Project Overview\n\nPhoneNumberKit is a Swift framework for parsing, formatting, and validating international phone numbers. It's inspired by Google's libphonenumber and supports iOS, macOS, tvOS, and watchOS platforms.\n\n## Common Commands\n\n### Testing\n```bash\n# Run tests via Swift Package Manager (works on Linux and macOS)\nswift test\n\n# Run tests for iOS using Xcode\nxcodebuild test -scheme PhoneNumberKit -destination 'platform=iOS Simulator,name=iPhone 15'\n\n# Run tests for macOS using Xcode\nxcodebuild test -scheme PhoneNumberKit-macOS -destination 'platform=macOS'\n```\n\n### Building\n```bash\n# Build via Swift Package Manager\nswift build\n\n# Build for iOS (Carthage-style)\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit -destination 'generic/platform=iOS' build\n\n# Build for macOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-macOS -destination 'generic/platform=macOS' build\n\n# Build for tvOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-tvOS -destination 'generic/platform=tvOS' build\n\n# Build for watchOS\nxcodebuild -project PhoneNumberKit.xcodeproj -scheme PhoneNumberKit-watchOS -destination 'generic/platform=watchOS' build\n```\n\n### CocoaPods\n```bash\n# Validate podspec\npod lib lint PhoneNumberKit.podspec\n\n# Push to CocoaPods trunk\npod trunk push PhoneNumberKit.podspec\n```\n\n### Metadata Updates\n```bash\n# Update phone number metadata from Google's libphonenumber (requires Python 3.12+ and xmljson)\ncd PhoneNumberKit/Resources && sh ./update_metadata.sh\n```\n\n## Architecture\n\n### Core Components\n\n**PhoneNumberUtility** (PhoneNumberKit/PhoneNumberUtility.swift)\n- The main entry point for all phone number operations\n- Relatively expensive to allocate (parses and keeps metadata in memory)\n- Should be instantiated once and reused throughout the app lifecycle\n- Provides parsing, formatting, validation, and country/region code queries\n\n**PhoneNumber** (PhoneNumberKit/PhoneNumber.swift)\n- Immutable struct representing a parsed phone number\n- Contains: numberString, countryCode, leadingZero, nationalNumber, numberExtension, type, regionID\n- Implements Equatable, Hashable, and Codable\n\n**MetadataManager** (PhoneNumberKit/MetadataManager.swift)\n- Loads and manages phone number metadata from PhoneNumberMetadata.json\n- Maintains dictionaries for fast lookup by country code and country ID\n- Handles territories with multiple countries sharing calling codes (e.g., NANPA)\n\n**PhoneNumberParser** (PhoneNumberKit/PhoneNumberParser.swift)\n- Internal parser handling normalization, extraction, and validation\n- Strips international/national prefixes and extensions\n- Determines phone number type (mobile, fixed line, etc.)\n\n**ParseManager** (PhoneNumberKit/ParseManager.swift)\n- Coordinates between parser and metadata manager\n- Handles single and batch parsing operations\n\n### Formatting Components\n\n**Formatter** (PhoneNumberKit/Formatter.swift)\n- Formats PhoneNumber objects to different formats: E164, international, national\n\n**PartialFormatter** (PhoneNumberKit/PartialFormatter.swift)\n- Provides as-you-type formatting for user input\n- Used internally by PhoneNumberTextField\n- Only available on platforms with ObjectiveC support (not available on Linux)\n\n### UI Components (iOS only)\n\n**PhoneNumberTextField** (PhoneNumberKit/UI/PhoneNumberTextField.swift)\n- Custom UITextField with automatic phone number formatting\n- Features: flag display, example placeholder, prefix handling\n- Integrates PartialFormatter for real-time formatting\n\n**CountryCodePickerViewController** (PhoneNumberKit/UI/CountryCodePickerViewController.swift)\n- Country code picker UI for PhoneNumberTextField\n- Customizable via CountryCodePickerOptions\n\n## Key Design Patterns\n\n### Metadata Loading\n- Metadata is loaded once during PhoneNumberUtility initialization via a callback\n- Default callback reads from bundled PhoneNumberMetadata.json\n- Custom metadata sources can be provided via metadataCallback parameter\n\n### Region Detection\n- Uses CNContactsUserDefaults.shared().countryCode for iOS 12+\n- Falls back to Locale.current for region detection\n- Handles edge cases (e.g., Korean language on macCatalyst returns \"ko\" instead of \"kr\")\n\n### Type Validation\n- Parser checks number against metadata patterns for each phone type\n- Can be skipped via `ignoreType` parameter for performance\n- Type hierarchy: specific types (mobile, pager, etc.) → fixedOrMobile → unknown\n\n### Performance Optimization\n- Batch parsing with `parse(_:withRegion:ignoreType:)` for arrays\n- Regex patterns are cached in RegexManager\n- Metadata dictionaries provide O(1) lookup by code/country\n\n## Platform Specifics\n\n### Swift Package Manager\n- Target: `PhoneNumberKit` at PhoneNumberKit/\n- Resources: PhoneNumberMetadata.json, PrivacyInfo.xcprivacy\n- Test target: `PhoneNumberKitTests` at PhoneNumberKitTests/\n- Supports iOS 12+, macOS 10.13+, tvOS 12+, watchOS 4+\n\n### CocoaPods\n- Two subspecs: PhoneNumberKitCore (core parsing) and UIKit (UI components)\n- UIKit subspec requires iOS 12+ and depends on PhoneNumberKitCore\n\n### Xcode Project\n- Schemes: PhoneNumberKit (iOS), PhoneNumberKit-macOS, PhoneNumberKit-tvOS, PhoneNumberKit-watchOS\n- No workspace file (uses .xcodeproj directly)\n- Example apps in examples/ directory (AsYouType, PhoneBook)\n\n### UI Components\n- Only available on iOS (guarded by `#if os(iOS)`)\n- PhoneNumberTextField requires UIKit\n\n## Testing Strategy\n\n- Tests in PhoneNumberKitTests/ directory\n- Run via `swift test` for SPM (works on both Linux and macOS)\n- Run via xcodebuild for platform-specific tests\n- CI runs tests on both Linux and macOS using `swift test`\n- CI also validates builds for iOS and macOS using xcodebuild\n\n## Metadata Updates\n\n- Metadata comes from Google's libphonenumber project\n- Update script: PhoneNumberKit/Resources/update_metadata.sh\n- Automated via GitHub Actions workflow (.github/workflows/update_metadata.yml)\n- Runs every 12 hours and can be triggered manually\n- Requires Python 3.12+ with xmljson package installed\n- Creates PRs automatically when new metadata versions are available\n\n## Important Notes\n\n- PhoneNumber objects should be created via PhoneNumberUtility, not directly (deprecated initializers will fail)\n- PhoneNumberUtility instances should be reused, not recreated frequently (they're expensive to allocate)\n- PartialFormatter requires ObjectiveC support (not available on Linux)\n- The `ignoreType` parameter can significantly improve parsing performance when type validation isn't needed\n- For batch operations, use the array parsing method for better performance\n- All builds in CI use `set -o pipefail` to catch errors in piped commands\n</yakaai_skills>"}