{"id":22840829,"url":"https://github.com/rustunit/bevy_ios_gamecenter","last_synced_at":"2025-04-28T10:50:43.298Z","repository":{"id":237903294,"uuid":"794215047","full_name":"rustunit/bevy_ios_gamecenter","owner":"rustunit","description":"Bevy Plugin and Swift Package to provide access to iOS native Gamecenter from inside Bevy","archived":false,"fork":false,"pushed_at":"2025-03-29T06:49:19.000Z","size":10686,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T07:00:51.139Z","etag":null,"topics":["bevy-engine","gamedev","ios","mobile","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/bevy_ios_gamecenter","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustunit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","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},"funding":{"github":"rustunit"}},"created_at":"2024-04-30T17:16:56.000Z","updated_at":"2025-03-29T06:49:22.000Z","dependencies_parsed_at":"2024-11-16T18:43:15.568Z","dependency_job_id":null,"html_url":"https://github.com/rustunit/bevy_ios_gamecenter","commit_stats":null,"previous_names":["rustunit/bevy_ios_gamecenter"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_gamecenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_gamecenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_gamecenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_gamecenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustunit","download_url":"https://codeload.github.com/rustunit/bevy_ios_gamecenter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251299828,"owners_count":21567317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bevy-engine","gamedev","ios","mobile","rust"],"created_at":"2024-12-13T01:13:34.814Z","updated_at":"2025-04-28T10:50:43.289Z","avatar_url":"https://github.com/rustunit.png","language":"Swift","funding_links":["https://github.com/sponsors/rustunit"],"categories":[],"sub_categories":[],"readme":"# bevy_ios_gamecenter\n\n[![crates.io][sh_crates]][lk_crates]\n[![docs.rs][sh_docs]][lk_docs]\n[![discord][sh_discord]][lk_discord]\n\n[sh_crates]: https://img.shields.io/crates/v/bevy_ios_gamecenter.svg\n[lk_crates]: https://crates.io/crates/bevy_ios_gamecenter\n[sh_docs]: https://img.shields.io/docsrs/bevy_ios_gamecenter\n[lk_docs]: https://docs.rs/bevy_ios_iap/latest/bevy_ios_gamecenter/\n[sh_discord]: https://img.shields.io/discord/1176858176897953872?label=discord\u0026color=5561E6\n[lk_discord]: https://discord.gg/rQNeEnMhus\n\nBevy Plugin and Swift Package to provide access to iOS native GameKit (Gamecenter) from inside Bevy Apps\nIt uses [Swift-Bridge](https://github.com/chinedufn/swift-bridge) to auto-generate the glue code and transport data types.\n\n![demo](./assets/demo.gif)\n\n\u003e Demo from our game using this crate: [zoolitaire.com](https://zoolitaire.com)\n\n## Features\n* authentication\n* save games (based on iCloud)\n* achievements\n* leaderboards\n* egui based debug ui crate see [bevy_ios_gamecenter_egui folder](./bevy_ios_gamecenter_egui/README.md)\n\n## TODOs\n* challenges, matchmaking\n\n## Instructions\n\n1. Add to XCode: Add SPM (Swift Package Manager) dependency\n2. Add Rust dependency\n3. Setup Plugin\n\n### 1. Add to XCode\n\n* Add `GameKit` framework:\n![gamekit](./assets/framework.png)\n\n* Go to `File` -\u003e `Add Package Dependencies` and paste `https://github.com/rustunit/bevy_ios_gamecenter.git` into the search bar on the top right:\n![xcode](./assets/xcode-spm.png)\n\n**Note:**\nThe rust crate used must be exactly the same version as the Swift Package.\nI suggest using a specific version (like `0.2.0` in the screenshot) to make sure to always use binary matching versions!\n\n### 2. Add Rust dependency\n\n```\ncargo add bevy_ios_gamecenter\n```\n\nor\n\n```toml\n# always pin to the same exact version you also of the Swift package\nbevy_ios_gamecenter = { version = \"=0.4.0\" }\n```\n\n### 3. Setup Plugin\n\nInitialize Bevy Plugin:\n\n```rust\n// init right on startup\napp.add_plugins(IosGamecenterPlugin::new(true));\n```\n\n```rust\nfn bevy_system(mut gc: BevyIosGamecenter) {\n\n    gc.authenticate()\n        .on_response(|trigger: Trigger\u003cIosGCAuthResult\u003e| match \u0026trigger.event().0 {\n            IosGCAuthResult::IsAuthenticated =\u003e {},\n            IosGCAuthResult::LoginPresented =\u003e {},\n            IosGCAuthResult::Error(e) =\u003e error!(\"auth error: {e}\"),\n        });\n\n    // here we request the player info type for the username and more\n    // Note: all requests via `gc` of type `BevyIosGamecenter`\n    // allow to attach an observer to listen to the response:\n    gc.request_player().on_response(on_player_response);\n\n    // update achievement progress, 100 % will complete it\n    gc.achievement_progress(\"id\".into(),100.);\n\n    // reset all achievements\n    gc.achievements_reset();\n\n    // save a game state as a byte slice\n    gc.save_game(\"test\".into(), vec![1, 2, 3].as_slice());\n\n    // request list of `IosGCSaveGame`\n    gc.fetch_save_games().on_response(on_response);\n\n    // based on result of above `fetch_save_games` request\n    let save_game = IosGCSaveGame {..}\n    gc.load_game(save_game);\n\n    // update leaderboard score\n    gc.leaderboards_score(\n        \"raking id\".into(),\n        // score\n        1,\n        // context\n        2,\n    );\n\n    // open gamecenter view (leaderboard)\n    gc.trigger_view(view_states::LEADERBOARDS);\n}\n```\n\n## Our Other Crates\n\n- [bevy_debug_log](https://github.com/rustunit/bevy_debug_log)\n- [bevy_device_lang](https://github.com/rustunit/bevy_device_lang)\n- [bevy_web_popups](https://github.com/rustunit/bevy_web_popups)\n- [bevy_libgdx_atlas](https://github.com/rustunit/bevy_libgdx_atlas)\n- [bevy_ios_review](https://github.com/rustunit/bevy_ios_review)\n- [bevy_ios_iap](https://github.com/rustunit/bevy_ios_iap)\n- [bevy_ios_alerts](https://github.com/rustunit/bevy_ios_alerts)\n- [bevy_ios_notifications](https://github.com/rustunit/bevy_ios_notifications)\n- [bevy_ios_impact](https://github.com/rustunit/bevy_ios_impact)\n- [bevy_ios_safearea](https://github.com/rustunit/bevy_ios_safearea)\n\n## Bevy version support\n\n|bevy|bevy\\_ios\\_gamecenter|\n|----|---|\n|0.16|0.4,main|\n|0.15|0.3|\n|0.14|0.2|\n|0.13|0.1|\n\n# License\n\nAll code in this repository is dual-licensed under either:\n\n- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)\n- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)\n\nat your option. This means you can select the license you prefer.\n\n## Your contributions\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustunit%2Fbevy_ios_gamecenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustunit%2Fbevy_ios_gamecenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustunit%2Fbevy_ios_gamecenter/lists"}