shyandsy / cipher2

a flutter plugin for AES encryption and decryption
GNU General Public License v3.0
43 stars 40 forks source link

flutter添加cipher2依赖,ios运行错误 #7

Closed javalzbin closed 5 years ago

javalzbin commented 5 years ago

您好,我在项目中添加cipher2依赖,运行到ios中会出现错误,错误如下:

Error output from Xcode build: ↳ BUILD FAILED

Xcode's output: ↳ === BUILD TARGET cipher2 OF PROJECT Pods WITH CONFIGURATION Debug === /Volumes/d/flutter/.pub-cache/hosted/pub.flutter-io.cn/cipher2-0.3.5/ios/Classes/Cipher2Plugin.m:2:9: fatal error: 'cipher2/cipher2-Swift.h' file not found

import <cipher2/cipher2-Swift.h>

        ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Could not build the application for the simulator. Error launching application on iPhone XR.

我从githup直接下载您的example又可以正常运行,我通过绝对路径的方式添加cipher2依赖也不能解决问题。 但是在安卓中运行又是正确的。

实在不知道是什么原因导致的!如您知道解决方式,烦请告知,谢谢!

shyandsy commented 5 years ago

example能运行的话,且所有test都能pass,就不是api的问题。

建议: ios文件夹下所有文件逐一比对,找不同(我也不熟悉ios,之前遇到一个不知所措的问题就是这么解决的)

shyandsy commented 5 years ago

你是怎么使用插件的

是按照这个来的么? image

javalzbin commented 5 years ago

倒是也试过这种方式,也大概知道有哪些地方不同,比如,用xcode打开,查看Pods/Products/下,你的example中是.framework格式静态库, 而我的项目下则是.a格式的静态库。我也不熟悉ios,这个比较崩溃,但是我查了下一些文章,大概就是说.framework是包含了.h文件的,而.a则不包含。 image 左边的图是的自己写的demo,右边的则是的你example。

然后还发现了一点不同: image

文件中你的example有引入CryptoSwift.framework和cipher2.framework,而我的没有,但是由于我并不了解ios,所以,我也不知道其原理。

我是通过依赖的方式来使用插件的, image

我是通过android studio来创建的flutter项目,但是我也试过通过flutter create命令来创建项目,也是同样的错误,问题是,为什么你创建的项目,会使用.framework格式静态库,而我创建的项目则使用了.a格式的静态库。

shyandsy commented 5 years ago

@javalzbin

写flutter我用的vscode,官方配置教程在这里。https://flutter.dev/docs/development/tools/vs-code

试一下这样子。重新建立一个test项目,别的什么也别做。只加入

dependencies:
     cipher2:0.3.5

(快凌晨三点了,我先睡了,明天再回复你。如果搞定了,记得给个星星哦,谢谢了)

javalzbin commented 5 years ago

原来你在国外,非常感谢你,你先休息!

javalzbin commented 5 years ago

我尝试了在win10中创建flutter项目,然后在mac中导入进来,还是一样的错误,也尝试了用其他版本的flutter,也没有用,哎呀,搞不定! 请问你现在新建一个项目,然后引入依赖,能运行到ios么?

shyandsy commented 5 years ago

我看看

彬哥哥 notifications@github.com于2019年2月23日 周六11:17写道:

我尝试了在win10中创建flutter项目,然后在mac中导入进来,还是一样的错误,也尝试了用其他版本的flutter,也没有用,哎呀,搞不定! 请问你现在新建一个项目,然后引入依赖,能运行到ios么?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/shyandsy/cipher2/issues/7#issuecomment-466670392, or mute the thread https://github.com/notifications/unsubscribe-auth/AFBvoTOGlNTgfump0TP38s0ONWcpkvGsks5vQXe_gaJpZM4bN0GH .

-- Yang Shi 201-15 bridgeland dr south R3Y 0E7

shyandsy commented 5 years ago

@javalzbin please try to do this, open the file under project, ios/Podfile

line 35: 

target 'Runner' do
  use_frameworks!    # add this line!!!!!

ref: https://github.com/flutter/flutter/issues/28404

javalzbin commented 5 years ago

四个字:万分感谢! 大神,受小菜膜拜~

解决方式: 1、打开ios/Podfile文件,添加一行代码: use_frameworks! 如下图 image

2、删除ios/Podfile.lock文件,然后重新运行即可!

shyandsy commented 5 years ago

closes #7

shyandsy commented 5 years ago

pr is welcome