Install using cocoapods:
pod 'srvresolver'
Manual installation:
For manual installation just clone the repo and add the project as subproject (add dependancy to build phases).
Usage:
// Swift example
import srvresolver
SRVQueryResolver.query("_xmpp-server._tcp.gmail.com", timeout:2){ records, err iniflet records = records {
records.forEach{ record inprint("\(record.target) : \(record.port), ttl: \(record.ttl), priority: \(record.priority)")}}elseiflet err = err {print(err.localizedDescription)}}// Objective-C example
@import srvresolver;
[SRVQueryResolver query:@"_xmpp-server._tcp.gmail.com"timeout:2.0completion:^(NSArray<SRVQueryRecord *> *records, NSError *err) {
if (records) {
for(SRVQueryRecord *record in records) {
NSLog(@"%@ : %ld, ttl: %ld, priority: %ld", record.target, record.port, record.ttl, record.priority);
}
} elseif (err) {
NSLog(@"%@", err.localizedDescription);
}
}];
Output:
alt1.xmpp-server.l.google.com : 5269, ttl: 1127, priority: 20
alt3.xmpp-server.l.google.com : 5269, ttl: 1127, priority: 20
alt4.xmpp-server.l.google.com : 5269, ttl: 1127, priority: 20
alt2.xmpp-server.l.google.com : 5269, ttl: 1127, priority: 20
xmpp-server.l.google.com : 5269, ttl: 1127, priority: 5