Short answer

The C++26 draft failed its ISO ballot, mainly over Contracts and the way standard library hardening was tied to them. You do not have to wait for the standard: the hardening checks are already in the libc++ that ships with Xcode. Find out whether your iOS app compiles any C++ or Objective-C++, turn on debug hardening in Debug builds, fix what it catches, and ship the fast mode in Release with -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST or the Enhanced Security capability. A precompiled binary framework keeps whatever mode its author used.

The draft of C++26 failed its international ballot. According to the vote summary quoted in a widely shared write-up published on November 11, 12 of the 20 voting P-members approved the draft, which is 60% against a required two thirds, and 9 of the 22 member bodies that voted said no, which is 41% against a ceiling of 25%. The same write-up says these are the first Disapprove votes any C++ draft international standard has received. The main fight is over Contracts, the pre, post and contract_assert feature, and over the way the standard library hardening rules were tied to it.

If you write iOS apps, you may think this has nothing to do with you. Your app is Swift. But open the build log of almost any app that uses a cross-platform framework, a media library, a database engine or a game engine and you will find .cpp and .mm files being compiled by clang against Apple's libc++. Apps built quickly with AI tools pick up these dependencies without anyone looking at them. And the safety checks that C++26 tried to standardize are already in the libc++ that ships with Xcode, behind one build setting and one macro. You do not need to wait for WG21 to use them.

This post covers what happened at the vote, what the hardening checks do, and how to turn them on in an iOS project today, with a test program you can run in a minute.

What failed, in plain terms

A C++ standard goes through a draft stage, then a ballot in which national standards bodies vote. The C++26 draft reached that ballot and did not get enough approvals. The write-up reports that 12 countries abstained, some because their own committees could not agree on a position.

Contracts let a function declare what must be true when it is called (pre), what it promises on return (post), and checks inside the body (contract_assert). How those checks behave when they fail is chosen at build time: ignore, observe, or enforce. Critics worry about checks that may not run at all, about interactions with undefined behavior, constexpr and inlining, and about whether a safety feature should allow a mode where the check is skipped. Contracts were voted into the working draft at the February 2025 meeting in Hagenberg, 100 in favor, 14 against and 12 abstaining. Later attempts to remove them, or to make enforcement mandatory, failed in committee.

Standard library hardening is the part that matters most for app code. It turns some of the most common kinds of undefined behavior in the library, such as reading past the end of a std::vector with operator[] or dereferencing an empty std::optional, into a guaranteed stop. In the C++26 draft that hardening is specified in terms of Contracts. Several national body comments asked for the two to be separated, and the committee kept them together.

The next WG21 meeting is scheduled for November 16 to 21 in Búzios. The write-up estimates that a fixed draft and a new ballot could take about a year, and that features could slip to the following three-year cycle if C++26 fails outright. Treat both as one author's estimate. The vote numbers come from the posted summary; the timeline does not come from ISO.

Why an iOS developer should care

Swift arrays already stop your app when you index out of range. That check is part of the language. C++ code inside the same app gets no such check by default. If a C++ dependency reads past the end of a buffer, the read returns whatever bytes sit there, and the app keeps going with bad data. That is the kind of bug that shows up as a crash nobody can reproduce, as corrupted output, or in the worst case as a memory safety hole an attacker can use.

Here is where C++ tends to hide in an iOS project:

  • Cross-platform frameworks and their native modules, which often include .cpp or Objective-C++ .mm files.
  • Libraries for images, audio, video, PDF, maps, physics and machine learning.
  • Database engines and sync SDKs.
  • Anything a coding agent added because it solved the problem in front of it.

You can find out in a few seconds. From the root of your repository:

# Count C++ and Objective-C++ sources, including those in Pods and SPM checkouts
find . \( -name '*.cpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.mm' \) \
  -not -path '*/DerivedData/*' | awk -F/ '{print $2"/"$3}' | sort | uniq -c | sort -rn | head -20

If that prints nothing, your own targets and checked-out dependencies have no C++ sources, and the rest of this post is optional reading. Note that precompiled binary frameworks will not show up in that list, and hardening at compile time cannot reach code that was compiled by someone else.

The checks are already in Xcode's libc++

The libc++ hardening documentation defines four modes, chosen with the _LIBCPP_HARDENING_MODE macro:

