M1 Mac Xcode构建完成,但颤动项目失败(苹果硅片)

人气:923 发布:2022-10-16 标签: ios xcode flutter flutter-dependencies apple-m1

问题描述

每当我在我的M1Mac上运行任何项目时,我都会遇到一个问题。 我已经尝试了堆栈溢出和GitHub的所有解决方案。我快要失去我的。第四个项目,因为麻烦。 起初,我认为这是因为Fflats MacOS桌面支持。把它弄坏了,什么都没变。 当我向我的应用程序添加一些依赖项并将其用作小部件或函数时,项目失败。 它毁了我的第四天。我正在分享所有详细信息,并热忱等待您的帮助。

转载:

已禁用MacOS颤动桌面支持 删除podfile.lock并重新启动 在Xcode Runner/Runner中仅为内部版本禁用 按原样安装CocoaPods和FFI(第一个答案)cocoapods_ffi 将部署目标更改为9和10

颤动医生-v;

alperenbaskaya@Alperen-MacBook-Air ios % flutter doctor -v
[✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.1 20D74 darwin-arm, locale tr-TR)
    • Flutter version 2.0.1 at /Users/alperenbaskaya/Desktop/flutter
    • Framework revision c5a4b4029c (3 months ago), 2021-03-04 09:47:48 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/alperenbaskaya/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (1 available)
    • iPhone 11 Pro (mobile) • 8E932E0F-46C9-42FC-AA28-06DBA7A513D6 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)

• No issues found!

错误日志;

Failed to build iOS app
Error output from Xcode build:
↳
    objc[89556]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1eb708188) and ?? (0x115c482b8). One of the two will be used. Which one is undefined.
    objc[89556]: Class AMSupportURLSession is implemented in both ?? (0x1eb7081d8) and ?? (0x115c48308). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **


Xcode's output:
↳
    abseil-dfbvnbqkknxxbhdudyeskahnmgpi
    building file list ... rsync: link_stat "/Users/alperenbaskaya/AndroidStudioProjects/app_app/build/ios/Debug-iphonesimulator/App.framework" failed: No such file or directory (2)
    done

    sent 29 bytes  received 20 bytes  98.00 bytes/sec
    total size is 0  speedup is 0.00
    rsync error: some files could not be transferred (code 23) at /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/main.c(996) [sender=2.6.9]
    Command PhaseScriptExecution failed with a nonzero exit code
    abseil-dfbvnbqkknxxbhdudyeskahnmgpi
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    note: Removed stale file '/Users/alperenbaskaya/Library/Developer/Xcode/DerivedData/Runner-diukrbptujoetdfkyqoxkpqvirsd/Build/Products/Debug-iphonesimulator/sqflite/sqflite.framework'

Pod;

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'false'
project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

编辑:

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete

推荐答案

在项目Pod文件中添加以下代码并运行命令 Pod安装

post_install do |installer|
installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    flutter_additional_ios_build_settings(target)
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
  end
end

结束

472