Flutter 无法为 IOS 构建

发布于 2025-01-15 08:18:13 字数 2570 浏览 0 评论 0原文

我正在使用 flutter 2.10.3 我创建了一个新项目,我能够在 simulator iphone 8 上运行,但是当我运行 flutter build ios 时我收到以下错误。

    The following build commands failed:
                CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'vibration' from project 'Pods')
                Ld

/Users/bilalrabbi/Library/Developer/Xcode/DerivedData/Runner-eqtwcanhgaiurgblzcjnjgoffipl/Build/Intermediates.noindex/Pods.build/Release-iphoneos/shared_preferences_ios.buil
                d/Objects-normal/armv7/Binary/shared_preferences_ios normal armv7 (in target 'shared_preferences_ios' from project 'Pods')
               (2 failures)

[ +320 ms] Uncategorized (Xcode): Command CompileSwiftSources failed with a nonzero exit code

[   +6 ms] Error (Xcode): Framework not found Flutter

已经删除了 pod 文件。删除派生数据。更新 pod 缓存,但似乎没有任何效果。当我尝试再次构建时,我收到此错误 这是我的 PodFile,

# 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'] = 'true'

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)
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
    end
  end
end

我也尝试过使用 platform :ios, '11.0'

I am using flutter 2.10.3 I have created a new project i was able to run on simulator iphone 8 but when i run flutter build ios i am getting below error.

    The following build commands failed:
                CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'vibration' from project 'Pods')
                Ld

/Users/bilalrabbi/Library/Developer/Xcode/DerivedData/Runner-eqtwcanhgaiurgblzcjnjgoffipl/Build/Intermediates.noindex/Pods.build/Release-iphoneos/shared_preferences_ios.buil
                d/Objects-normal/armv7/Binary/shared_preferences_ios normal armv7 (in target 'shared_preferences_ios' from project 'Pods')
               (2 failures)

and

[ +320 ms] Uncategorized (Xcode): Command CompileSwiftSources failed with a nonzero exit code

[   +6 ms] Error (Xcode): Framework not found Flutter

I have removed pod files. delete derived data. update pod cache but nothing seems to work. When i try to build again i am getting this error
Here is my PodFile

# 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'] = 'true'

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)
    target.build_configurations.each do |build_configuration|
      build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64 i386'
    end
  end
end

I also tried with platform :ios, '11.0'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清眉祭 2025-01-22 08:18:13

尝试删除flutter SDK并重新安装
然后在项目文件夹中运行这些命令

flutter clean
flutter pub upgrade
flutter pub get

,然后切换到 ios 文件夹并运行

pod install

“现在尝试构建”。

try deleting flutter SDK and re-install it
then run these commands in the project folder

flutter clean
flutter pub upgrade
flutter pub get

then switch to the ios folder and run

pod install

Now try to build.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文