Skip to content

Commit

Permalink
make gomobile work by removing custom couchdb document type
Browse files Browse the repository at this point in the history
  • Loading branch information
zemirco committed Jan 23, 2016
1 parent 95dd86c commit 7e14708
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 4 deletions.
1 change: 1 addition & 0 deletions Item.framework/Headers
1 change: 1 addition & 0 deletions Item.framework/Item
1 change: 1 addition & 0 deletions Item.framework/Modules
1 change: 1 addition & 0 deletions Item.framework/Resources
36 changes: 36 additions & 0 deletions Item.framework/Versions/A/Headers/Item.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Objective-C API for talking to github.com/zemirco/todo/item Go package.
// gobind -lang=objc github.com/zemirco/todo/item
//
// File is generated by gobind. Do not edit.

#ifndef __GoItem_H__
#define __GoItem_H__

#include <Foundation/Foundation.h>

@class GoItemTodo;

@interface GoItemTodo : NSObject {
}
@property(strong, readonly) id _ref;

- (id)initWithRef:(id)ref;
- (NSString*)id;
- (void)setID:(NSString*)v;
- (NSString*)rev;
- (void)setRev:(NSString*)v;
- (NSString*)type;
- (void)setType:(NSString*)v;
- (NSString*)text;
- (void)setText:(NSString*)v;
- (double)createdAt;
- (void)setCreatedAt:(double)v;
- (BOOL)done;
- (void)setDone:(BOOL)v;
- (NSString*)getID;
- (NSString*)getRev;
@end

FOUNDATION_EXPORT GoItemTodo* GoItemNewTodo(NSString* text);

#endif
Binary file added Item.framework/Versions/A/Item
Binary file not shown.
5 changes: 5 additions & 0 deletions Item.framework/Versions/A/Modules/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework module "Item" {
header "Item.h"

export *
}
6 changes: 6 additions & 0 deletions Item.framework/Versions/A/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
1 change: 1 addition & 0 deletions Item.framework/Versions/Current
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ up:
stop:
docker-compose stop

.PHONY: run up stop
mobile:
gomobile bind -target=ios -o todo/Item.framework github.com/zemirco/todo/item

.PHONY: run up stop mobile
23 changes: 20 additions & 3 deletions item/item.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
package item

import "github.com/zemirco/couchdb"

// Todo defines todo item.
// Whole package is reused for mobile app via gomobile.
// Therefore only basic types work.
type Todo struct {
couchdb.Document
// cannot embed couchdb.Document directly because gomobile complains
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Type string `json:"type"`
Text string `json:"text"`
CreatedAt float64 `json:"createdAt"`
Done bool `json:"done"`
}

// NewTodo returns new todo item.
// Constructor must exist and must return pointer to work on ios.
func NewTodo(text string) *Todo {
return &Todo{
Type: "todo",
Text: text,
Done: false,
}
}

// let Todo implement couchdb.CouchDoc interface

// GetID returns document ID.
func (t *Todo) GetID() string {
return t.ID
}

// GetRev returns document revision.
func (t *Todo) GetRev() string {
return t.Rev
}
1 change: 1 addition & 0 deletions todo/Item.framework/Headers
1 change: 1 addition & 0 deletions todo/Item.framework/Item
1 change: 1 addition & 0 deletions todo/Item.framework/Modules
1 change: 1 addition & 0 deletions todo/Item.framework/Resources
38 changes: 38 additions & 0 deletions todo/Item.framework/Versions/A/Headers/Item.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Objective-C API for talking to github.com/zemirco/todo/item Go package.
// gobind -lang=objc github.com/zemirco/todo/item
//
// File is generated by gobind. Do not edit.

#ifndef __GoItem_H__
#define __GoItem_H__

#include <Foundation/Foundation.h>

@class GoItemTodo;

@interface GoItemTodo : NSObject {
}
@property(strong, readonly) id _ref;

