Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

[iOS Wrapper] Fixed build issues #1664

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
231 changes: 155 additions & 76 deletions wrappers/ios/libindy-pod/Indy-demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.7">
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -90,7 +89,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down Expand Up @@ -139,23 +137,5 @@
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
<PostActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "${SRCROOT}/universal_framework.sh ">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3E2A7F841EC36186006194EC"
BuildableName = "Indy-demo.app"
BlueprintName = "Indy-demo"
ReferencedContainer = "container:Indy-demo.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PostActions>
</ArchiveAction>
</Scheme>
63 changes: 63 additions & 0 deletions wrappers/ios/libindy-pod/Indy-demo/Base58.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// Base58Conversion.swift
// Indy-demoTests
//
// Created by Anastasia Tarasova on 06/06/2019.
// Copyright © 2019 Hyperledger. All rights reserved.
//

import Foundation
import BigInt

public enum Base58Alphabet {
public static let btc = [UInt8]("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".utf8)
public static let flickr = [UInt8]("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ".utf8)
}

@objc(Base58)
public class Base58: NSObject {

@objc
public static func encode(_ bytes: Data) -> String?
{
let alphabet: [UInt8] = Base58Alphabet.btc
var x = BigUInt(bytes)
let radix = BigUInt(alphabet.count)

var answer = [UInt8]()
answer.reserveCapacity(bytes.count)

while x > 0 {
let (quotient, modulus) = x.quotientAndRemainder(dividingBy: radix)
answer.append(alphabet[Int(modulus)])
x = quotient
}

let prefix = Array(bytes.prefix(while: {$0 == 0})).map { _ in alphabet[0] }
answer.append(contentsOf: prefix)
answer.reverse()

return String(bytes: answer, encoding: .utf8)
}

@objc
public static func decode(_ string: String) -> Data? {
let alphabet: [UInt8] = Base58Alphabet.btc
var answer = BigUInt(0)
var j = BigUInt(1)
let radix = BigUInt(alphabet.count)
let byteString = [UInt8](string.utf8)

for ch in byteString.reversed() {
if let index = alphabet.firstIndex(of: ch) {
answer = answer + (j * BigUInt(index))
j *= radix
} else {
return nil
}
}

let bytes = answer.serialize()
return byteString.prefix(while: { i in i == alphabet[0]}) + bytes
}
}
19 changes: 19 additions & 0 deletions wrappers/ios/libindy-pod/Indy-demo/Base58Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Base58Utils.h
// Indy-demo
//
// Created by Anastasia Tarasova on 12/06/2019.
// Copyright © 2019 Hyperledger. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Indy_demo-Swift.h>

@class Base58;

@interface Base58Utils : NSObject

+ (NSData *) decode:(NSString *) str;
+ (NSString *) encodeData:(NSData *) data;

@end
25 changes: 25 additions & 0 deletions wrappers/ios/libindy-pod/Indy-demo/Base58Utils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Base58Utils.m
// Indy-demoTests
//
// Created by Anastasia Tarasova on 12/06/2019.
// Copyright © 2019 Hyperledger. All rights reserved.
//

#import "Base58Utils.h"

@interface Base58Utils ()
@end

@implementation Base58Utils

+ (NSData *)decode:(NSString *) str
{
return [[Base58 class] decode: str];
}

+ (NSString *)encodeData:(NSData *) data
{
return [[Base58 class] encode: data];
}
@end
17 changes: 17 additions & 0 deletions wrappers/ios/libindy-pod/Indy-demo/Indy-demo-PrefixHeader.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Indy-demo-PrefixHeader.pch
// Indy-demo
//
// Created by Anastasia Tarasova on 06/06/2019.
// Copyright © 2019 Hyperledger. All rights reserved.
//

#ifndef Indy_demo_PrefixHeader_pch
#define Indy_demo_PrefixHeader_pch

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.

#import "Indy_demo-Swift.h"

#endif /* Indy_demo_PrefixHeader_pch */
13 changes: 4 additions & 9 deletions wrappers/ios/libindy-pod/Indy-demoTests/Base58Test.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#import "WalletUtils.h"
#import <Indy/Indy.h>
#import "NSDictionary+JSON.h"
#import <CoreBitcoin+Categories.h>

#import "Base58Utils.h"

@interface Base58Test : XCTestCase

Expand All @@ -25,13 +24,9 @@ @implementation Base58Test

- (void)testDecode
{
XCTAssertTrue([[@"" dataFromBase58] isEqualToData:[@"" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:false]], @"");

XCTAssertTrue([[@"3mJr7AoUXx2Wqd" dataFromBase58] isEqualToData:[@"1234598760" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:false]], @"");

XCTAssertTrue([[@"3yxU3u1igY8WkgtjK92fbJQCd4BZiiT1v25f" dataFromBase58] isEqualToData:[@"abcdefghijklmnopqrstuvwxyz" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:false]], @"");
XCTAssertTrue([[Base58Utils decode:@""] isEqualToData:[@"" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:false]], @"");
XCTAssertTrue([[Base58Utils decode:@"3mJr7AoUXx2Wqd"] isEqualToData:[@"1234598760" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:false]], @"");
XCTAssertTrue([[Base58Utils decode:@"3yxU3u1igY8WkgtjK92fbJQCd4BZiiT1v25f"] isEqualToData:[@"abcdefghijklmnopqrstuvwxyz" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:false]], @"");
}



@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import <XCTest/XCTest.h>
#import "PoolUtils.h"
#import "TestUtils.h"
#import <CoreBitcoin+Categories.h>
#import "Base58Utils.h"

@interface DidHignCases : XCTestCase

Expand Down Expand Up @@ -43,8 +43,8 @@ - (void)testCreateMyDidWorksForEmptyJson {
outMyDid:&myDid
outMyVerkey:&myVerKey];
XCTAssertEqual(ret.code, Success, @"DidUtils::createMyDidWithWalletHandle() failed");
XCTAssertEqual([[myDid dataFromBase58] length], 16, @"length of myDid != 16");
XCTAssertEqual([[myVerKey dataFromBase58] length], 32, @"length of myVerKey != 32");
XCTAssertEqual([[Base58Utils decode:myDid] length], 16, @"length of myDid != 16");
XCTAssertEqual([[Base58Utils decode:myVerKey] length], 32, @"length of myVerKey != 32");
}

- (void)testCreateMyDidWorksWithSeed {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// IndyDemoTests-PrefixHeader.pch
// Indy-demoTests
//
// Created by Anastasia Tarasova on 12/06/2019.
// Copyright © 2019 Hyperledger. All rights reserved.
//

#ifndef IndyDemoTests_PrefixHeader_pch
#define IndyDemoTests_PrefixHeader_pch

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.

#import <Indy_demo-Swift.h>

#endif /* IndyDemoTests_PrefixHeader_pch */
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Indy-demo
//


#import <XCTest/XCTest.h>

@interface NSDictionary (JSON)
Expand Down