在iOS上运行时,用于flutter的Image_picker插件会导致生成错误

时间:2020-01-20 03:21:26

标签: flutter flutter-dependencies

在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文件正在引起该错误,但是我不知道为什么。请帮助我,谢谢。

1 个答案:

答案 0 :(得分:1)

主要故障似乎是您尚未配置应用程序的项目的“签名和功能”部分,因此在构建时无法对应用程序进行签名。

environment variables

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

关于架构错误:

/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')

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

虽然与您的问题无关,但将来可能有问题,但我会在{strong> NSLocationWhenInUseUsageDescription 下将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') 更改为<false/>的描述,因为这是预期的:

<string>