Cargo Features
[dependencies]
objc2 = { version = "0.6.0", default-features = false, features = ["std", "alloc", "exception", "catch-all", "relax-void-encoding", "relax-sign-encoding", "disable-encoding-assertions", "verify", "unstable-static-sel", "unstable-static-sel-inlined", "unstable-static-class", "unstable-static-class-inlined", "unstable-autoreleasesafe", "unstable-apple-new", "unstable-arbitrary-self-types", "unstable-coerce-pointee", "gnustep-1-7", "gnustep-1-8", "gnustep-1-9", "gnustep-2-0", "gnustep-2-1", "unstable-compiler-rt", "unstable-gnustep-strict-apple-compat", "unstable-winobjc", "unstable-objfw", "unstable-requires-macos"] }
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 wheneverobjc2
is added without
somewhere in the dependency tree.default-features = false - std default = alloc
-
Currently not possible to turn off, put here for forwards compatibility.
Enables std of objc2-encode
- alloc std
-
Enables alloc of objc2-encode
objc2-encode:
Currently not possible to turn off, put here for forwards compatibility
- exception catch-all?
-
Enables
objc2::exception::throw
andobjc2::exception::catch
Enables objc2-exception-helper
- 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 ofUInt
. - disable-encoding-assertions
-
Fully disable debug assertions on invalid encodings.
Sometimes, the method encoding registered with the runtime doesn't match the encoding in the header. This happens for example in NSUUID methods, see: https://github.com/madsmtm/objc2/issues/671
Furthermore, sometimes a method may just not be visible to the runtime before we actually send a message to it, see: https://github.com/madsmtm/objc2/issues/645
Ideally,
objc2
's encoding checks should not encounter these issues, but that is not the state we are in, so for now, this can be used to work around them by disabling all encoding checks. - 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-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.
- unstable-arbitrary-self-types
-
Uses the nightly arbitrary_self_types feature to make initialization more ergonomic.
- unstable-coerce-pointee
-
Uses the nightly derive_coerce_pointee feature to make conversions more ergonomic.
- gnustep-1-7 gnustep-1-8? unstable-compiler-rt? unstable-gnustep…apple-compat? = unstable-static-class
-
Compile for GNUStep's libobjc2
unstable-static-class
is always enabled on GNUStep, as it fails to link in release mode otherwise.Default in clang is 1.6, GNUStep's own default is 1.8, we only support 1.7 and up.
Enables gnustep-1-7 of optional objc2-exception-helper
Affects
__nsstring::UTF8_ENCODING
… - gnustep-1-8 gnustep-1-9? unstable-winobjc? = gnustep-1-7
-
Enables gnustep-1-8 of optional objc2-exception-helper
- gnustep-1-9 gnustep-2-0? = gnustep-1-8
-
Enables gnustep-1-9 of optional objc2-exception-helper
- gnustep-2-0 gnustep-2-1? = gnustep-1-9
-
Enables gnustep-2-0 of optional objc2-exception-helper
- gnustep-2-1 = gnustep-2-0
-
Enables gnustep-2-1 of optional objc2-exception-helper
- unstable-compiler-rt = gnustep-1-7
-
Used by
block2
- unstable-gnustep-strict-apple-compat = gnustep-1-7
-
Enable the equivalent of GNUStep's
STRICT_APPLE_COMPATIBILITY
- unstable-winobjc = gnustep-1-8
-
Link to Microsoft's WinObjC libobjc2
This is a fork of gnustep's from version 1.8 - unstable-objfw
-
Link to ObjFW. Default in clang is version 0.8
- unstable-requires-macos
-
The hello world app example requires macOS.
Workaround for Cargo not supporting target-specific examples.
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.