flutter项目运行到IOS手机

1.通过Android studio可以看到创建ios模拟器的选项,但是点击创建会报错,原因是我没安装xcode
2.安装xcode,因为我mac版本是10.14,所以安装了xcode10.1,然后我flutter版本比较新,他最低支持的xcode版本是11,所以我又把flutter sdk插件降低了版本号。

git reset --hard cc949a8

3.flutte版本降低后,

  • 运行flutter doctor,报错cocoapods没安装
    直接照着提示运行了sudo gem install cocoapods / pod setup,
  • 再运行flutter doctor,还是有问题,提示cocoapods已安装,但还是不能使用
    通过下面命令解决,是cocoapods版本号的问题,
    下载失败可以切换网络试试,下载时间比较久
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup

4.安装完成,再运行flutter doctor,就没有报错了
5. 打开xcode,录入appid和密码,运行模拟器,

提示:There are no devices registered in your account on the developer website. Plug in and select a device
解决方法:(期间各种修改bundle identifier,一直不管用,最后百度发现是因为我一直用的模拟器。用我自己的手机连一下就好了)
(把错误直译过来就是:
我们没有在开发者账号(Apple ID)上注册iOS设备(真机)
他让我们把iOS设备连上电脑,选择一个设备让Xcode自动帮我们注册一下。)
网址:https://blog.csdn.net/weixin_30974373/article/details/112710206
  1. 接着运行报错
错误提示为:
/Runner.app/Frameworks/Flutter.framework:Permission denied
解决方法:
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -exec chmod a-w "{}"  \;
改为
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -iname '.h' -exec chmod a-w "{}" \;
网址; https://blog.csdn.net/Gemini_Kanon/article/details/106471945

7.再运行模拟器就可以安装成功了
8.flutter跑真机报错

 The service is invalid. AMDeviceSecureStartService(device, CFSTR("com.apple.debugserver"), NULL, &con)
Could not run build/ios/iphoneos/Runner.app on 00008030-0006686A3E63802E.

解决网址:https://www.jianshu.com/p/62c995282134
9.最后我还是运行不到我的手机上,我xcode版本是10,ios手机是14.1,期间试了各种方法,加14.1的支持包,都失败了 所以我放弃了,我怀疑是xcode太老了
10. 可以在Android studio 选择ios模拟器运行,也可以在xcode运行。(xcode的作用是安装ios模拟器和方便调试)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要在 Android Studio 中部署 Flutter 项目iOS 设备上,需要遵循以下步骤: 1. 在 Flutter 项目中打开终端,并运行 `flutter build ios` 命令,以构建 iOS 应用程序。 2. 在 iOS 设备上安装 Xcode,打开 Xcode 并选择 `File -> New -> Project` 菜单项。 3. 在弹出的菜单中,选择 `Application -> Single View Application`,并输入应用程序的名称和组织标识符。 4. 在 `Product` 菜单中选择 `Destination`,并选择要部署到的 iOS 设备。 5. 在 `File` 菜单中选择 `Add Files to "Project Name"`,并选择 Flutter 项目中的 `ios` 文件夹。 6. 在弹出的菜单中,选择 `Copy items if needed`,并点击 `Finish`。 7. 在 `AppDelegate.swift` 文件中,添加以下代码: ``` import UIKit import Flutter @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } } ``` 8. 在 `Info.plist` 文件中,添加以下权限: ``` <key>NSCameraUsageDescription</key> <string>Camera Permission</string> <key>NSMicrophoneUsageDescription</key> <string>Microphone Permission</string> <key>NSPhotoLibraryUsageDescription</key> <string>Photo Library Permission</string> ``` 9. 在 Xcode 中,选择 `Product -> Build` 菜单项,以构建 iOS 应用程序。 以上就是在 Android Studio 中部署 Flutter 项目iOS 设备上的步骤。注意,在构建 iOS 应用程序之前,需要在 Mac 上安装并配置 Xcode 和 iOS 开发人员工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值