将Flutter程序打包为ios应用并进行安装使用

如果直接执行flutter build ios:

Building com.example.myTimeApp for device (ios-release)...
════════════════════════════════════════════════════════════════════════════════
No valid code signing certificates were found
You can connect to your Apple Developer account by signing in with your Apple ID
in Xcode and create an iOS Development Certificate as well as a Provisioning 
Profile for your project by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- Make sure a 'Development Team' is selected under Signing & Capabilities > Team. 
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again
  5- Trust your newly created Development Certificate on your iOS device
     via Settings > General > Device Management > [your new certificate] > Trust

For more information, please visit:
  https://developer.apple.com/library/content/documentation/IDEs/Conceptual/
  AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
No development certificates available to code sign app for device deployment

为设备(ios-release)构建com.example.myTimeApp... ════════════════════════════════════════════════════════════════════════════════ 找不到有效的代码签名证书 您可以通过在Xcode中使用您的Apple ID登录并创建iOS开发证书以及为您的项目创建一个 配置文件来连接到您的Apple开发者帐户,方法如下: 1- 使用以下命令打开Flutter项目的Xcode目标: open ios/Runner.xcworkspace 2- 在导航器中选择“Runner”项目,然后选择“Runner”目标 在项目设置中 3- 确保在Signing & Capabilities > Team下选择了“Development Team”。 您可能需要: - 首先使用您的Apple ID在Xcode中登录 - 确保您拥有一个有效的唯一Bundle ID - 使用您的Apple开发者帐户注册您的设备 - 让Xcode自动为您的应用程序配置配置文件 4- 再次构建或运行您的项目 5- 在iOS设备上信任您新创建的开发证书 通过设置 > 通用 > 设备管理 > [您的新证书] > 信任

获取更多信息,请访问: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/ AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html

或者在没有代码签名的情况下在iOS模拟器上运行 ════════════════════════════════════════════════════════════════════════════════ 没有可用的开发证书来对设备部署进行代码签名


要将Flutter应用程序编译为iOS上可用的app,需执行以下步骤:

  1. 安装Xcode

    首先,需要在macOS系统上安装最新版本的Xcode。Xcode是Apple提供的集成开发环境,用于编写iOS、macOS、watchOS和tvOS应用程序。

  2. 配置iOS模拟器

    启动Xcode,进入Xcode > Preferences > Components,并安装iOS模拟器组件。这将允许我们在macOS上运行和测试iOS应用程序。

    注意,Xcode事情比较多, 需要打开项目里面ios文件夹,不然会报错 could not open file(具体的路径)

  3. 创建iOS模拟器

    在Xcode中,选择Xcode > Open Developer Tool > Simulator 打开iOS模拟器。

alt

  1. 配置Flutter开发环境 在macOS的终端中,运行以下命令来启用iOS平台支持:

    flutter config --enable-ios
alt
  1. 启动模拟器

    在Flutter项目目录下,运行以下命令来启动iOS模拟器并安装应用程序:

    flutter run
alt
alt

Flutter将自动检测并列出所有可用的iOS模拟器设备。选择一个合适的模拟器即可在其中运行我开发的应用程序。

这个地址 http://127.0.0.1:9100/home?uri=http://127.0.0.1:64534/zqL1_Dh8L-8=/  能进行debug
alt
  1. 构建release版本

    要构建最终的发布版本(release build),使用以下命令:

    flutter build ios

    这将在ios/build/Products/Release-iphoneXX目录下生成一个.app文件。可以将该文件提交到App Store进行审核和分发。

如果想要在真实的iOS设备上运行该应用程序,则需要一个付费的Apple开发者账户,以及对代码进行签名和配置。该过程比在模拟器上运行略微复杂一些。

但在执行flutter build ios还是报最开始的错误

执行flutter doctor -v

