vsCode 不在物理 iPhone 上运行颤振应用程序

Posted

技术标签:

【中文标题】vsCode 不在物理 iPhone 上运行颤振应用程序【英文标题】:vsCode doesn't run flutter app on physical iPhone 【发布时间】:2020-08-02 07:41:03 【问题描述】:

我刚刚安装了最新版本的 Flutter 和 xcode,当我尝试在实际 iPhone 上运行 Flutter 应用程序时出现错误。适用于ios模拟器。奇怪的是,当我从 xcode 运行它时它可以工作,但是当我从 vsCode 运行它时,我收到以下错误:

It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
  open ios/Runner.xcworkspace

我尝试做的事情:

将包标识符更改为 myEmailAddress@gmail.com.appTitle 清理并构建 ios 应用 清理然后运行flutter build bundle

我做错了什么,如何让 vsCode 在 iPhone 上运行应用程序?

这是完整的错误:

Launching lib/main.dart on Jessica’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: ITYTO5RCWD
Xcode build done.                                           25.4s
Failed to build iOS app
Error output from Xcode build:
↳
    2020-04-19 13:53:51.828 xcodebuild[2046:21215] [MT] iPhoneConnect: ????<DVTiOSDevice ...> == Underlying device preparation errors ==
    2020-04-19 13:53:51.828 xcodebuild[2046:21215] [MT] iPhoneConnect: Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.
    Domain: com.apple.platform.iphoneos
    Code: 5
    Failure Reason: allowsSecureServices: 1. isConnected: 0. Platform: <"...platform info...">. DTDKDeviceIdentifierIsIDID: 0
    User Info: 
        DVTDeviceDescription = "...device info..."
    
    --
    2020-04-19 13:53:51.829 xcodebuild[2046:21215] [MT] iPhoneConnect: ????<"...platform info..."> == END: Underlying device preparation errors ==
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/Jessica/Development/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.m:88:37: warning: incompatible pointer types sending 'FlutterEngine *' to parameter of type 'NSObject<FlutterBinaryMessenger> * _Nonnull' [-Wincompatible-pointer-types]
                        binaryMessenger:_headlessEngine];
                                        ^~~~~~~~~~~~~~~
    In module 'Flutter' imported from /Users/Jessica/Development/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.h:2:
    /Users/Jessica/Desktop/flutter_game2/ios/Flutter/Flutter.framework/Headers/FlutterChannels.h:178:74: note: passing argument to parameter 'messenger' here
                          binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
                                                                             ^
    1 warning generated.
    /Users/Jessica/Desktop/flutter_game2/build/ios/Debug-iphoneos/Runner.app: resource fork, Finder information, or similar detritus not allowed
    Command CodeSign failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Could not build the precompiled application for the device.

It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
  open ios/Runner.xcworkspace

Error launching application on Jessica’s iPhone.
Exited (sigterm)

【问题讨论】:

类似的东西? github.com/flutter/flutter/issues/41198#issuecomment-540131788 @brianLikeApple 现在确实修复了它。谢谢!! flutter clean 【参考方案1】:

好的,所以我通过按 vscode 左上角的搜索图标,然后搜索 com.example 解决了这个问题 然后我看到了 ios 文件夹中的三个搜索结果,单击它并将所有三个 com.example 替换为您在 xcode 中创建的标识符。

【讨论】:

【参考方案2】:

您可以在 Xcode 中更改您的签名标识符

为此,只需在 Xcode 中使用应用程序打开您的工作区,然后转到签名和功能以将默认 com.example 更改为其他任何内容...

【讨论】:

【参考方案3】:

最好使用如下给app公司/组织名称

flutter create --org com.yourdomain your_app_name

Swift、Kotlin 和 androidx 依赖项是默认选项

在 Android Studio 或 VSCode 中打开创建的项目后

参数

--org com.yourcompany

将为 Android 形成 applicationId:

com.yourcompany.yourappname 和 iOS PRODUCT_BUNDLE_IDENTIFIER:

com.yourcompany.yourAppName 探索所有可能的参数类型

flutter create --help

【讨论】:

以上是关于vsCode 不在物理 iPhone 上运行颤振应用程序的主要内容,如果未能解决你的问题,请参考以下文章

在物理 iPhone 上运行颤振开发的应用程序时出错

在 Windows 10 上使用 VS Code 在 iphone 上调试颤振

Flutter 应用程序在 Android 模拟器上运行,但不在物理设备上(OnePlus 7T)

我可以在我的物理 iPhone 设备上从 VSCode (Windows) 测试我的 Flutter 应用程序吗?

在 iPhone Flutter 上启动应用程序时出错

尝试在 vscode 上通过颤振运行应用程序时出现此错误