ModeMacro valueWhat it checksUse it for
None_LIBCPP_HARDENING_MODE_NONENothingThe vendor default
Fast_LIBCPP_HARDENING_MODE_FASTValid element access and valid input ranges, in constant timeRecommended by libc++ for most production code
Extensive_LIBCPP_HARDENING_MODE_EXTENSIVEFast, plus null checks, overlapping ranges, bad deallocation, allocator mismatches and moreProduction after you benchmark it
Debug_LIBCPP_HARDENING_MODE_DEBUGEverything, including internal library invariants and expensive heuristicsDebug builds and tests only

Each mode includes the checks of the one above it. The libc++ page says the macro must be set before any standard library header is included, and that mode changes do not affect the ABI, although some extra iterator checks need ABI options that only the library vendor can turn on.

The libc++ page also lists assertion semantics: ignore, observe, quick-enforce and enforce. Fast and extensive default to quick-enforce, which traps as fast as possible. Debug defaults to enforce, which logs a message and then terminates. The page says these semantics are based on the C++26 Contracts evaluation semantics, and that the C++26 hardening wording does not allow a conforming hardened implementation to skip the check. So libc++ already ships the behavior the committee is still arguing about, as a vendor extension you can use now.

What Apple turns on for you

Apple's article Enabling enhanced security for your app describes the Enhanced Security capability. When you add it to a target, Xcode sets the ENABLE_CPLUSPLUS_BOUNDS_SAFE_BUFFERS build setting to YES. Apple says this enables the fast hardening mode of the C++ standard library. In that mode the library checks that element accesses exist in the collection, including in std::function and std::optional, and that ranges passed to algorithms are valid. A failed check crashes the app.

The same setting does one more thing that catches people out. Apple says it also turns on compiler warnings for unsafe buffer usage in C++ and treats them as errors. The compiler will then reject code that indexes an array or does pointer arithmetic on raw pointers, calls operator[] on a smart pointer to an array, or builds a std::span from a pointer and a size. On a large third-party C++ library, that can mean hundreds of build errors on day one.

That gives you two paths.

Path 1: the full Enhanced Security capability

  1. Select your app target in Xcode and open the Signing and Capabilities editor.
  2. Click the Add Capability button and pick Enhanced Security.
  3. Use the checkboxes in the capability to choose the protections you want.
  4. Build. Fix or suppress the unsafe buffer errors the compiler now reports.
  5. Run your test suite and use the app on a device before you ship.

Enhanced Security brings more than C++ hardening. Apple lists typed allocators, zero-initialized stack variables, extra security warnings, read-only platform memory, additional runtime restrictions, and options for pointer authentication and hardware memory tagging. Apple's own warning is direct: these checks can affect the performance and stability of an app that was not built with security in mind, so review your threat model and test thoroughly. This path makes sense for apps that handle sensitive data and teams that own their C++ code.

Path 2: library hardening only

If you only want the library checks and are not ready for the buffer warnings as errors, define the macro yourself. The libc++ documentation says users enable a mode by passing the macro to the compiler, and Apple's article shows the same macro values for setting the mode per file. In an .xcconfig file for your target:

// Hardening.xcconfig
// Fast libc++ hardening for all C++ and Objective-C++ in this target.
OTHER_CPLUSPLUSFLAGS = $(inherited) -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST

// Optional: everything in Debug builds, including the slow heuristic checks.
OTHER_CPLUSPLUSFLAGS[config=Debug] = $(inherited) -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG

You can also set the same value in the target's Build Settings under Other C++ Flags. Because the flag reaches the compiler before any header is read, it meets the libc++ rule that the macro be defined first.

To change the mode for a single file, for example a hot loop you have benchmarked, Apple's article says to define the macro at the top of the file before any standard library include:

// ImageKernel.cpp
// This file was profiled; extensive mode cost too much in the inner loop.
#define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_NONE
#include <vector>
#include <algorithm>

If you also pass the macro on the command line, clang warns that the macro was redefined (-Wmacro-redefined). Remove the flag for that file or accept the warning, but do not leave it ambiguous which mode a file uses.

Dependencies in CocoaPods

Pods build in their own targets, so a flag on your app target does not reach them. A post_install hook can add the flag to every pod target. This snippet has not been tested against a real Podfile, so run pod install and then check the generated build settings before you rely on it:

# Podfile (add inside your existing post_install block if you have one)
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      flags = config.build_settings['OTHER_CPLUSPLUSFLAGS'] || ['$(inherited)']
      flags = [flags] if flags.is_a?(String)
      flags << '-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST'
      config.build_settings['OTHER_CPLUSPLUSFLAGS'] = flags.uniq
    end
  end
