Swiftpack.co - Package - MaxDesiatov/XMLCoder


Encoder & Decoder for XML using Swift's Codable protocols.

CI Status Version License Platform

This package is a fork of the original ShawnMoore/XMLParsing with more options and tests added.


import XMLCoder

let xmlStr = """
    <body>Don't forget to use XMLCoder!</body>
struct Note: Codable {
    var to: String
    var from: String
    var heading: String
    var body: String

guard let data = xmlStr.data(using: .utf8) else { return }

let note = try? XMLDecoder().decode(Note.self, from: data)

let returnData = try? XMLEncoder().encode(note, withRootKey: "note")



CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. You can install it with the following command:

$ gem install cocoapods

Navigate to the project directory and create Podfile with the following command:

$ pod install

Inside of your Podfile, specify the XMLCoder pod:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'YourApp' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks

  # Pods for Test
  pod 'XMLCoder', '~> 0.2.1'


Then, run the following command:

$ pod install

Open the the YourApp.xcworkspace file that was created. This should be the file you use everyday to create your app, instead of the YourApp.xcodeproj file.


Carthage is a dependency manager that builds your dependencies and provides you with binary frameworks.

Carthage can be installed with Homebrew using the following command:

$ brew update
$ brew install carthage

Inside of your Cartfile, add GitHub path to XMLCoder:

github "MaxDesiatov/XMLCoder" ~> 0.2.1

Then, run the following command to build the framework:

$ carthage update

Drag the built framework into your Xcode project.

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding XMLCoder as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/MaxDesiatov/XMLCoder.git", from: "0.2.1")


Stars: 30
Help us keep the lights on


Used By

Total: 1


0.2.1 - Nov 18, 2018

  • watchOS deployment target set to 2.0 for Carthage (@MaxDesiatov)

0.2.0 - Nov 18, 2018

  • Add watchOS 2.0 deployment target (@MaxDesiatov)

0.1.1 - Nov 18, 2018

  • Set iOS deployment target to 9.0 (@MaxDesiatov)

0.1.0 - Nov 8, 2018

  • Add support for decoupled, type-dependent node-encoding strategies (@regexident)
  • Add missing visibility declarations (@regexident)
  • Improve .gitignore and remove tracked *.xcuserdata files (@regexident)
  • Make XMLEncoder.OutputFormatting.prettyPrinted actually do something (@regexident)
  • Add tvOS deployment target to podspec (@edc1591)
  • Fix Carthage command (@salavert)
  • Set deployment versions to allow older SDKs (@Lutzifer)
  • Add Info.plist to allow Framework use in App Store Connect via Carthage (@Lutzifer)
  • Add convertFromCapitalized strategy, simple test (@MaxDesiatov)
  • Allow older iOS/tvOS deployment targets in podspec (@MaxDesiatov)