无法安装请求的应用程序:无法确定应用程序的包标识符。 - 颤振

Failed to install the requested application: The bundle identifier of the application could not be determined. - Flutter

我在 Xcode 模拟器中启动 flutter 应用程序时遇到问题。 android 版本的应用程序在使用 android 模拟器测试时工作正常,没有出现任何错误,即使在成功构建应用程序时也是如此,但我不知道 [=28 出了什么问题=]. (IOS 版本)

flutter 版本:v2.5.3 |开发工具:v2.8.0

错误日志:(扑运行)

Unable to install /Users/USER_NAME/Documents/APP_NAME/main_files/source/wordpress_app/build/ios/iphonesimulator/Runner.app on FEBE8117-5EC5-429F-820D-DA1F80359C7B. This is sometimes caused by a
malformed plist file:
ProcessException: Process exited abnormally:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The bundle identifier of the application could not be determined.
Ensure that the application's Info.plist contains a value for CFBundleIdentifier.
  Command: /usr/bin/arch -arm64e xcrun simctl install FEBE8117-5EC5-429F-820D-DA1F80359C7B
  /Users/USER_NAME/Documents/APP_NAME/main_files/source/wordpress_app/build/ios/iphonesimulator/Runner.app
Error launching application on iPhone 11.

Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>My App Name</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(com.MY_NAME.MY_APP_NAME)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>myAppName</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

感谢您提供的任何帮助。

问题是 Info.plist 中不包含有效的 CFBundleVersion。确保您的包包含有效的 CFBundleVersion。

您需要将代码粘贴到列表文件中

CFBundle版本 $(FLUTTER_BUILD_NUMBER)

发生错误是因为您的包标识符 (CFBundleIdentifier) 不正确。 com.MY_NAME.MY_APP_NAME 不是环境变量,因此无法使用 $().

求值

在 flutter 中,CFBundleIdentifier 应设置为 PRODUCT_BUNDLE_IDENTIFIER 的值,这是在 ios\Runner.xcodeproj\project.pbxproj.

中定义的环境变量

因此,在您的 Info.plist 文件中,替换:

<key>CFBundleIdentifier</key>
<string>$(com.MY_NAME.MY_APP_NAME)</string>

与:

<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

这有时可能是因为您没有添加 GoogleService-Info 文件