I need to canonicalize an xml file (using c14n standard) in my iOS app for signature validation but I cannot find an API in the iOS SDK which will help me do this. The XML Canonicalization API canonicalXMLStringPreservingComments is available only for the MacOS. Is there any equivalent API or 3rd party library like XOM for this purpose on iOS?
Asked
Active
Viewed 277 times
1 Answers
0
So, I found a solution for this using libxml2. libxml2 contains the required APIs for XML Canonicalization (c14n) and you can find the documentation for it here.
libxml2 is available in the iOS SDK. To add the library in your Xcode project:
- Target -> Build Phases -> Link Binary With Libraries
- Click on the "+" button and search for "libxml2.tbd"
You will also need to add the following to your project's Build Settings:
- Other Linker Flags: -lxml2
- Header Search Paths: $(SDKROOT)/usr/include/libxml2
To access libxml2 in your Swift class, simply add:
import libxml2

rkk817
- 117
- 1
- 13