博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
O3(OzoneWalletIOS)项目
阅读量:6964 次
发布时间:2019-06-27

本文共 4368 字,大约阅读时间需要 14 分钟。

The main repo for the O3 wallet on iOS.

  • OzoneWalletIOS:
  • neo-swift:
  • neo-wallet-address-go:

下载 OzoneWalletIOS 项目

下载 项目到本地:

下载 OzoneWalletIOS 项目

用 Xcode 打开项目并运行:

运行出错

缺少文件

运行出错,发现缺少文件。打开项目目录,发现有这两个文件 CartfileCartfile.resolved

Cartfile 文件

该项目是用 管理 iOS 依赖库的,安装使用方法看,如果安装不成功请下载 版本进行安装。

打开终端,cd 到该项目目录,运行如下命令:

$ carthage update --platform iOS复制代码

$ carthage update –platform iOS 命令

缺少的文件已下载完成

命令运行成功之后,再次运行项目:

info.plist 文件错误

发现 info.plist 文件读取错误,无法打开。我的解决方法是,新建一个 Project,然后把新工程里的 info.plist 文件拷贝到该项目里替换掉,然后再次运行:

Reason image not found 错误

在 Finder 里前往文件夹 ~/Library/Developer/Xcode/DerivedData ,删除缓存目录下的文件 :

删除缓存目录下的文件

再次运行,发现还是同样的错误,后来发现新加的一个库文件 AutoInsetter 没有加进去:

*** Building scheme "AutoInsetter" in AutoInsetter.xcworkspace复制代码
添加库文件 1

添加库文件 2

添加好后再次运行:

“networkKey” 出错

这个错误不知道怎么分析,全局搜索了一下“ networkKey”,发现是跟用户数据有关,后来整体看了一下项目,然后把项目的 Main Interface 改了一下:

修改 Main Interface

再一次运行:

Info.plist 文件缺少 Fabric 字段 1

Info.plist 文件缺少 Fabric 字段 2

开启 Background Modes:

开启 Background Modes

向 Info.plist 文件添加 Fabric 字段,包含一个 String 类型的 APIKey 和一个 Array 类型的 Kits

QQ20180131-144207@2x.png

好了,再次运行:

模拟器运行界面

终于运行成功了!!!/(ㄒoㄒ)/~~

AppDelegate.swift

Channel.framework 大概是跟推送通知有关的库:

func setupChannel() {        //O3 Development on Channel app_gUHDmimXT8oXRSpJvCxrz5DZvUisko_mliB61uda9iY        Channel.setup(withApplicationId: "app_gUHDmimXT8oXRSpJvCxrz5DZvUisko_mliB61uda9iY")    }复制代码

设置应用的外观样式:

func setupApperances() {        UIBarButtonItem.appearance().setTitleTextAttributes([            NSAttributedStringKey.font: ThemeManager.barButtonItemFont,            NSAttributedStringKey.foregroundColor: UserDefaultsManager.theme.primaryColor], for: .normal)        UINavigationBar.appearance().largeTitleTextAttributes = [            NSAttributedStringKey.foregroundColor: UserDefaultsManager.theme.textColor,            NSAttributedStringKey.font: UIFont(name: "Avenir-Heavy", size: 32) as Any]    }复制代码

创建用户的默认配置:

func registerDefaults() {        let userDefaultsDefaults: [String: Any] = [            "networkKey": "main",            "usedDefaultSeedKey": false,            "selectedThemeKey": Theme.light.rawValue        ]        UserDefaults.standard.register(defaults: userDefaultsDefaults)    }复制代码

开启网络状态监测:

let alertController = UIAlertController(title: "Uh oh! There is no internet connection. ", message: nil, preferredStyle: .alert)    @objc func reachabilityChanged(_ note: Notification) {        switch reachability.connection {        case .wifi:            print("Reachable via WiFi")            alertController.dismiss(animated: true, completion: nil)        case .cellular:            print("Reachable via cellular")            alertController.dismiss(animated: true, completion: nil)        case .none:            print("Network not reachable")            UIApplication.shared.keyWindow?.rootViewController?.presentFromEmbedded(alertController, animated: true, completion: nil)        }    }    let reachability = Reachability()!    func setupReachability() {        NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(_:)), name: .reachabilityChanged, object: nil)        do {            try reachability.startNotifier()        } catch {            print("could not start reachability notifier")        }    }复制代码

检查本地是否存在钱包,如果存在就将主窗口设置为登录到本地钱包的界面:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {        Fabric.with([Crashlytics.self])        self.registerDefaults()        self.setupChannel()        self.setupApperances()        self.setupReachability()        //check if there is an existing wallet in keychain        //if so, present LoginToCurrentWalletViewController        let walletExists =  UserDefaultsManager.o3WalletAddress != nil        if walletExists {            let login = UIStoryboard(name: "Onboarding", bundle: nil).instantiateViewController(withIdentifier: "LoginToCurrentWalletViewController")            if let window = self.window {                window.rootViewController = login            }        }        return true    }复制代码

Onboarding.storyboard

OnboardingHomeViewController.swift

总结

欢迎留言讨论,有错误请指出,谢谢!

参考链接

  • OzoneWalletIOS:
  • neo-swift:
  • neo-wallet-address-go:

更新日志

  • 2018.02.02 第一次更新
  • 2018.02.23 第二次更新
  • 2018.08.07 第三次更新

作者:AlleniCoder

链接:https://www.jianshu.com/p/85a05c70c6fd
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

你可能感兴趣的文章
[Whole Web] [AngularJS + Grunt] Using ng-html2js to Convert Templates into JavaScript
查看>>
基于jQuery/CSS3实现拼图效果的相册插件
查看>>
【问题解决】小数点前面不显示0的问题
查看>>
ios学习笔记(二)第一个应用程序--Hello World
查看>>
项目优化经验分享(七)敏捷开发
查看>>
如何解决adb devices 端口被占用的问题zz
查看>>
Maven学习总结(四)——Maven核心概念——转载
查看>>
实践一些js中的prototype, __proto__, constructor
查看>>
怎么用CIFilter给图片加上各种各样的滤镜_2
查看>>
android:关于主工程和library project
查看>>
CodeForces 2A Winner
查看>>
Window环境配置Mongodb
查看>>
Project facet Java version 1.8 is not supported解决记录
查看>>
制作和unity调用动态链接库dll文件
查看>>
N-Gram
查看>>
操作可能会破坏运行时稳定性的解决办法
查看>>
exsi6.0远程修改密码
查看>>
Header和Cookie相关内容
查看>>
20个可能你不知道Linux网路工具
查看>>
Android 关于listView 显示不全的问题
查看>>