After reading this blog post from Adam Wiggins Mobile syncing with Couchbase I thouhgt I could give it a try. First thing you’ll notice reading Couchbase Getting Started guide is that you have to include their framework and its dependencies.
You can do it in your RubyMotion Rakefile
app.frameworks += ['CFNetwork', 'Security', 'SystemConfiguration']
app.libs += ['/usr/lib/libsqlite3.dylib', '/usr/lib/libz.dylib']
app.vendor_project('vendor/couchbase-lite-community-ios_1.0-beta2/CouchbaseLite.framework',
:static,
:products => ['CouchbaseLite'],
:headers_dir => 'Headers'
)
But, after running rake
I got this error message:
Objective-C stub for message `createDatabaseNamed:error:' type `@@:@^@' not precompiled.
Make sure you properly link with the framework or library that defines this message.
I learnt from this post
that some vital information is not being generated. You’ll notice an #ifdef CBL_DEPRECATED
condition in Couchbase Lite source code which prevents RubyMotion to create some
My approach was to make sure that this constant was defined before CBLManager.h
was reached so RubyMotion could
generate this snippet of code:
<method selector='createDatabaseNamed:error:'>
<arg declared_type='NSString*' index='0' name='name' type='@'/>
<arg declared_type='NSError**' index='1' name='outError' type='^@'/>
<retval declared_type='CBLDatabase*' type='@'/>
</method>
I created a file named AAA-rubymotion-fix.h
with this content:
//
// Define CBL_DEPRECATED before anything else
#define CBL_DEPRECATED
Now you can run rake clean
and rake
again and stub error message won’t appear.