Cargo Features

[dependencies]
objc2 = { version = "0.5.2", default-features = false, features = ["std", "alloc", "exception", "catch-all", "relax-void-encoding", "relax-sign-encoding", "unstable-msg-send-always-comma", "malloc", "verify", "unstable-static-sel", "unstable-static-sel-inlined", "unstable-static-class", "unstable-static-class-inlined", "unstable-autoreleasesafe", "unstable-c-unwind", "unstable-apple-new", "apple", "gnustep-1-7", "gnustep-1-8", "gnustep-1-9", "gnustep-2-0", "gnustep-2-1", "unstable-compiler-rt"] }

NOTE: 'unstable' features are _not_ considered part of the SemVer contract,
and may be removed in a minor release.

default = std

The std feature is set by default whenever objc2 is added without default-features = false somewhere in the dependency tree.

std default = alloc

Currently not possible to turn off, put here for forwards compatibility.

Enables std of objc-sys and objc2-encode

alloc std

Enables alloc of objc-sys and objc2-encode

objc2-encode:

Currently not possible to turn off, put here for forwards compatibility

exception catch-all?

Enables objc2::exception::throw and objc2::exception::catch

Enables unstable-exception of objc-sys

catch-all = exception

Wrap every objc2::msg_send call in a @try/@catch block

relax-void-encoding

Allow *const c_void and *mut c_void to be used as arguments and return types where other pointers were expected.

This may be useful for CoreFoundation types, or for migrating code from objc to objc2.

relax-sign-encoding

Make signed and unsigned types interchangable when used as arguments/return types in methods.

This may be useful for dealing with Swift code that incorrectly uses Int instead of UInt.

unstable-msg-send-always-comma

Enable deprecation of using msg_send! without a comma between arguments.

malloc = malloc_buf

This was necessary to access certain functionality in the past, but it is no longer required.

verify

This was necessary to enable certain debug assertions in the past, but it is no longer required.

unstable-static-sel unstable-static-sel-inlined? = objc2-proc-macros

Make the sel! macro look up the selector statically.

The plan is to enable this by default, but right now we are uncertain of its stability, and it might need significant changes before being fully ready!

Please test it, and report any issues you may find: https://github.com/madsmtm/objc2/issues/new

unstable-static-sel-inlined = unstable-static-sel
unstable-static-class gnustep-1-7? unstable-static-class-inlined? = objc2-proc-macros
unstable-static-class-inlined = unstable-static-class
unstable-autoreleasesafe

Uses nightly features to make autorelease pools fully sound

unstable-c-unwind

Uses the nightly c_unwind feature to make throwing safe

You must manually enable objc-sys/unstable-c-unwind to use this.

unstable-apple-new

Enable some new features available on ARM64 on:

  • macOS 13.0
  • iOS 16.0
  • tvOS 16.0
  • watchOS 9.0

See https://developer.apple.com/videos/play/wwdc2022/110363/ for an overview of the features.

Currently untested, might be unsound or lead to confusing compiler errors.

Additionally, the message sending improvements is not yet implemented.

apple

Deprecated; this is the default on Apple platforms, and not applicable on other platforms.

gnustep-1-7 gnustep-1-8? unstable-compiler-rt? = unstable-static-class

Runtime selection. See objc-sys for details.

unstable-static-class is always enabled on GNUStep, as it fails to link in release mode otherwise.

Enables gnustep-1-7 of objc-sys

Affects __nsstring::UTF8_ENCODING

gnustep-1-8 gnustep-1-9? = gnustep-1-7

Enables gnustep-1-8 of objc-sys

gnustep-1-9 gnustep-2-0? = gnustep-1-8

Enables gnustep-1-9 of objc-sys

gnustep-2-0 gnustep-2-1? = gnustep-1-9

Enables gnustep-2-0 of objc-sys

gnustep-2-1 = gnustep-2-0

Enables gnustep-2-1 of objc-sys

unstable-compiler-rt = gnustep-1-7

Used by block2

Features from optional dependencies

In crates that don't use the dep: syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.

malloc_buf malloc?
objc2-proc-macros unstable-static-class? unstable-static-sel?