- (id)initWithRef:(id)ref;
- (NSString*)id;
- (void)setID:(NSString*)v;
- (NSString*)rev;
- (void)setRev:(NSString*)v;
- (NSString*)type;
- (void)setType:(NSString*)v;
- (NSString*)text;
- (void)setText:(NSString*)v;
- (double)createdAt;
- (void)setCreatedAt:(double)v;
- (BOOL)done;
- (void)setDone:(BOOL)v;
- (NSString*)awesome;
- (void)setAwesome:(NSString*)v;
- (NSString*)getID;
- (NSString*)getRev;
@end

FOUNDATION_EXPORT GoItemTodo* GoItemNewTodo(NSString* text);

#endif
Binary file added todo/Item.framework/Versions/A/Item
Binary file not shown.
5 changes: 5 additions & 0 deletions todo/Item.framework/Versions/A/Modules/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework module "Item" {
header "Item.h"

export *
}
6 changes: 6 additions & 0 deletions todo/Item.framework/Versions/A/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
1 change: 1 addition & 0 deletions todo/Item.framework/Versions/Current
8 changes: 8 additions & 0 deletions todo/todo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
3B75A02F1C53BE0000E92480 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B75A02E1C53BDFF00E92480 /* SystemConfiguration.framework */; };
3B75A0311C53BE0A00E92480 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B75A0301C53BE0A00E92480 /* libsqlite3.tbd */; };
3B75A0331C53BE1300E92480 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B75A0321C53BE1300E92480 /* libz.tbd */; };
3B75A0371C53CFAF00E92480 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B75A0361C53CFAF00E92480 /* Database.swift */; };
3B75A0391C53D84F00E92480 /* Item.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B75A0381C53D84F00E92480 /* Item.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -60,6 +62,8 @@
3B75A0301C53BE0A00E92480 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
3B75A0321C53BE1300E92480 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
3B75A0351C53C06000E92480 /* todo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "todo-Bridging-Header.h"; sourceTree = "<group>"; };
3B75A0361C53CFAF00E92480 /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = "<group>"; };
3B75A0381C53D84F00E92480 /* Item.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Item.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -70,6 +74,7 @@
3B75A0331C53BE1300E92480 /* libz.tbd in Frameworks */,
3B75A0311C53BE0A00E92480 /* libsqlite3.tbd in Frameworks */,
3B75A02F1C53BE0000E92480 /* SystemConfiguration.framework in Frameworks */,
3B75A0391C53D84F00E92480 /* Item.framework in Frameworks */,
3B75A02D1C53BDF600E92480 /* Security.framework in Frameworks */,
3B75A02B1C53BDEC00E92480 /* CFNetwork.framework in Frameworks */,
3B75A0291C53BD9200E92480 /* CouchbaseLite.framework in Frameworks */,
Expand All @@ -96,6 +101,7 @@
3B759FEA1C53B71900E92480 = {
isa = PBXGroup;
children = (
3B75A0381C53D84F00E92480 /* Item.framework */,
3B75A0351C53C06000E92480 /* todo-Bridging-Header.h */,
3B75A0321C53BE1300E92480 /* libz.tbd */,
3B75A0301C53BE0A00E92480 /* libsqlite3.tbd */,
Expand Down Expand Up @@ -125,6 +131,7 @@
children = (
3B759FF61C53B71900E92480 /* AppDelegate.swift */,
3B75A0241C53B87000E92480 /* TodosTableViewController.swift */,
3B75A0361C53CFAF00E92480 /* Database.swift */,
3B75A0261C53BADE00E92480 /* AddTodoViewController.swift */,
3B759FFD1C53B71A00E92480 /* Assets.xcassets */,
3B759FFF1C53B71A00E92480 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -283,6 +290,7 @@
files = (
3B75A0271C53BADE00E92480 /* AddTodoViewController.swift in Sources */,
3B759FF71C53B71900E92480 /* AppDelegate.swift in Sources */,
3B75A0371C53CFAF00E92480 /* Database.swift in Sources */,
3B75A0251C53B87000E92480 /* TodosTableViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions todo/todo/Database.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import Foundation

public class Database {

public class func GetTodos(db: CBLDatabase) {

}

}

0 comments on commit 7e14708

Please sign in to comment.