end

Swift packages are harder. You cannot change how SwiftPM compiles a package you do not own from your app target's settings. For a package you do own, add the define in Package.swift with cxxSettings: [.define("_LIBCPP_HARDENING_MODE", to: "_LIBCPP_HARDENING_MODE_FAST")]. For a package you do not own, ask the maintainer, fork it, or accept that it runs unhardened. If a package refuses to resolve after a change like this, Fix "Missing Package Product" Errors in Xcode lists the usual causes.

See it work before you trust it

The fastest way to believe a safety check is to watch it fire. Save this as oob.cpp:

#include <cstdio>
#include <vector>

int main(int argc, char**) {
    std::vector<int> scores = {90, 72, 85};
    std::size_t i = 2 + argc;   // 3 with no arguments: one past the end
    std::fprintf(stderr, "reading index %zu\n", i);
    int v = scores[i];          // out of bounds
    std::fprintf(stderr, "got %d\n", v);
    return 0;
}

Build it twice and compare:

clang++ -std=c++20 -stdlib=libc++ -O2 \
  -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE oob.cpp -o oob_none
./oob_none; echo "exit $?"

clang++ -std=c++20 -stdlib=libc++ -O2 \
  -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST oob.cpp -o oob_fast
./oob_fast; echo "exit $?"

This program was tested with clang 18.1.3 and libc++ 18 on Linux, not on a Mac. With hardening off, it printed reading index 3, then got 0, and exited normally after reading memory it does not own. With fast mode it printed reading index 3 and stopped at the bad read with an illegal instruction trap (exit code 132 on Linux). A dereference of an empty std::optional behaved the same way. With debug mode the library printed vector[] index out of bounds with the header line before aborting. On macOS, clang++ from Xcode uses Apple's libc++ by default, so -stdlib=libc++ is redundant there; the exact crash type and message differ from the Linux results above, as the next section shows.

Inside an iOS app, a trap from fast mode shows up as a crash in the libc++ header that made the check, with your calling function a frame or two below it. That stack is far easier to act on than a crash in some unrelated code ten minutes after the bad read happened.

The same test with Apple clang on a Mac

The test program was also built with Apple clang 17 from Xcode 26.2 on macOS 26.0.1, once for each mode and once with no macro at all, which is what an Xcode project does by default. Each binary was run with no arguments:

mode         exit  what it printed
NONE         0     reading index 3 / got 0
FAST         133   reading index 3   (Trace/BPT trap: 5)
EXTENSIVE    133   reading index 3   (Trace/BPT trap: 5)
DEBUG        134   reading index 3 / __vector/vector.h:403: assertion __n < size() failed: vector[] index out of bounds   (Abort trap: 6)
no macro     0     reading index 3 / got 0

Three differences from the Linux run are worth knowing. Fast and extensive mode stop with a breakpoint trap, signal 5, so the shell reports exit code 133 and not the 132 of an illegal instruction. Debug mode aborts with signal 6 and prints the header path and line, which in Apple's libc++ is __vector/vector.h:403. And the build with no macro behaved exactly like NONE: it read past the end and printed a value. That is the important row. Nothing in a default Xcode build checks these accesses until you set the mode or add the capability.

An empty std::optional behaved the same way: with NONE the program printed whatever value happened to be there, and with fast mode it trapped before printing. The test file also built for the iOS Simulator with the fast macro, so the flag is accepted for iOS targets too. The simulator binary was not run.

Does the Package.swift define reach the C++ code?

The cxxSettings route for packages you own was tested with a small package: a C++ target that reads from a three-element std::vector, and a Swift executable that calls it with index 1 and then index 3.

// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "Scores",
    targets: [
        .target(
            name: "Scores",
            cxxSettings: [.define("_LIBCPP_HARDENING_MODE", to: "_LIBCPP_HARDENING_MODE_FAST")]
        ),
        .executableTarget(name: "demo", dependencies: ["Scores"]),
    ],
    cxxLanguageStandard: .cxx20
)

Built with Swift 6.2.3 and run, it stopped with "Trace/BPT trap: 5" and exit code 133. With cxxSettings emptied and the package rebuilt, the same call returned 0 for index 3 and the program exited normally. So the define reaches the C++ target, and Swift code calling into it gets the same trap.

