You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter报错:SWIFT_VERSION需设为支持值,求助解决方案

Fixing "Swift Language Version (SWIFT_VERSION) must be set" Error for simple_permissions in Flutter

I’ve run into this exact headache before while working with the simple_permissions library in Flutter. The frustrating part is that even if you manually add the Swift version setting in Xcode, the simple_permissions target under Pods often resets this config every time you run pod install. Here’s the reliable, long-term fix:

Step 1: Add Swift Version Configuration to Your Podfile

Open your project’s root Podfile (located in the ios directory) and paste this post-install hook at the very end:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'simple_permissions'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '5.0' # Adjust to your project's Swift version (e.g., 4.2 if your Xcode requires it)
      end
    end
  end
end

This script ensures that every time you install or update Pods, the simple_permissions target automatically gets the correct Swift version assigned—no more manual Xcode tweaks that get overwritten.

Step 2: Clean and Reinstall Pods

In your terminal, navigate to the ios folder of your Flutter project and run these commands to wipe old configurations and apply the new settings:

pod deintegrate
pod install

pod deintegrate completely removes existing Pod setups, so the new Swift version setting will take full effect when you run pod install.

Step 3: Verify the Setting

Open your project’s .xcworkspace file (not the .xcodeproj), navigate to the Pods project, find the simple_permissions target, and check the Build Settings tab. You should now see the "Swift Language Version" set to the value you specified in the Podfile.

Quick Notes:

  • Make sure the Swift version you pick is supported by your installed Xcode. For example, Xcode 11+ supports Swift 5.0 and above, while older Xcode versions may require 4.2 or lower.
  • Never edit the Pods project directly—any changes you make there will be erased the next time you run pod install. Using the Podfile hook is the only persistent way to lock in this configuration.

内容的提问来源于stack exchange,提问作者Rosenberg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:17:31