Skip to content

Commit e76f132

Browse files
author
Tomislav Markovski
committed
Merged PR 1544: Swift / Obj C wrapper as a Framework + Static Lib
Related work items: #3490
1 parent 1303bb3 commit e76f132

File tree

26 files changed

+1348
-3
lines changed

26 files changed

+1348
-3
lines changed

DIDCommGrpc.podspec

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Pod::Spec.new do |s|
2+
s.name = "DIDCommGrpc"
3+
s.version = "0.0.1"
4+
s.summary = "A brief description of MyFramework project."
5+
s.description = <<-DESC
6+
An extended description of MyFramework project.
7+
DESC
8+
s.homepage = "http://your.homepage/here"
9+
s.license = { :type => 'Copyright', :text => <<-LICENSE
10+
Copyright 2018
11+
Permission is granted to...
12+
LICENSE
13+
}
14+
s.author = { "$(git config user.name)" => "$(git config user.email)" }
15+
s.source = { :git => "$HOME/MyFramework.git", :tag => "#{s.version}" }
16+
s.source_files = "swift/DIDCommGrpc/**/*.swift"
17+
s.vendored_libraries = 'libs/ios/libdidcommgrpc.a'
18+
s.platform = :ios
19+
s.swift_version = "4.2"
20+
s.ios.deployment_target = '12.0'
21+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ typedef struct {
1010
char* message; /* note: nullable */
1111
} ExternError;
1212

13+
void didcomm_string_free(char* string);
14+
15+
void didcomm_byte_buffer_free(ByteBuffer data);
16+
1317
int32_t didcomm_generate_key(ByteBuffer request, ByteBuffer *response, ExternError *err);
1418

1519
int32_t didcomm_convert_key(ByteBuffer request, ByteBuffer *response, ExternError *err);

native/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
2-
name = "didcomm"
2+
name = "didcomm-grpc"
33
version = "0.1.0"
44
authors = ["Tomislav Markovski <[email protected]>"]
55
edition = "2018"
66

77
[lib]
8-
name = "didcomm_grpc"
8+
name = "didcommgrpc"
99
crate-type = ["staticlib", "cdylib"]
1010

1111
[dependencies]

native/cbindgen.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# cargo install --force cbindgen
2-
# cbindgen --config cbindgen.toml --crate didcomm --output out.h --lang c
2+
# cbindgen --config cbindgen.toml --crate didcomm-grpc --output out.h --lang c
3+
# copy data manually into include/didcomm_grpc.h

swift/DIDCommGrpc/DIDComm.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// DIDComm.swift
3+
// DIDCommExtensionGrpc
4+
//
5+
// Created by Tomislav Markovski on 11/2/20.
6+
//
7+
8+
import Foundation
9+
import DIDCommGrpcNative
10+
11+
public func generateKey(request: Data) throws -> Data {
12+
let error: NSErrorPointer = NSErrorPointer.none
13+
14+
return DMNative.generateKey(Data(), withError: error)
15+
}

swift/DIDCommGrpc/DIDCommGrpc.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// DIDCommExtensionGrpc.h
3+
// DIDCommExtensionGrpc
4+
//
5+
// Created by Tomislav Markovski on 11/2/20.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
10+
//! Project version number for DIDCommExtensionGrpc.
11+
FOUNDATION_EXPORT double DIDCommExtensionGrpcVersionNumber;
12+
13+
//! Project version string for DIDCommExtensionGrpc.
14+
FOUNDATION_EXPORT const unsigned char DIDCommExtensionGrpcVersionString[];
15+
16+
// In this header, you should import all the public headers of your framework using statements like #import <DIDCommExtensionGrpc/PublicHeader.h>
17+
18+

swift/DIDCommGrpc/Info.plist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
21+
</dict>
22+
</plist>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// DIDCommGrpc.h
3+
// DIDCommGrpc
4+
//
5+
// Created by Tomislav Markovski on 11/2/20.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
10+
//! Project version number for DIDCommGrpc.
11+
FOUNDATION_EXPORT double DIDCommGrpcVersionNumber;
12+
13+
//! Project version string for DIDCommGrpc.
14+
FOUNDATION_EXPORT const unsigned char DIDCommGrpcVersionString[];
15+
16+
// In this header, you should import all the public headers of your framework using statements like #import <DIDCommGrpc/PublicHeader.h>
17+
18+
#import "didcommgrpc.h"
19+
#import "DMNative.h"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// DMGrpcError.h
3+
// DIDCommGrpcNative
4+
//
5+
// Created by Tomislav Markovski on 11/2/20.
6+
//
7+
8+
#import <Foundation/Foundation.h>
9+
#import "didcommgrpc.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface DMGrpcError : NSObject
14+
15+
+ (NSError*) errorFromExternError:(ExternError *) error;
16+
17+
@end
18+
19+
NS_ASSUME_NONNULL_END
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// DMGrpcError.m
3+
// DIDCommGrpcNative
4+
//
5+
// Created by Tomislav Markovski on 11/2/20.
6+
//
7+
8+
#import "DMGrpcError.h"
9+
10+
static NSString *const DMGrpcErrorDomain = @"DIDCommGrpcError";
11+
12+
@implementation DMGrpcError
13+
14+
+ (NSError *)errorFromExternError:(ExternError *)error {
15+
16+
NSMutableDictionary *userInfo = [NSMutableDictionary new];
17+
18+
if (error->message != NULL) {
19+
[userInfo setValue:[NSString stringWithUTF8String:error->message] forKey:@"message"];
20+
free(error->message);
21+
}
22+
23+
free(error);
24+
return [NSError errorWithDomain:DMGrpcErrorDomain code:error->code userInfo:userInfo];
25+
}
26+
27+
@end

0 commit comments

Comments
 (0)