在iOS发行模式下构建Flutter应用 [英] Build Flutter app in release mode for iOS

查看:72
本文介绍了在iOS发行模式下构建Flutter应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了带有Flutter插件的Android Studio.Flutter SDK也通过Android Studio安装在我的Mac上,我知道它的路径.

I have Android Studio with Flutter plugin installed. Flutter SDK is also installed on my Mac through Android Studio and I know path to it.

我想在真正的iOS设备上以发布模式运行我的应用程序.据我所知,不仅可以隐藏慢速模式"横幅,而且可以使用此代码完成

I want to run my app in release mode on real iOS device. Not only to hide "slow mode" banner that can be done using this code as I know

new MaterialApp(
  debugShowCheckedModeBanner: false,
  ...

还要检查我的应用程序如何工作.

but also to check how my app works.

我发现此说明 https://flutter.io/ios-release/,但仍然可以不要在发布模式下构建应用.

I found this instructions https://flutter.io/ios-release/ but still can't build app in release mode.

每次尝试在终端中运行flutter命令时,都会得到:

Each time I try to run flutter command in terminal, I got:

颤振:找不到命令

flutter: command not found

我认为这是因为我已经从Android Studio安装了Flutter SDK,并且应该更新一些路径.那么,使用Xcode在发布模式下构建Flutter应用程序的步骤是什么?

I think that it is because I had installed Flutter SDK from Android Studio and I should update some pathes. So what are my steps to build flutter app in release mode using Xcode?

推荐答案

构建步骤

如果由于找不到终端而在终端中使用flutter命令时遇到问题,请阅读下面的配置步骤.

If you have problems using flutter command in terminal because it is not found - read Configuring steps below.

第1步

打开终端,运行命令

cd /Users/John/myFlutterApp/

运行

flutter build ios

打开Xcode并在iOS文件夹中运行.xcworkspace文件.现在,它应该可以正常工作,并且慢速模式横幅也应该消失了.

Open Xcode and run .xcworkspace file in iOS folder. It should now work smoothly and Slow mode banner should be gone.

配置步骤

第1步

找到在Mac上安装flutter的文件夹.如果它是使用Android Studio安装的.只需打开Android Studio创建新的Flutter项目,您将看到 Flutter SDK路径.例如,将其设置为/Users/John/flutter/

Locate folder where flutter is installed on your mac. If it was installed using Android Studio. Just open Android Studio create new flutter project and you will see Flutter SDK path. For example let it be /Users/John/flutter/

第2步

在Mac上打开终端并运行

open terminal on your Mac and run

cd /Users/John/

正如您所看到的,我们现在已经从SDK路径升级了

As you can see we are now one level up from SDK path

第3步

运行

export PATH=`pwd`/flutter/bin:$PATH

如果您现在在终端中运行 flutter ,您应该会看到可用参数的列表.这样您就可以运行

If you now run flutter in terminal you should see list of available params. So you can run

flutter doctor

要检查安装是否一切正常.现在,flutter命令仅适用于此终端会话.如果关闭它,然后再次打开它并运行更完整的命令,则会收到此命令未知的错误消息.因此,即使终端关闭后,您也希望将flutter命令保存为可用.

To check is everything is fine with installation. Now flutter command only works for this terminal session. And if you close it and later open it again and run fuller command - you will get error that this command is unknown. So you want to save flutter command to be available even after terminal was closed.

第4步

运行

open ~/.bash_profile

您将看到需要粘贴的文本编辑器

you will see text editor where you need to paste

export PATH=/Users/John/flutter/bin:$PATH

保存文件.如果您现在关闭终端然后再次打开-您应该能够运行flutter命令.

save file. If you close terminal now and open it again - you should be able to run flutter command.

这篇关于在iOS发行模式下构建Flutter应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