[✓] Flutter (Channel stable, 3.19.6, on macOS 13.0 22A380 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.19.6 on channel stable at /Users/fliter/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (3 周前), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/fliter/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/fliter/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to
        your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.89.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • iPhone 14 Pro (mobile)     • F598C6ED-1F79-4764-AC82-2FBAF9612F39 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • iPhone 14 Pro Max (mobile) • 04892CB6-FD81-4F25-9FC9-F5CE20B4A765 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS
      13.0 22A380 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google
      Chrome 124.0.6367.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

发现

    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to
        your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

CocoaPods未安装。
CocoaPods用于获取iOS和macOS平台端的插件代码,以响应Dart端对插件的使用。
如果没有安装CocoaPods,插件将无法在iOS或macOS上工作。
有关更多信息,请参阅https://flutter.dev/platform-plugins。
要安装,请参阅https://guides.cocoapods.org/using/getting-started.html#installation获取安装说明。

参考 cocoapods的安装和使用, 安装cocoapods.

然后再次执行flutter doctor -v, 都是对号, No issues found!


但依然报最开始的错误, 可见可能和cocoapods的安装没直接关系,还是签名的问题

对于ios开发,为了安全,签名是必不可少的..否则只能在Mac上面用模拟器玩一玩,无法安装到手机上..这点和安卓不一样

alt

而想要签名,就需要一个开发者账号, 一般的普通个人版,99美刀一年 (真特么贵啊,而且还不是一次性的,每年都要续费)..

(公司/组织 类型的账号更贵)

> 只有拥有开发着账号,才可以申请开发者 / 发布者证书以及相关配置授权文件,进而在 iOS 真机上开发调试 Applocation 或发布至 Apple Store。

关于 IOS 的一些基础说明[1]



alt

果然,不氪金不行...

Communication with Apple failed. Your team has no devices from which to generate a provisioning profile. Connect a device to use or manually add device IDs in Certificates, Identifiers & Profiles. https://developer.apple.com/account/

需要登录开发者中心,同意新的协议,并添加设备

alt

通过USB连接手机, 在iPhone上搜索 隐私和安全性,打开开发者模式(需要重启手机)

alt

要在 iOS 17 设备上进行调试,需要 Xcode 15。这需要 macOS 13.5 或更高版本。


更新系统后再试:

alt
alt

然后再次执行 flutter build ios

alt

在 Xcode 中, 打开Window-->Devices and Simulators, 单击下图中的+, 选择/Users/fliter/my_time_app/build/ios/iphoneos/Runner.app.

然后就能看到手机上安装了我开发的这个app

但是打开时会报错:

alt

你的设备管理设置不允许在这台iphone上使用开发者...

手机上,打开 设置-通用-VPN与设备管理,信任

alt
alt
alt
alt
alt



更多flutter的命令:

flutter -v       
Manage your Flutter app development.

Common commands:

  flutter create <output directory>
    Create a new Flutter project in the specified directory.

  flutter run [options]
    Run your Flutter application on an attached device or in an emulator.

Usage: flutter <command> [arguments]

Global options:
-h, --help                      Print this usage information.
-v, --verbose                   Noisy logging, including all shell commands executed.
                                If used with "--help", shows hidden options. If used with "flutter doctor",
                                shows additional diagnostic information. (Use "-vv" to force verbose logging in
                                those cases.)
    --prefixed-errors           Causes lines sent to stderr to be prefixed with "ERROR:".
    --quiet                     Reduce the amount of output from some commands.
    --[no-]wrap                 Toggles output word wrapping, regardless of whether or not the output is a
                                terminal.
                                (defaults to on)
    --wrap-column               Sets the output wrap column. If not set, uses the width of the terminal. No
                                wrapping occurs if not writing to a terminal. Use "--no-wrap" to turn off
                                wrapping when connected to a terminal.
-d, --device-id                 Target device id or name (prefixes allowed).
    --version                   Reports the version of this tool.
    --machine                   When used with the "--version" flag, outputs the information using JSON.
    --[no-]color                Whether to use terminal colors (requires support for ANSI escape sequences).
                                (defaults to on)
    --[no-]version-check        Allow Flutter to check for updates when this command runs.
                                (defaults to on)
    --enable-analytics          Enable telemetry reporting each time a flutter or dart command runs.
    --disable-analytics         Disable telemetry reporting each time a flutter or dart command runs, until it
                                is re-enabled.
    --suppress-analytics        Suppress analytics reporting for the current CLI invocation.
    --packages                  Path to your "package_config.json" file.

Local build selection options (not normally required):
    --local-engine-src-path     Path to your engine src directory, if you are building Flutter locally.
                                Defaults to $FLUTTER_ENGINE if set, otherwise defaults to the path given in
                                your pubspec.yaml dependency_overrides for sky_engine, if any.
    --local-engine              Name of a build output within the engine out directory, if you are building
                                Flutter locally.
                                Use this to select a specific version of the engine if you have built multiple
                                engine targets.
                                This path is relative to "--local-engine-src-path" (see above).
    --local-engine-host         The host operating system for which engine artifacts should be selected, if you
                                are building Flutter locally.
                                This is only used when "--local-engine" is also specified.
                                By default, the host is determined automatically, but you may need to specify
                                this if you are building on one platform (e.g. MacOS ARM64) but intend to run
                                Flutter on another (e.g. Android).
    --local-web-sdk             Name of a build output within the engine out directory, if you are building
                                Flutter locally.
                                Use this to select a specific version of the web sdk if you have built multiple
                                engine targets.
                                This path is relative to "--local-engine-src-path" (see above).

Options for testing the "flutter" tool itself:
    --show-test-device          List the special "flutter-tester" device in device listings. This headless
                                device is used to test Flutter tooling.
    --show-web-server-device    List the special "web-server" device in device listings.
    --ci                        Enable a set of CI-specific test debug settings.

Available commands:

Flutter SDK
  bash-completion   Output command line shell completion setup scripts.
  channel           List or switch Flutter channels.
  config            Configure Flutter settings.
  doctor            Show information about the installed tooling.
  downgrade         Downgrade Flutter to the last active version for the current channel.
  precache          Populate the Flutter tool's cache of binary artifacts.
  upgrade           Upgrade your copy of Flutter.

Project
  analyze           Analyze the project's Dart code.
  assemble          Assemble and build Flutter resources.
  build             Build an executable app or install bundle.
  clean             Delete the build/ and .dart_tool/ directories.
  create            Create a new Flutter project.
  drive             Run integration tests for the project on an attached device or emulator.
  gen-l10n          Generate localizations for the current project.
  pub               Commands for managing Flutter packages.
  run               Run your Flutter app on an attached device.
  test              Run Flutter unit tests for the current project.

Tools & Devices
  attach            Attach to a running app.
  custom-devices    List, reset, add and delete custom devices.
  daemon            Run a persistent, JSON-RPC based server to communicate with devices.
  debug-adapter     Run a Debug Adapter Protocol (DAP) server to communicate with the Flutter tool.
  devices           List all connected devices.
  emulators         List, launch and create emulators.
  install           Install a Flutter app on an attached device.
  logs              Show log output for running Flutter apps.
  screenshot        Take a screenshot from a connected device.
  symbolize         Symbolize a stack trace from an AOT-compiled Flutter app.

Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used options.
参考资料
[1]

关于 IOS 的一些基础说明: https://nicogatekeeper.com/index.php/archives/10/

本文由 mdnice 多平台发布

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/606361.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

抖音小店怎么找达人带货的?分享几个成功率超高的沟通话术!

哈喽~我是电商月月 做抖音小店&#xff0c;特别是无货源的商家想要更多的流量&#xff0c;必定会尝试直播卖货&#xff0c;不会自己直播卖货&#xff0c;就会开通精选联盟&#xff0c;在里面找达人合作 那精选联盟到底是怎样找达人带货的呢&#xff1f; 有的达人打招呼了根本…

院校信息 | 伯明翰大学24Fall新增3个专业!附截止时间!

伯明翰大学针对2024年秋季入学&#xff0c;推出3个新的授课型硕士项目&#xff1a; MSc Financial Data Science 金融数据科学理学硕士 MSc Statistical Data Science 统计学数据科学理学硕士 MSc Statistics 统计学理学硕士 以上所有课程24fall申请截止时间为6月1日&#xf…

百病之源,根在肝脏!4种养肝法,助您对症养肝,越养越健康~

如今生活节奏比较快&#xff0c;人们的身体和精神都承受着巨大的压力&#xff0c;熬夜加班、喝酒应酬、通宵上网等&#xff0c;这些习惯都在悄悄损耗我们的肝脏&#xff0c;使得大家长期处于亚健康的边缘&#xff01; 中医讲&#xff0c;百病之源&#xff0c;根在肝脏。肝不好…

Vue.js-----vue组件

能够说出vue生命周期能够掌握axios的使用能够了解$refs, $nextTick作用能够完成购物车案例 Vue 生命周期讲解 1.钩子函数 目标&#xff1a;Vue 框架内置函数&#xff0c;随着组件的生命周期阶段&#xff0c;自动执行 作用: 特定的时间点&#xff0c;执行特定的操作场景: 组…

数字IC乘法器结构

目录 一、原理分析二、Xinlinx中的乘法器结构1.直接相乘2.移位相加乘法器3.加法树加法器 在数字IC中乘法器的结构是什么样的呢&#xff1f;接下来我们以两个4bit数的乘法进行举例&#xff0c;假定有两个4bit数据&#xff0c;分别为X(X3&#xff0c;X2&#xff0c;X1&#xff0c…

Ti雷达常用工具

Ti雷达常用工具 名称网站功能雷达开箱界面mmWave Demo Visualizer (ti.com)显示距离谱、RD谱图雷达参数估计mmWaveSensingEstimator根据性能设计估计参数雷达项目资料Embedded Software (ti.com)Ti雷达示例及说明书官方论坛Sensors forum - Sensors - TI E2E support forumsTi…

【复试分数线】四电四邮历年分数线汇总(第一弹)

24年考研国家线预计3月中旬公布&#xff0c;接下来各大院校就会公布自己的复试分数线。这次会为大家整理四电四邮的整理了近三年各院校的复试分数线作为参考&#xff0c;大家可以参考&#xff01; 大多数院校采取的是1.2:1差额的形式复试。举个例子&#xff0c;比如学校今年拟…

人工智能|推荐系统——工业界的推荐系统之涨指标

一、推荐系统的评价指标 涨指标的方法有哪些? 二、涨指标的方法:召回 2.1 改进双塔模型 2.2 Item-to-Item (I2I) 2.3 类似I2I 的模型

三.搜索与图论(未完结)

DFS(深搜) 之前写过三篇关于dfs的 练习总结: 基础算法--递归搜索DFS练习总结(上)-CSDN博客 基础算法--递归搜索DFS练习总结(中)-CSDN博客 基础算法--递归搜索DFS练习总结(下)-CSDN博客 以下题目均为 补充练习: P1460 [USACO2.1] 健康的荷斯坦奶牛 Healthy Holsteins …

使用Python将数据表中的浮点数据转换为整数:详细教程与案例分析

目录 一、引言 二、环境准备 三、读取数据表 四、浮点数据转换为整数 五、写入数据表 六、案例分析 步骤一&#xff1a;读取数据表 步骤二&#xff1a;浮点数据转换为整数 步骤三&#xff1a;写入新的数据表 七、注意事项 八、总结 在数据处理和分析的过程中&#x…

58. 【Android教程】音频录制:MediaRecord

在第 57 节我们使用 MediaPlayer 实现了一个 mp3 播放器&#xff0c;除了播放 Android 还提供了 MediaRecorder 用于录音。Android 设备基本都会有一个麦克风&#xff0c;通过 MediaRecorder 可以打开麦克风进行语音采集&#xff0c;这一节我们就来学习如何在 Android 系统上实…

将ESP工作为AP路由模式并当成服务器

将ESP8266模块通过usb转串口接入电脑 ATCWMODE3 //1.配置成双模ATCIPMUX1 //2.使能多链接ATCIPSERVER1 //3.建立TCPServerATCIPSEND0,4 //4.发送4个字节在链接0通道上 >ATCIPCLOSE0 //5.断开连接通过wifi找到安信可的wifi信号并连接 连接后查看自己的ip地址变为192.168.4.…

太牛逼了,用ComfyUI中一键完成电商模特换装换背景!商业级教程附上!

&#x1f310; 大背景&#xff1a;电商时代的画卷正在翻页 在全球电子商务风起云涌的今天&#xff0c;市场竞争愈发激烈。商家们始终在寻求提高效率、减少成本和增强用户体验的新方法。然而&#xff0c;一个关键问题一直困扰着电商行业——**如何高效且经济地展示商品&#xff…

python如何整体缩进

python自带编辑器的缩进和取消缩进快捷键&#xff1a; 整体缩进 Ctrl【 整体取消缩进 Ctrl】 pycharm编辑器的缩进和取消缩进快捷键&#xff1a; 整体缩进&#xff1a; tab 整体取消缩进&#xff1a; tabshift

ADOP带你了解:温度如何影响您的室外以太网电缆?

温度&#xff1a;室外以太网电缆的隐形敌人 在构建和维护室外以太网网络时&#xff0c;我们通常会考虑到许多物理因素&#xff0c;如电缆的长度、宽带容量和连接质量。然而&#xff0c;有一个不那么显眼但同样重要的因素常常被忽视&#xff0c;那就是温度。温度的波动不仅影响…

力扣-21. 合并两个有序链表-js实现

/*** Definition for singly-linked list.* function ListNode(val, next) {* this.val (valundefined ? 0 : val)* this.next (nextundefined ? null : next)* }*/ /*** param {ListNode} list1* param {ListNode} list2* return {ListNode}*/ const mergeTwoList…

数据库索引回表困难?揭秘PolarDB存储引擎优化技术

引言 数据库系统为了高效地存储、检索和维护数据&#xff0c;采用了多种不同的数据组织结构。不同的组织结构有其特定的用途和优化点&#xff0c;比如提高查询速度、优化写入性能、减少存储空间等。常见的数据库记录组织结构有&#xff1a; B-Tree B-Tree是一种平衡的多路搜索…

【MySQL 数据宝典】【索引原理】- 007 索引优化示例

一、单表优化 1.1 数据准备 下面是一张用户通讯表的表结构信息,这张表来源于真实企业的实际项目中,有接近500万条数据. CREATE TABLE user_contacts (id INT(11) NOT NULL AUTO_INCREMENT,user_id INT(11) DEFAULT NULL COMMENT 用户标识,mobile VARCHAR(50) DEFAULT NULL C…

QT-小项目:连接MY SQL数据库实现登录(下一章实现登录注册账号和忘记密码功能)

一、环境准备 1、下载MYSQL 64位&#xff0c;安装完成&#xff0c;制作简易数据库教程如下&#xff1a; MY SQL安装 2、QT 编译器使用 二、实现工程目录&#xff08;基于上一章基础上&#xff09; 三、源程序增加内容如下&#xff1a; login.cpp 增加头文件&#xff1a; #in…

python代码自动生成器原理 python 生成器原理

python生成器原理剖析 函数的调用满足“后进先出”的原则&#xff0c;也就是说&#xff0c;最后被调用的函数应该第一个返回&#xff0c;函数的递归调用就是一个经典的例子。显然&#xff0c;内存中以“后进先出”"方式处理数据的栈段是最适合用于实现函数调用的载体&…
最新文章