rive-app / rive-app/rive-flutter
rive_native Package.swift fails to compile under Swift Package Manager: `String.replacingOccurrences` without `import Foundation`
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 1.5k
- Forks
- 240
- PR merge metrics
- No merged PRs in 30d
Description
Affected versions
Confirmed in rive_native 0.1.4 and 0.1.6 (likely all SPM-shipping versions). Pulled transitively via rive 0.14.4 / 0.14.6.
Environment
- Flutter 3.41.4 (stable)
- Xcode 26.0.1 (build 17A400)
- macOS 14, arm64
- Swift 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
- iOS deployment target 15.0
- Hybrid Flutter SPM mode (
flutter.config.enable-swift-package-manager: trueinpubspec.yaml)
Bug
rive_native/ios/rive_native/Package.swift lines 1–6:
// swift-tools-version: 5.9
import PackageDescription
// Version and checksum are auto-updated by native/build_xcframework.sh
let riveNativeVersion = "0.1.6+1"
let riveNativeVersionURLComponent = riveNativeVersion.replacingOccurrences(of: "+", with: "%2B")
String.replacingOccurrences(of:with:) is a Foundation API. Swift Package Manager compiles Package.swift manifests in a minimal toolchain that does not auto-import Foundation. Result: every swift package resolve / xcodebuild -resolvePackageDependencies against a Flutter project that pulls in rive_native fails with:
error: Invalid manifest (compiled with: ["…", ".../rive_native/Package.swift", …])
.../rive_native/Package.swift:6:55: error: value of type 'String' has no member 'replacingOccurrences'
4 | // Version and checksum are auto-updated by native/build_xcframework.sh
5 | let riveNativeVersion = "0.1.6+1"
6 | let riveNativeVersionURLComponent = riveNativeVersion.replacingOccurrences(of: "+", with: "%2B")
| `- error: value of type 'String' has no member 'replacingOccurrences'
Cascading symptom (why this is hard to diagnose)
When SPM fails to compile a single plugin manifest in a Flutter FlutterGeneratedPluginSwiftPackage, the resolver bails out before walking transitive deps. The high-level error xcodebuild reports is misleading — in our case it surfaced as a fake firebase-ios-sdk version conflict:
xcodebuild: error: Could not resolve package dependencies:
Failed to resolve dependencies Dependencies could not be resolved because
'cloud_functions' depends on 'firebase-ios-sdk' 12.9.0..<13.0.0 and
root depends on 'firebase-ios-sdk' 11.7.0..<12.0.0.
The 11.7.0 pin doesn't exist anywhere in the project — it's an artifact of SPM falling back to stale resolution state when the manifest compile fails. We spent ~2 hours chasing the firebase-ios-sdk red herring before tracing the actual rive_native manifest error in swift package resolve --verbose output.
Fix (one line)
Add import Foundation to rive_native/ios/rive_native/Package.swift line 2:
// swift-tools-version: 5.9
import PackageDescription
import Foundation // ← add this
// Version and checksum are auto-updated by native/build_xcframework.sh
let riveNativeVersion = "0.1.6+1"
let riveNativeVersionURLComponent = riveNativeVersion.replacingOccurrences(of: "+", with: "%2B")
Verified locally: with import Foundation added to the pub-cache copy, xcodebuild -resolvePackageDependencies proceeds past manifest compilation and resolves the full graph successfully.
This is the same pattern other Flutter plugins use — e.g. firebase_core/ios/firebase_core/Package.swift imports both PackageDescription and Foundation since it uses String(contentsOfFile:) and NSString.path(withComponents:).
Why this matters now
Flutter 3.41+ ships SPM as a project-local opt-in (flutter.config.enable-swift-package-manager: true). With the Firebase Apple SDK CocoaPods publishing cutoff in October 2026, every Flutter+Firebase iOS app needs to migrate to SPM mode by then — and any project that pulls rive (which transitively pulls rive_native) will hit this error during their migration.
Happy to send a PR if rive-app accepts external contributions for rive_native — just let me know.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rive_native/ios/rive_native/Package.swift and inspect the manifest imports and String.replacingOccurrences call. Run swift package resolve or xcodebuild -resolvePackageDependencies against a project using rive_native. Done means the manifest compiles and package dependency resolution proceeds without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100