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

查看:37
本文介绍了在 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:

颤动:找不到命令

我认为是因为我已经从 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.

第一步

打开终端,运行命令

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.

配置步骤

第一步

找到您的 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天全站免登陆