{"id":50897682,"url":"https://github.com/inesbcode/swift-app-context","last_synced_at":"2026-06-16T01:31:25.675Z","repository":{"id":351283256,"uuid":"1205146373","full_name":"inesbcode/swift-app-context","owner":"inesbcode","description":"Swift package for reading app bundle metadata and build environment. Exposes version, build number, and debug/release configuration as focused, type-safe Swift values.","archived":false,"fork":false,"pushed_at":"2026-04-14T10:12:34.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-14T12:14:47.869Z","etag":null,"topics":["app-version","apple-platforms","bundle","ios","macos","semantic-versioning","swift","swift-package-manager","swift6","tvos","visionos","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inesbcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-08T17:20:21.000Z","updated_at":"2026-04-14T10:12:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/inesbcode/swift-app-context","commit_stats":null,"previous_names":["inesbcode/swift-app-context"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/inesbcode/swift-app-context","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inesbcode%2Fswift-app-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inesbcode%2Fswift-app-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inesbcode%2Fswift-app-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inesbcode%2Fswift-app-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inesbcode","download_url":"https://codeload.github.com/inesbcode/swift-app-context/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inesbcode%2Fswift-app-context/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34387472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app-version","apple-platforms","bundle","ios","macos","semantic-versioning","swift","swift-package-manager","swift6","tvos","visionos","watchos"],"created_at":"2026-06-16T01:31:24.995Z","updated_at":"2026-06-16T01:31:25.662Z","avatar_url":"https://github.com/inesbcode.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AppContext\n\nApp bundle metadata and build environment for Apple platforms.\n\nReading `CFBundleShortVersionString` as a raw string, checking `#if DEBUG` ad-hoc across files, and accessing `Bundle.main` everywhere leads to scattered, untyped boilerplate. `swift-app-context` centralises all of it into three focused types: `AppContext` for bundle metadata, `AppVersion` for typed semantic versioning, and `AppEnvironment` for build configuration.\n\n## Requirements\n\n| Platform | Minimum version |\n|----------|----------------|\n| iOS      | 16             |\n| macOS    | 13             |\n| watchOS  | 9              |\n| tvOS     | 16             |\n| visionOS | 1              |\n\nSwift 6 · Swift Package Manager\n\n## Installation\n\n### Xcode\n\n**File → Add Package Dependencies…**, paste the repository URL, then add `AppContext` to your app target.\n\n### Package.swift\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/inesbcode/swift-app-context.git\", from: \"1.0.0\"),\n],\ntargets: [\n    .target(\n        name: \"MyApp\",\n        dependencies: [\n            .product(name: \"AppContext\", package: \"swift-app-context\"),\n        ]\n    ),\n]\n```\n\n## Usage\n\n### Reading bundle metadata\n\n```swift\nimport AppContext\n\nlet context = AppContext()\n\nprint(context.version)       // AppVersion — major: 1, minor: 2, patch: 3\nprint(context.buildNumber)   // \"42\"\nprint(context.bundleId)      // \"com.mycompany.MyApp\"\nprint(context.displayName)   // \"My App\"\n```\n\n### Checking the build environment\n\n```swift\nif context.environment == .debug {\n    // enable extra diagnostics\n}\n```\n\nOr access the environment directly without an `AppContext` instance:\n\n```swift\nswitch AppEnvironment.current {\ncase .debug:\n    enableVerboseLogging()\ncase .release:\n    break\n}\n```\n\n### Working with AppVersion\n\n`AppVersion` parses the version string from `Info.plist` into typed integer components:\n\n```swift\nlet version = context.version  // AppVersion?\n\nversion?.major   // 1\nversion?.minor   // 2\nversion?.patch   // 3\nString(describing: version!)  // \"1.2.3\"\n```\n\n`AppVersion` conforms to `Comparable`, so you can gate behaviour on a minimum version:\n\n```swift\nif let version = context.version, version \u003e= AppVersion(major: 2) {\n    // enable feature introduced in 2.0\n}\n```\n\n### Custom bundle\n\nPass an explicit bundle for framework or test targets:\n\n```swift\nlet context = AppContext(bundle: Bundle(for: MyClass.self))\n```\n\n## API reference\n\n### AppContext\n\n| Property | Type | Source |\n|---|---|---|\n| `version` | `AppVersion?` | `CFBundleShortVersionString` |\n| `buildNumber` | `String?` | `CFBundleVersion` |\n| `bundleId` | `String?` | `Bundle.bundleIdentifier` |\n| `displayName` | `String?` | `CFBundleDisplayName` / `CFBundleName` |\n| `environment` | `AppEnvironment` | `#if DEBUG` compilation condition |\n\n### AppVersion\n\n| Member | Description |\n|---|---|\n| `init(major:minor:patch:)` | Creates a version from numeric components. `minor` and `patch` default to `0`. |\n| `init?(_ string:)` | Parses a dot-separated string such as `\"1.2.3\"`. Returns `nil` on invalid input. |\n| `major`, `minor`, `patch` | `Int` components. |\n| `description` | Dot-separated string representation (e.g. `\"1.2.3\"`). |\n| `Comparable` | Ordered by major, then minor, then patch. |\n\n### AppEnvironment\n\n| Member | Description |\n|---|---|\n| `current` | `static var` — `.debug` when `DEBUG` is defined, `.release` otherwise. |\n| `.debug` | The app was built in Debug configuration. |\n| `.release` | The app was built in Release configuration. |\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finesbcode%2Fswift-app-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finesbcode%2Fswift-app-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finesbcode%2Fswift-app-context/lists"}