One detail from that run will matter when you debug a real crash: the line for index 1 never appeared in the hardened run. Swift's print was buffered because the output went to a pipe, and the trap killed the process before the buffer was written. The last log line you see may be several calls before the one that crashed. The crash report's stack trace is the reliable record.

What was checked in the Podfile hook

The post_install hook was not run against a real Podfile. Its flag-merging logic was run with the system Ruby, using stand-in objects for three pod targets: one with no C++ flags, one whose flags were a single string, and one whose flags were already a list. After the hook ran twice, as it would on a second pod install, every target ended with the hardening flag exactly once and kept its existing flags. The string case stays as one element, "$(inherited) -DFOO=1", which Xcode reads correctly. Check the generated build settings in the Pods project after your first real pod install.

The per-file override in the previous section was also confirmed: a file that defines the macro itself, compiled with the macro also on the command line, produced the -Wmacro-redefined warning described above.

Roll it out without breaking your users

Hardening converts silent bugs into crashes. If your C++ code has a latent out-of-bounds read that happens to return harmless data today, the hardened build will crash where the old one carried on. That is the point, but you want to find those crashes before your users do.

  1. Find the C++. Run the find command above and list which targets and dependencies compile C++.
  2. Turn on debug mode in Debug builds first. Run the full test suite and your UI tests. Every assertion that fires here is a real bug.
  3. Fix or report each failure. For your own code, fix the index or range. For a dependency, check for a newer version, then report the issue upstream with the assertion text.
  4. Turn on fast mode in Release. Ship it through TestFlight to internal testers before the App Store.
  5. Watch crash reports. A new cluster of crashes in libc++ headers after the release means hardening found something. The fix is in the caller, never in turning the check off.
  6. Benchmark before extensive mode. libc++ recommends measuring first. Profile the screens that do heavy C++ work with Instruments before and after.

For App Store review, a crash on launch is the worst outcome. Guideline 2.1(a) of Apple's App Review Guidelines asks you to test on device for bugs and stability, and says Apple will reject binaries that crash or show obvious technical problems. Run a Release build on a physical device through the paths a reviewer will take, sign in, the main screen, a purchase if you have one, before you submit a hardened build. Guideline 2.1 Rejection: Why Your AI-Built App Crashed in App Review explains what that rejection looks like.

What C++26's delay changes for you

Very little in the short term. Clang and libc++ do not wait for ISO to approve a standard before shipping pieces of it, and the hardening modes described here are libc++ features you can turn on with today's Xcode. What the delay changes is the standard wording that other library implementations would follow, and the timeline for Contracts as a portable language feature you can write in your own code.

If you were planning to write pre and post conditions in cross-platform C++ code, hold off. The feature might change before it is approved, and the committee might remove it or change its enforcement rules after the Búzios meeting. Use ordinary assertions or your own checking macros for now, and keep them easy to replace.

If you only consume C++ through dependencies, the action list is short: find it, harden it in Debug, ship fast mode in Release, and watch your crash reports.

FAQ

Does this affect my Swift code?
No. The hardening macro changes the C++ standard library headers. Swift collections already check bounds at runtime.

Will fast mode slow my app down?
libc++ describes the fast checks as constant time with relatively little overhead and recommends them for most production projects. Measure the screens that do heavy C++ work anyway.

Can I turn it on for a binary framework I downloaded?
No. The checks are compiled into each call site. A framework compiled by someone else keeps whatever mode its author used.

Is the Enhanced Security capability required for hardening?
No. It is the route Apple documents, and it adds many other protections. Defining _LIBCPP_HARDENING_MODE yourself gives you the library checks without the unsafe buffer errors.

Is libc++ hardening on by default in Xcode?
No. In a test with Apple clang from Xcode 26.2, a build with no hardening macro read past the end of a vector and carried on, exactly like the explicit NONE mode. You get the checks only after you set _LIBCPP_HARDENING_MODE or add the Enhanced Security capability.

Should I put my Contracts code on hold?
If it needs to compile with every major compiler, yes, until a standard is approved. The write-up linked below explains the arguments on each side.

Tools for the rest of your iOS workflow

If you use Claude Code on an iOS project, Jerry PM sells Claude Code + Xcode: The Production iOS Workflow Kit on Gumroad, from $18. It is a set of rules, commands and agents that tell Claude Code to inspect an Xcode project before editing, run real build and test commands, and report what it verified, plus a runnable SwiftUI and UIKit sample project. It includes a privacy and security rule and a release readiness agent. It does not configure C++ hardening for you, so use the steps above for that.

Sources