Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
javalzbin opened this issue Feb 23, 2019 · 11 comments
Closed

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

javalzbin opened this issue Feb 23, 2019 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@javalzbin
Copy link

您好,我在项目中添加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
Copy link
Owner

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

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

@shyandsy
Copy link
Owner

你是怎么使用插件的

是按照这个来的么?
image

@javalzbin
Copy link
Author

javalzbin commented Feb 23, 2019

倒是也试过这种方式,也大概知道有哪些地方不同,比如,用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
Copy link
Owner

shyandsy commented Feb 23, 2019

@javalzbin

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

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

dependencies:
     cipher2:0.3.5
  • 等系统更新完之后再看能不能编译。
  • 然后使用aes加密api随便加密一段文字看看能不能编译

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

@javalzbin
Copy link
Author

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

@javalzbin
Copy link
Author

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

@shyandsy
Copy link
Owner

shyandsy commented Feb 23, 2019 via email

@shyandsy shyandsy added the bug Something isn't working label Feb 23, 2019
@shyandsy shyandsy self-assigned this Feb 23, 2019
@shyandsy
Copy link
Owner

shyandsy commented Feb 25, 2019

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

line 35: 

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

ref: flutter/flutter#28404

@javalzbin
Copy link
Author

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

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

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

@shyandsy
Copy link
Owner

closes #7

@shyandsy
Copy link
Owner

pr is welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants