Skip to content

Commit b83bda5

Browse files
authored
support Bevy 0.16 (#8)
1 parent e25cad0 commit b83bda5

File tree

17 files changed

+151
-115
lines changed

17 files changed

+151
-115
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,74 @@ jobs:
1212
runs-on: macos-latest
1313

1414
steps:
15-
- uses: actions/checkout@v4
16-
- uses: dtolnay/rust-toolchain@stable
17-
18-
- name: Add iOS targets
19-
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
20-
21-
- name: Rust Cache
22-
uses: Swatinem/rust-cache@v2
23-
with:
24-
workspaces: "./bevy_ios_iap"
25-
26-
- name: Check iOS Sim
27-
run: |
28-
cd bevy_ios_iap
29-
cargo c --target=aarch64-apple-ios-sim
30-
cargo b --target=aarch64-apple-ios-sim
31-
cargo clippy --target=aarch64-apple-ios-sim
32-
33-
- name: Check iOS
34-
run: |
35-
cd bevy_ios_iap
36-
cargo c --target=aarch64-apple-ios
37-
cargo b --target=aarch64-apple-ios
38-
cargo clippy --target=aarch64-apple-ios
39-
40-
- name: Check MacOs
41-
run: |
42-
cd bevy_ios_iap
43-
cargo c
44-
cargo b
45-
cargo clippy
46-
cargo t
15+
- uses: actions/checkout@v4
16+
- uses: dtolnay/rust-toolchain@stable
17+
18+
- name: Add iOS targets
19+
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
20+
21+
- name: Rust Cache
22+
uses: Swatinem/rust-cache@v2
23+
with:
24+
workspaces: "./bevy_ios_iap"
25+
26+
# TODO: enable once https://github.com/rust-lang/rust-bindgen/issues/3181 is released
27+
# - name: Check iOS Sim
28+
# run: |
29+
# cd bevy_ios_iap
30+
# cargo c --target=aarch64-apple-ios-sim
31+
# cargo b --target=aarch64-apple-ios-sim
32+
# cargo clippy --target=aarch64-apple-ios-sim
33+
34+
- name: Check iOS
35+
run: |
36+
cd bevy_ios_iap
37+
cargo c --target=aarch64-apple-ios
38+
cargo b --target=aarch64-apple-ios
39+
cargo clippy --target=aarch64-apple-ios
40+
41+
- name: Check MacOs
42+
run: |
43+
cd bevy_ios_iap
44+
cargo c
45+
cargo b
46+
cargo clippy
47+
cargo t
4748
4849
build_egui:
4950
runs-on: macos-latest
5051

5152
steps:
52-
- uses: actions/checkout@v4
53-
- uses: dtolnay/rust-toolchain@stable
54-
55-
- name: Add iOS targets
56-
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
57-
58-
- name: Rust Cache
59-
uses: Swatinem/rust-cache@v2
60-
with:
61-
workspaces: "./bevy_ios_iap_egui"
62-
63-
- name: Check iOS Sim
64-
run: |
65-
cd bevy_ios_iap_egui
66-
cargo c --target=aarch64-apple-ios-sim
67-
cargo b --target=aarch64-apple-ios-sim
68-
cargo clippy --target=aarch64-apple-ios-sim
69-
70-
- name: Check iOS
71-
run: |
72-
cd bevy_ios_iap_egui
73-
cargo c --target=aarch64-apple-ios
74-
cargo b --target=aarch64-apple-ios
75-
cargo clippy --target=aarch64-apple-ios
76-
77-
- name: Check MacOs
78-
run: |
79-
cd bevy_ios_iap_egui
80-
cargo c
81-
cargo b
82-
cargo clippy
83-
cargo t
53+
- uses: actions/checkout@v4
54+
- uses: dtolnay/rust-toolchain@stable
55+
56+
- name: Add iOS targets
57+
run: rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
58+
59+
- name: Rust Cache
60+
uses: Swatinem/rust-cache@v2
61+
with:
62+
workspaces: "./bevy_ios_iap_egui"
63+
64+
# TODO: enable once https://github.com/rust-lang/rust-bindgen/issues/3181 is released
65+
# - name: Check iOS Sim
66+
# run: |
67+
# cd bevy_ios_iap_egui
68+
# cargo c --target=aarch64-apple-ios-sim
69+
# cargo b --target=aarch64-apple-ios-sim
70+
# cargo clippy --target=aarch64-apple-ios-sim
71+
72+
- name: Check iOS
73+
run: |
74+
cd bevy_ios_iap_egui
75+
cargo c --target=aarch64-apple-ios
76+
cargo b --target=aarch64-apple-ios
77+
cargo clippy --target=aarch64-apple-ios
78+
79+
- name: Check MacOs
80+
run: |
81+
cd bevy_ios_iap_egui
82+
cargo c
83+
cargo b
84+
cargo clippy
85+
cargo t

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10-
## [0.6.0] - 2024-03-30
10+
## [0.7.0] - 2025-04-26
11+
12+
### Fixed
13+
* upgrade to bevy `0.16`
14+
* temporarily disabled ios-sim support until rust-bindgen [releases](https://github.com/rust-lang/rust-bindgen/issues/3181)
15+
16+
## [0.6.0] - 2025-03-30
1117

1218
### Changed
1319
* make `Transaction` `reason` and `storefront` available only ios `17.0` or up
1420
* introduce `Ios17Specific` Option-like that forces users to handle the fact that these values are only available on iOS 17 or up
1521
* make package iOS `16.0` compatible
1622
* remove `currency_code` as it was deprecated in iOS `16.0`
1723

18-
## [0.5.2] - 2024-01-11
24+
## [0.5.2] - 2025-01-11
1925

2026
### Added
2127
* add `IosIapPurchaseError` and `IosIapStoreKitError` to `IosIapPurchaseResponse` to provide programmatic error handling
@@ -73,4 +79,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7379
*note:* the crate release matches the commit tagged with the `ru-` prefix because we release the swift package after the crate due to its dependency on each other
7480

7581
### Added
76-
* `IosIapPurchaseResult` can be `Unknown` if an invalid product ID is used for a purchase ([#3](https://github.com/rustunit/bevy_ios_iap/issues/3))
82+
* `IosIapPurchaseResult` can be `Unknown` if an invalid product ID is used for a purchase ([#3](https://github.com/rustunit/bevy_ios_iap/issues/3))

Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ let package = Package(
1010
// Products define the executables and libraries a package produces, making them visible to other packages.
1111
.library(
1212
name: "bevy_ios_iap",
13-
targets: ["bevy_ios_iap"]),
13+
targets: ["bevy_ios_iap"])
1414
],
1515
targets: [
1616
// Targets are the basic building blocks of a package, defining a module or a test suite.
1717
// Targets can depend on other targets in this package and products from dependencies.
1818
.binaryTarget(
1919
name: "RustXcframework",
20-
// for local development:
21-
// path: "RustXcframework.xcframework"),
22-
url: "https://github.com/rustunit/bevy_ios_iap/releases/download/rs-0.6.0/RustXcframework.xcframework.zip",
23-
checksum: "ce0261d0fda41b2108b9f34bd2235f0e245c6b666a1921615a24a8a61fa41f1e"),
20+
//for local development:
21+
path: "RustXcframework.xcframework"),
22+
//url: "https://github.com/rustunit/bevy_ios_iap/releases/download/rs-0.6.0/RustXcframework.xcframework.zip",
23+
//checksum: "ce0261d0fda41b2108b9f34bd2235f0e245c6b666a1921615a24a8a61fa41f1e"),
2424
.target(
2525
name: "bevy_ios_iap",
2626
dependencies: ["RustXcframework"]),

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ It uses [Swift-Bridge](https://github.com/chinedufn/swift-bridge) to auto-genera
5151

5252
* Don't forget to configure your purchases like for any other iOS app, this guide will not focus on that, as it is the same no matter what engine you use. this guide focuses on setting things up in a bevy project.
5353

54-
**Note:**
54+
**Note:**
5555
The rust crate used must be **exactly** the same version as the Swift Package (for binary compatibility reasons).
5656
I suggest using a specific version (like `0.2.0` in the screenshot) to make sure to always use binary matching versions!
5757

5858
### 2. Add Rust dependency
5959

6060
```
6161
cargo add bevy_ios_iap
62-
```
62+
```
6363

64-
or
64+
or
6565

6666
```toml
6767
# always pin to the same exact version you also of the Swift package
@@ -79,7 +79,7 @@ app.add_plugins(IosIapPlugin::new(true));
7979

8080
```rust
8181
fn bevy_system(mut iap: BevyIosIap) {
82-
// If you set the plugin to manual init, this will register the
82+
// If you set the plugin to manual init, this will register the
8383
// TranscactionObserver to listen to updates to any Transactions and trigger
8484
// `IosIapEvents::Transaction` accordingly.
8585
// Note: this will require the user to be logged in into their apple-id and popup a login dialog if not
@@ -156,9 +156,10 @@ fn process_iap_events(
156156

157157
## Bevy version support
158158

159-
|bevy|bevy\_ios\_iap|
159+
|bevy|crate|
160160
|---|---|
161-
|0.15|0.5,main|
161+
|0.16|0.6,main|
162+
|0.15|0.5|
162163
|0.14|0.3,0.4|
163164
|0.13|0.2|
164165

Sources/bevy_ios_iap/BevyIosIAP.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ public func convert_storekit_error(_ error: (StoreKitError)) -> IosIapStoreKitEr
214214
case .systemError(let e): IosIapStoreKitError.system_error(e.localizedDescription)
215215
case .notAvailableInStorefront: IosIapStoreKitError.not_available_in_storefront()
216216
case .notEntitled: IosIapStoreKitError.not_entitled()
217+
218+
@unknown default:
219+
IosIapStoreKitError.unknown()
217220
}
218221
}
219222

bevy_ios_iap/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_ios_iap"
3-
version = "0.6.0"
4-
edition = "2021"
3+
version = "0.7.0"
4+
edition = "2024"
55
build = "build.rs"
66
readme = "../README.md"
77
license = "MIT"
@@ -15,11 +15,11 @@ description = "Bevy Plugin and Swift Package to provide access to iOS native Sto
1515
crate-type = ["staticlib", "rlib"]
1616

1717
[dependencies]
18-
bevy_app = { version = "0.15", default-features = false }
19-
bevy_ecs = { version = "0.15", default-features = false }
20-
bevy_ecs_macros = { version = "0.15", default-features = false }
21-
bevy_log = { version = "0.15", default-features = false }
22-
bevy_crossbeam_event = "0.7"
18+
bevy_app = { version = "0.16", default-features = false }
19+
bevy_ecs = { version = "0.16", default-features = false }
20+
bevy_ecs_macros = { version = "0.16", default-features = false }
21+
bevy_log = { version = "0.16", default-features = false }
22+
bevy_crossbeam_event = "0.8"
2323
swift-bridge = "0.1"
2424

2525
[build-dependencies]

bevy_ios_iap/build-rust-release.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ cd $THISDIR
1010
touch ./src/lib.rs
1111
cargo build --release --target aarch64-apple-ios
1212
cargo build --release --target x86_64-apple-ios
13-
cargo build --release --target aarch64-apple-ios-sim
13+
# TODO: enable once https://github.com/rust-lang/rust-bindgen/issues/3181 is released
14+
# cargo build --release --target aarch64-apple-ios-sim
15+
#
1416
mkdir -p ./target/universal-ios/release
1517

16-
lipo \
17-
./target/aarch64-apple-ios-sim/release/libbevy_ios_iap.a \
18-
./target/x86_64-apple-ios/release/libbevy_ios_iap.a -create -output \
19-
./target/universal-ios/release/libbevy_ios_iap.a
18+
# TODO: add back sim target
19+
lipo -create \
20+
"./target/aarch64-apple-ios/release/libbevy_ios_iap.a" \
21+
"./target/x86_64-apple-ios/release/libbevy_ios_iap.a" \
22+
-output ./target/universal-ios/release/libbevy_ios_iap.a

bevy_ios_iap/build-rust.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ cd $THISDIR
1010
touch ./src/lib.rs
1111
cargo build --target aarch64-apple-ios
1212
cargo build --target x86_64-apple-ios
13-
cargo build --target aarch64-apple-ios-sim
13+
# TODO: enable once https://github.com/rust-lang/rust-bindgen/issues/3181 is released
14+
# cargo build --target aarch64-apple-ios-sim
15+
1416
mkdir -p ./target/universal-ios/debug
1517

16-
lipo \
17-
./target/aarch64-apple-ios-sim/debug/libbevy_ios_iap.a \
18-
./target/x86_64-apple-ios/debug/libbevy_ios_iap.a -create -output \
19-
./target/universal-ios/debug/libbevy_ios_iap.a
18+
# TODO: add back sim target
19+
lipo -create \
20+
"./target/aarch64-apple-ios/debug/libbevy_ios_iap.a" \
21+
"./target/x86_64-apple-ios/debug/libbevy_ios_iap.a" \
22+
-output ./target/universal-ios/debug/libbevy_ios_iap.a

bevy_ios_iap/justfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
check:
2+
cargo c
3+
cargo c --target=aarch64-apple-ios
4+
cargo clippy
5+
cargo fmt -- --check

bevy_ios_iap/src/native.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::unnecessary_cast)]
2+
13
use std::sync::OnceLock;
24

35
use bevy_crossbeam_event::CrossbeamEventSender;
@@ -6,13 +8,13 @@ use bevy_crossbeam_event::CrossbeamEventSender;
68
pub use ffi::*;
79

810
use crate::{
9-
plugin::{IosIapEvents, IosIapResponse},
10-
transaction::IosIapTransaction,
1111
IosIapCurrency, IosIapEnvironment, IosIapProduct, IosIapProductType, IosIapProductsResponse,
1212
IosIapPurchaseError, IosIapPurchaseResponse, IosIapRevocationReason, IosIapStoreKitError,
1313
IosIapStorefront, IosIapSubscriptionInfo, IosIapSubscriptionPeriod,
1414
IosIapSubscriptionPeriodUnit, IosIapSubscriptionRenewalState, IosIapSubscriptionStatus,
1515
IosIapTransactionFinishResponse, IosIapTransactionReason, IosIapTransactionResponse,
16+
plugin::{IosIapEvents, IosIapResponse},
17+
transaction::IosIapTransaction,
1618
};
1719

1820
#[swift_bridge::bridge]
@@ -246,12 +248,12 @@ static SENDER_RESPONSE: OnceLock<Option<CrossbeamEventSender<IosIapResponse>>> =
246248

247249
#[allow(dead_code)]
248250
pub fn set_sender_events(sender: CrossbeamEventSender<IosIapEvents>) {
249-
while !SENDER_EVENTS.set(Some(sender.clone())).is_ok() {}
251+
while SENDER_EVENTS.set(Some(sender.clone())).is_err() {}
250252
}
251253

252254
#[allow(dead_code)]
253255
pub fn set_sender_response(sender: CrossbeamEventSender<IosIapResponse>) {
254-
while !SENDER_RESPONSE.set(Some(sender.clone())).is_ok() {}
256+
while SENDER_RESPONSE.set(Some(sender.clone())).is_err() {}
255257
}
256258

257259
fn transaction_update(t: IosIapTransaction) {

0 commit comments

Comments
 (0)