构建Superhero iOS钱包时遭遇SWIFT_VERSION值不能为空的报错
Let's break down how to resolve this Swift version error you're hitting while setting up your Superhero wallet for iOS with Cordova. This issue pops up because your auto-generated Xcode project lacks an explicit Swift version configuration—something that's required if any of your Cordova plugins rely on Swift code, or if the project structure expects it by default.
Here are three reliable solutions to get you back on track:
1. Manually Set Swift Version Directly in Xcode
This is the fastest way to get your project running immediately:
- Open your
.xcodeprojfile in Xcode - Select your project's root node (the top-level item) in the Project Navigator
- Switch to the Build Settings tab
- Use the search bar to look for
SWIFT_VERSION(ensure "All" settings are visible, not just "Basic") - Set the value to a supported Swift version (I recommend 5.0 or higher—match it to what your Xcode version supports; Xcode 14+ works best with Swift 5.7+)
- Double-check that each project target has the same setting (they should inherit it, but it's safe to confirm)
- Clean your project (
Cmd+Shift+K) and try building again
2. Persist Swift Version via Cordova's config.xml
To avoid reconfiguring this every time you run cordova prepare ios, add this preference to your project's config.xml:
<preference name="SwiftVersion" value="5.0" />
After adding this line, re-run cordova prepare ios—Cordova will automatically apply the specified Swift version to your Xcode project from now on.
3. Verify and Update Your Cordova Plugins
Outdated or poorly configured plugins can sometimes trigger this error:
- Run
cordova plugin listto see all installed plugins - Identify any plugins that explicitly use Swift (like camera, location, or payment-related plugins)
- Update outdated plugins with
cordova plugin update [plugin-name] - If a specific plugin still causes issues, check its official docs to see if it requires a specific Swift version or additional configuration
Quick Tip
Make sure your Xcode version supports the Swift version you pick:
- Swift 5.7+ requires Xcode 14.0+
- Swift 5.0 works with Xcode 10.2+
内容的提问来源于stack exchange,提问作者Vikram Anand Bhushan

