ios啓動私有鏈查詢區塊信息 原

一、新建一個ios swift項目

二、下載並安裝CocoaPods.app-1.5.2.tar.bz2

https://github.com/CocoaPods/CocoaPods-app/releases/download/1.5.2/CocoaPods.app-1.5.2.tar.bz2

三、通過pod安裝geth插件

$ cd /Users/shijun/Desktop/iosWorkspace/BlockChain

$ pod init

生成Podfile文件,並修改內容

target 'BlockChain' do
    pod 'Geth', '1.8.12' #加這行
    use_frameworks!

    target 'BlockChainTests' do
        pod 'Geth', '1.8.12' #加這行
        inherit! :search_paths
    end

    target 'BlockChainUITests' do
        pod 'Geth', '1.8.12' #加這行
        inherit! :search_paths
    end
end

$ pod install

========================================

Analyzing dependencies

Downloading dependencies

Installing Geth (1.8.12)

Generating Pods project

Integrating client project

[!] Please close any current Xcode sessions and use `BlockChain.xcworkspace` for this project from now on.

Sending stats

Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] Automatically assigning platform `ios` with version `11.4` on target `BlockChain` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

========================================

四、ios代碼

創建新帳號

========================================

import Geth 

let keyStorePath = "/Users/shijun/Desktop/blockChain/ethereum/private/data0/keystore"

print("keyStorePath: \(keyStorePath)")

let keyStoreManager = GethNewKeyStore(keyStorePath, GethLightScryptN, GethLightScryptP)

let account = try! keyStoreManager?.newAccount("password")

let address = account?.getAddress().getHex()

print("address: \(address!)")

let url = account?.getURL()

print("url: \(url!)")

========================================

四、問題彙總

1、真機build faile

解決:all + Combined ,搜索bitcode,enable bitcode講yes修改爲no

========================================

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章