Expat for iOS
v2.8.5iOSExpat 2.8.5 for React Native apps on iOS, precompiled for arm64 devices and simulators as @crossbind/port-expat-ios.
npm install @crossbind/port-expat-ios@betaInstall
The whole flow, including Expo, is in the React Native playbook.
Usage
The examples the WebAssembly page runs, as iOS compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Turn XML into JavaScript objects
The calls most Expat code makes: XML_ParserCreate, an element handler and a character data handler, then XML_Parse. A malformed document throws with the line and column where Expat stopped.
Expat 2.8.5 1 en Dune 9.99 EUR 2 fr L'Étranger 7.50 EUR 3 en Pride & Prejudice 5.25 GBP mismatched tag at line 2, column 30
Read namespaced XML whatever the prefixes
XML_ParserCreateNS resolves every prefix to its namespace URI before your handlers see a name, and XML_SetStartNamespaceDeclHandler reports the declarations themselves.
gpxtpx:hr 128 131
ns3:hr 128 131
hr in the GPX namespace: 0
{"":"http://www.topografix.com/GPX/1/1","ns3":"http://www.garmin.com/xmlschemas/TrackPointExtension/v1"}Expand entities without a billion laughs
Expat expands the entities a document declares and stops the ones that blow up: XML_SetBillionLaughsAttackProtectionMaximumAmplification and …ActivationThreshold set how far.
crossbind parses crossbind 5 levels: 300000 characters 9 levels: limit on input amplification factor (from DTD and entities) breached at line 14, column 6 5 levels, 64 KiB threshold: limit on input amplification factor (from DTD and entities) breached at line 10, column 6
"Stream a file through Expat" writes its input with m.FS, which iOS does not have; the C++ takes paths, so it works unchanged on files in the app's storage. It runs on the WebAssembly page.
What is different on iOS
pod installcompiles your headers with the library through the plugin's podspec, and the app build links the result.- Named imports from
./native/<header>.hwork as on the web:await initNative()once, then call the classes. - There is no
m.FSand no/memfs: files live in the app's own storage, and your C++ takes their paths. - No Worker and no COOP or COEP:
runtime: 'mt'uses pthreads directly.
Other platforms
- Expat overview: the apps, every platform's setup and the packages.
- Expat for WebAssembly: browsers, Node.js and edge runtimes.
- Expat for Android: React Native apps on Android.
- Expat for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.