Skip to content

Objective-C wrapper for TinyCbor - Concise Binary Object Representation (CBOR) Library

License

Notifications You must be signed in to change notification settings

getditto/TinyCborObjc

 
 

Repository files navigation

ObjCCBOR

CI Status

ObjCCBOR allows encoding and decoding Foundation-objects into/from CBOR representation.

Supported types:

  • NSDictionary
  • NSArray
  • NSString
  • NSNumber
  • NSNull
  • NSData

Usage

Encoding

#import <ObjCCBOR/ObjCCBOR.h>

NSDictionary *dictionary = ...;
NSError *error = nil;
NSData *cborData = [ObjCCBOR encode:dictionary error:&error];

Decoding

#import <ObjCCBOR/ObjCCBOR.h>

NSData *data = ...; // CBOR data
NSError *error = nil;
id decoded = [ObjCCBOR decode:data error:&error];

Dependencies

ObjCCBOR is built on top of tinycbor which is integrated as git subrepo.

Embedding

When embedding this CBOR library within a distributed framework (or library), there is a risk of running into symbol conflicts if the embedding binary or one of its other dependencies also embed this CBOR library. All C symbols can be hidden at link time of the final binary by adding -Wl,-hidden-lObjCCBOR to OTHER_LDFLAGS.

However, Objective-C types must be unique per process. Therefore, this library adds support for mangling all relevant types by generating a Mangling.h header that defines macros that will prefix the original symbols with a custom build setting OBJC_CBOR_MANGLING_PREFIX. This allows the source to use the original ObjCCBOR type names, while renaming them behind the scenes at build time.

Typically, your final distribution binary is built by CI via xcodebuild, so all you have to do is pass a unique mangling prefix like so:

xcodebuild build ... OBJC_CBOR_MANGLING_PREFIX=MyPersonalObjCCBORBuild123

Authors

Andrew Podkovyrin, [email protected] Hamilton Chapman, [email protected] Connor Power, [email protected]

License

ObjCCBOR is available under the MIT license. See the LICENSE file for more info.

About

Objective-C wrapper for TinyCbor - Concise Binary Object Representation (CBOR) Library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 44.7%
  • C++ 37.4%
  • Objective-C 14.2%
  • Makefile 1.3%
  • Perl 1.1%
  • Shell 0.8%
  • QMake 0.5%