Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building libraries for iOS — Going native

Building libraries for iOS — Going native

As the iOS community grows, code sharing becomes more and more important thing to discuss. In this presentation I'll share my experience of being a library vendor. I'll give an overview of dependency management approaches. In the "Going Native" part I'll explain why it might be a good idea to stay native and master your libraries manually.

Remarks: One more thing… We are going to talk a bit about mixing Objective-C and C++.

Oleksandr Dodatko

April 12, 2014
Tweet

More Decks by Oleksandr Dodatko

Other Decks in Programming

Transcript

  1. The standard library saves programmers from having to reinvent the

    wheel. Bjarne Stroustrup http://bit.ly/1iqZ3JO
  2. // Pure C headers go here #include <math.h> #ifdef __cplusplus

    // Pure C++ headers go here #include <vector> #endif #ifdef __OBJC__ // Objective-C headers go here #import <Foundation/Foundation.h> #ifdef __cplusplus #import "MyObjectiveCppClass.h" #endif #endif
  3. void bad(const char* p) { FILE* fh = fopen(p,"r"); //

    acquire // use f if ( someCondition ) { // Oops! File handle leaks return; } fclose( fh ); // release }
  4. void good(const char* p) { FILE* fh = fopen(p,"r"); //

    acquire // the block to perform cleanup actions GuardCallbackBlock releaseBlock_ = ^void( void ) { fclose( fh ); }; // creating a guard ObjcScopedGuard guard( releaseBlock_ ); if ( someCondition ) { // Now the scoped guard will release the resource return; } }