【问题标题】:Image_picker plugin for flutter causes build error when running on iOS在 iOS 上运行时 Flutter 的 Image_picker 插件会导致构建错误
【发布时间】:2020-05-06 01:38:59
【问题描述】:

在 iOS 模拟器上运行 Flutter 应用时出现此错误。

/Users/sirapol/Desktop/FirstCareFrontEnd/care_now_frontend_v1/build/ios/Debug-iphonesimulator/shared_preferences/shared_prefe
    rences.framework: resource fork, Finder information, or similar detritus not allowed
    Command CodeSign failed with a nonzero exit code
    note: Using new build system
    note: Planning build
    note: Constructing build description
    warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings
    are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
    warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings
    are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
    warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team
    ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')

这是我的 pubspec.yaml 文件

name: care_now_frontend_v1
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  provider: ^3.0.0
  http: ^0.12.0+4
  image_picker: ^0.6.3+1
  path_provider: ^1.1.0
  shared_preferences: ^0.5.6
  # image_picker: ^0.6.1+4
  # image_picker_modern: ^0.4.12+2
  firebase_storage: ^3.1.1



dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  assets:
     - assets/images/

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

这是我的 info.plist 文件。我已按照 image_picker 文档中的说明添加了 NSPhotoLibraryUsageDescription。

<?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>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>care_now_frontend_v1</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>UIViewControllerBasedStatusBarAppearance</key>
    <string>UIViewController</string>
    <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>NSLocationWhenInUseUsageDescription</key>
  <false/>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>${PRODUCT_NAME} Library Usage</string>
    <key>NSCameraUsageDescription</key>
    <string>${PRODUCT_NAME} Camera Usage</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>${PRODUCT_NAME} Microphone Usage</string>
</dict>
</plist>

我怀疑是 info.plist 文件导致了错误,但我不知道为什么。请帮帮我,谢谢。

【问题讨论】:

  • 我怀疑是,您在 pubspec.yaml 中安装的版本与您的颤振不兼容,因此请尝试删除该版本,或者转到您的 ios 文件夹并运行 pod install,然后尝试添加你的签约能力是一个开发团队
  • 更改您的 imagePicker 版本
  • 试过了,还是报错
  • 在 ios 上运行时,您必须将设置从新构建系统更改为旧构建系统才能成功构建它。我面临这个问题......

标签: flutter flutter-dependencies


【解决方案1】:

似乎主要的失败是您没有配置应用程序的项目的签名和功能部分,因此应用程序在构建时无法签名。

/Users/sirapol/Desktop/FirstCareFrontEnd/care_now_frontend_v1/build/ios/Debug-iphonesimulator/shared_preferences/shared_prefe
    rences.framework: resource fork, Finder information, or similar detritus not allowed
    Command CodeSign failed with a nonzero exit code
    note: Using new build system
    note: Planning build
    note: Constructing build description
    ...
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team
    ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')

要解决此问题,请在 xcode 中打开应用程序的 iOS 项目,然后选择 Runner Target。您应该会看到 Signing & Capabilities 设置部分,您可以在其中管理应用的签名,并为项目选择一个团队。如果您还没有团队,还会有一个用于创建团队的按钮。

至于架构错误:

warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings
    are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')
warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings
    are configured correctly for the iOS Simulator platform. (in target 'image_picker' from project 'Pods')

General 部分中将 部署目标设置为 iOS 9.0 及更高版本应该可以解决此问题,通常我建议将新的 Flutter 应用程序设置为最低 iOS 目标除非您有理由支持 iOS 8.0,否则有助于提高软件包的兼容性。

虽然与您的问题无关,而是未来的潜在问题,但我会将 NSLocationWhenInUseUsageDescription 下的 &lt;false/&gt; 更改为 &lt;string&gt; 描述,因为这是预期的:

<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow access to your device's location</string>

【讨论】:

    猜你喜欢
    • 2019-05-02
    • 2019-10-22
    • 2022-06-11
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 2021-01-26
    • 2021-03-06
    相关资源
    最近更新 更多