Swiftpack.co -  onevcat/AddressParser as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Email address parser.
.package(url: "https://github.com/onevcat/AddressParser.git", from: "2.0.0")


This framework is a component of Hedwig, which is a cross platform Swift SMTP email client framework.

When sending an email, you need to specify the receipt address. The address field could be one of these forms below:

  • Single address: onev@onevcat.com
  • Formatted address with name: Wei Wang <onev@onevcat.com>
  • A list of addresses: onev@onevcat.com, foo@bar.com
  • A group: My Group: onev@onevcat.com, foo@bar.com;

and even more and mixed...

If you need a complete solution of sending mails through SMTP by Swift, see Hedwig instead.


Add the url of this repo to your Package.swift:

import PackageDescription

let package = Package(
    name: "YourAwesomeSoftware",
    dependencies: [
        .Package(url: "https://github.com/onevcat/AddressParser.git", 
                 majorVersion: 1)

Then run swift build whenever you get prepared.

You could know more information on how to use Swift Package Manager in Apple's official page.


Use AddressParser.parse to parse an email string field to an array of Address. An Address struct contains the name of that address and an entry to indicate whether this is a mail address or a group.

import AddressParser

let _ = AddressParser.parse("onev@onevcat.com")
// [Address(name: "", entry: .mail("onev@onevcat.com"))]

let _ = AddressParser.parse("Wei Wang <onev@onevcat.com>")
// [Address(name: "Wei Wang", entry: .mail("onev@onevcat.com"))]

let _ = AddressParser.parse("onev@onevcat.com, foo@bar.com")
// [
//     Address(name: "", entry: .mail("onev@onevcat.com"))
//     Address(name: "", entry: .mail("foo@bar.com"))
// ]

let _ = AddressParser.parse("My Group: onev@onevcat.com, foo@bar.com;")
// [
//     Address(name: "MyGroup", entry: .group([
//         Address(name: "", entry: .mail("onev@onevcat.com")),
//         Address(name: "", entry: .mail("foo@bar.com")),
//     ]))
// ]


MIT. See the LICENSE file.


Stars: 69
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Swift 5
2 weeks ago

Drop old versions of Swift and adapt to Swift 5. #3 from @vencewill

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API