Skip to content

Commit 4ec407e

Browse files
committed
Update CI
- Add tvOS, watchOS and visionOS. - Add more docs. - Remove `new-versions` branch. - Fix confusions around x86_64 vs Aarch64 runners, see: https://github.com/actions/runner-images. - Fix GNUStep. - Fix compiling examples on Mac Catalyst.
1 parent e58bb10 commit 4ec407e

File tree

7 files changed

+172
-65
lines changed

7 files changed

+172
-65
lines changed

.github/workflows/ci.yml

Lines changed: 106 additions & 61 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ If you're confused about this, don't worry too much about it, if you enable
7373
Copy and fill out the following checklist into the release PR:
7474

7575
```markdown
76-
- [ ] The branch is named `new-versions`, such that the full CI will run.
76+
- [ ] The branch is named `ci-full`, such that the full CI will run.
7777
- [ ] Changelogs have only been modified under the `Unreleased` header.
7878
- [ ] Version numbers are bumped in the following order:
7979
- `objc2-proc-macros`

crates/header-translator/src/main.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,15 @@ fn update_ci(workspace_dir: &Path, config: &Config) -> io::Result<()> {
490490
.is_some_and(|v| VersionReq::parse("<=10.12").unwrap().matches(v))
491491
// HACK: These depend on `objc2-uniform-type-identifiers`, which
492492
// is not available on macOS 10.12, but will be enabled by `"all"`
493-
&& !["objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
493+
&& !["objc2-app-kit", "objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
494494
})?;
495495
writer(&mut ci, config, "FRAMEWORKS_MACOS_10_13", |lib| {
496496
lib.macos
497497
.as_ref()
498498
.is_some_and(|v| VersionReq::parse("<=10.13").unwrap().matches(v))
499499
// HACK: These depend on `objc2-uniform-type-identifiers`, which
500500
// is not available on macOS 10.13, but will be enabled by `"all"`
501-
&& !["objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
501+
&& !["objc2-app-kit", "objc2-file-provider", "objc2-health-kit", "objc2-photos"].contains(&&*lib.krate)
502502
})?;
503503
writer(&mut ci, config, "FRAMEWORKS_MACOS_11", |lib| {
504504
lib.macos
@@ -520,11 +520,43 @@ fn update_ci(workspace_dir: &Path, config: &Config) -> io::Result<()> {
520520
.as_ref()
521521
.is_some_and(|v| VersionReq::parse("<=14.0").unwrap().matches(v))
522522
})?;
523+
writer(&mut ci, config, "FRAMEWORKS_MACOS_15", |lib| {
524+
lib.macos
525+
.as_ref()
526+
.is_some_and(|v| VersionReq::parse("<=15.0").unwrap().matches(v))
527+
})?;
523528
writer(&mut ci, config, "FRAMEWORKS_IOS_10", |lib| {
524529
lib.ios
525530
.as_ref()
526531
.is_some_and(|v| VersionReq::parse("<=10.0").unwrap().matches(v))
527532
})?;
533+
writer(&mut ci, config, "FRAMEWORKS_IOS_17", |lib| {
534+
lib.ios
535+
.as_ref()
536+
.is_some_and(|v| VersionReq::parse("<=17.0").unwrap().matches(v))
537+
// HACK: MLCompute and MetalFX are only available on Aarch64
538+
&& !["objc2-ml-compute", "objc2-metal-fx"].contains(&&*lib.krate)
539+
})?;
540+
writer(&mut ci, config, "FRAMEWORKS_TVOS_17", |lib| {
541+
lib.tvos
542+
.as_ref()
543+
.is_some_and(|v| VersionReq::parse("<=17.0").unwrap().matches(v))
544+
})?;
545+
writer(&mut ci, config, "FRAMEWORKS_MAC_CATALYST_17", |lib| {
546+
lib.maccatalyst
547+
.as_ref()
548+
.is_some_and(|v| VersionReq::parse("<=17.0").unwrap().matches(v))
549+
})?;
550+
writer(&mut ci, config, "FRAMEWORKS_VISIONOS_1", |lib| {
551+
lib.visionos
552+
.as_ref()
553+
.is_some_and(|v| VersionReq::parse("<=1.0").unwrap().matches(v))
554+
})?;
555+
writer(&mut ci, config, "FRAMEWORKS_WATCHOS_10", |lib| {
556+
lib.watchos
557+
.as_ref()
558+
.is_some_and(|v| VersionReq::parse("<=10.0").unwrap().matches(v))
559+
})?;
528560
writer(&mut ci, config, "FRAMEWORKS_GNUSTEP", |lib| lib.gnustep)?;
529561

530562
write!(&mut ci, " # END AUTOMATICALLY GENERATED{after}")?;

crates/objc2/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static_assertions = "1.1.0"
123123
memoffset = "0.9.0"
124124
block2 = { path = "../block2", default-features = false }
125125
objc2-foundation = { path = "../../framework-crates/objc2-foundation", default-features = false, features = [
126+
"NSArray",
126127
"NSDate",
127128
"NSDictionary",
128129
"NSEnumerator",

framework-crates/objc2-metal/examples/triangle.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![deny(unsafe_op_in_unsafe_fn)]
22
#![allow(clippy::incompatible_msrv)]
3+
#![cfg_attr(not(target_os = "macos"), allow(dead_code, unused))]
34

45
use core::{cell::OnceCell, ptr::NonNull};
56

@@ -8,6 +9,7 @@ use objc2::runtime::ProtocolObject;
89
use objc2::{
910
declare_class, msg_send_id, ClassType, DeclaredClass, MainThreadMarker, MainThreadOnly,
1011
};
12+
#[cfg(target_os = "macos")]
1113
use objc2_app_kit::{
1214
NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate, NSBackingStoreType,
1315
NSWindow, NSWindowStyleMask,
@@ -20,6 +22,7 @@ use objc2_metal::{
2022
MTLLibrary, MTLPackedFloat3, MTLPrimitiveType, MTLRenderCommandEncoder,
2123
MTLRenderPipelineDescriptor, MTLRenderPipelineState,
2224
};
25+
#[cfg(target_os = "macos")]
2326
use objc2_metal_kit::{MTKView, MTKViewDelegate};
2427

2528
#[derive(Copy, Clone)]
@@ -58,6 +61,7 @@ struct Ivars {
5861
start_date: Retained<NSDate>,
5962
command_queue: OnceCell<Retained<ProtocolObject<dyn MTLCommandQueue>>>,
6063
pipeline_state: OnceCell<Retained<ProtocolObject<dyn MTLRenderPipelineState>>>,
64+
#[cfg(target_os = "macos")]
6165
window: OnceCell<Retained<NSWindow>>,
6266
}
6367

@@ -82,6 +86,7 @@ declare_class!(
8286
unsafe impl NSObjectProtocol for Delegate {}
8387

8488
// define the delegate methods for the `NSApplicationDelegate` protocol
89+
#[cfg(target_os = "macos")]
8590
unsafe impl NSApplicationDelegate for Delegate {
8691
#[method(applicationDidFinishLaunching:)]
8792
#[allow(non_snake_case)]
@@ -176,6 +181,7 @@ declare_class!(
176181
}
177182

178183
// define the delegate methods for the `MTKViewDelegate` protocol
184+
#[cfg(target_os = "macos")] // TODO: Support iOS
179185
unsafe impl MTKViewDelegate for Delegate {
180186
#[method(drawInMTKView:)]
181187
#[allow(non_snake_case)]
@@ -288,12 +294,14 @@ impl Delegate {
288294
start_date: unsafe { NSDate::now() },
289295
command_queue: OnceCell::default(),
290296
pipeline_state: OnceCell::default(),
297+
#[cfg(target_os = "macos")]
291298
window: OnceCell::default(),
292299
});
293300
unsafe { msg_send_id![super(this), init] }
294301
}
295302
}
296303

304+
#[cfg(target_os = "macos")]
297305
fn main() {
298306
let mtm = MainThreadMarker::new().unwrap();
299307
// configure the app
@@ -308,3 +316,8 @@ fn main() {
308316
// run the app
309317
app.run();
310318
}
319+
320+
#[cfg(not(target_os = "macos"))]
321+
fn main() {
322+
panic!("This example is currently only supported on macOS");
323+
}

framework-crates/objc2-web-kit/examples/browser.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![deny(unsafe_op_in_unsafe_fn)]
22
#![allow(clippy::incompatible_msrv)]
3+
#![cfg_attr(not(target_os = "macos"), allow(dead_code, unused))]
34
use core::cell::OnceCell;
45

56
use objc2::{
@@ -9,6 +10,7 @@ use objc2::{
910
sel, ClassType, DeclaredClass, MainThreadMarker, MainThreadOnly,
1011
};
1112
#[allow(deprecated)]
13+
#[cfg(target_os = "macos")]
1214
use objc2_app_kit::{
1315
NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate, NSBackingStoreType,
1416
NSBezelStyle, NSButton, NSColor, NSControl, NSControlTextEditingDelegate, NSLayoutAttribute,
@@ -19,6 +21,7 @@ use objc2_foundation::{
1921
ns_string, NSNotification, NSObject, NSObjectProtocol, NSPoint, NSRect, NSSize, NSURLRequest,
2022
NSURL,
2123
};
24+
#[cfg(target_os = "macos")]
2225
use objc2_web_kit::{WKNavigation, WKNavigationDelegate, WKWebView};
2326

2427
macro_rules! idcell {
@@ -41,8 +44,11 @@ macro_rules! idcell {
4144

4245
#[derive(Default)]
4346
struct Ivars {
47+
#[cfg(target_os = "macos")]
4448
nav_url: OnceCell<Retained<NSTextField>>,
49+
#[cfg(target_os = "macos")]
4550
web_view: OnceCell<Retained<WKWebView>>,
51+
#[cfg(target_os = "macos")]
4652
window: OnceCell<Retained<NSWindow>>,
4753
}
4854

@@ -65,6 +71,7 @@ declare_class!(
6571

6672
unsafe impl NSObjectProtocol for Delegate {}
6773

74+
#[cfg(target_os = "macos")]
6875
unsafe impl NSApplicationDelegate for Delegate {
6976
#[method(applicationDidFinishLaunching:)]
7077
#[allow(non_snake_case)]
@@ -245,6 +252,7 @@ declare_class!(
245252
}
246253
}
247254

255+
#[cfg(target_os = "macos")]
248256
unsafe impl NSControlTextEditingDelegate for Delegate {
249257
#[method(control:textView:doCommandBySelector:)]
250258
#[allow(non_snake_case)]
@@ -265,8 +273,10 @@ declare_class!(
265273
}
266274
}
267275

276+
#[cfg(target_os = "macos")]
268277
unsafe impl NSTextFieldDelegate for Delegate {}
269278

279+
#[cfg(target_os = "macos")] // TODO: Enable this on iOS
270280
unsafe impl WKNavigationDelegate for Delegate {
271281
#[method(webView:didFinishNavigation:)]
272282
#[allow(non_snake_case)]
@@ -293,6 +303,7 @@ impl Delegate {
293303
}
294304
}
295305

306+
#[cfg(target_os = "macos")]
296307
fn main() {
297308
let mtm = MainThreadMarker::new().unwrap();
298309
let app = NSApplication::sharedApplication(mtm);
@@ -306,3 +317,8 @@ fn main() {
306317
// run the app
307318
app.run();
308319
}
320+
321+
#[cfg(not(target_os = "macos"))]
322+
fn main() {
323+
panic!("This example is currently only supported on macOS");
324+
}

helper-scripts/test-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euxo pipefail
66
export CARGO_TARGET_DIR=$HOME/Desktop/objc2-target
77
export MACOSX_DEPLOYMENT_TARGET=10.12
88
export CRATES='--package=block2 --package=objc2 --package=objc2-encode --package=objc2-proc-macros --package=tests'
9-
export FRAMEWORKS_MACOS_10_12='--package=objc2-accounts --package=objc2-app-kit --package=objc2-automator --package=objc2-av-kit --package=objc2-cloud-kit --package=objc2-contacts --package=objc2-contacts-ui --package=objc2-core-bluetooth --package=objc2-core-data --package=objc2-core-image --package=objc2-core-location --package=objc2-core-wlan --package=objc2-event-kit --package=objc2-exception-handling --package=objc2-finder-sync --package=objc2-foundation --package=objc2-game-controller --package=objc2-game-kit --package=objc2-input-method-kit --package=objc2-local-authentication --package=objc2-map-kit --package=objc2-media-player --package=objc2-metal --package=objc2-metal-kit --package=objc2-multipeer-connectivity --package=objc2-network-extension --package=objc2-osa-kit --package=objc2-photos-ui --package=objc2-quartz-core --package=objc2-screen-saver --package=objc2-service-management --package=objc2-social --package=objc2-store-kit --package=objc2-web-kit'
9+
export FRAMEWORKS_MACOS_10_12='--package=objc2-accounts --package=objc2-automator --package=objc2-av-kit --package=objc2-cloud-kit --package=objc2-contacts --package=objc2-contacts-ui --package=objc2-core-bluetooth --package=objc2-core-data --package=objc2-core-image --package=objc2-core-location --package=objc2-core-wlan --package=objc2-event-kit --package=objc2-exception-handling --package=objc2-finder-sync --package=objc2-foundation --package=objc2-game-controller --package=objc2-game-kit --package=objc2-input-method-kit --package=objc2-local-authentication --package=objc2-map-kit --package=objc2-media-player --package=objc2-metal --package=objc2-metal-kit --package=objc2-multipeer-connectivity --package=objc2-network-extension --package=objc2-osa-kit --package=objc2-photos-ui --package=objc2-quartz-core --package=objc2-screen-saver --package=objc2-service-management --package=objc2-social --package=objc2-store-kit --package=objc2-web-kit'
1010
export FRAMEWORKS_IOS_9='--package=objc2-foundation --package=objc2-metal'
1111

1212
# Test on macOS 32bit

0 commit comments

Comments
 (0)