iOS Flutter Build Fails with “Build input file cannot be found” for Privacy Bundles
I’m encountering a build failure when creating an IPA for my Flutter iOS app, specifically with privacy bundles for the path_provider_foundation and image_picker_ios plugins.
Error Message
Error (Xcode): Build input file cannot be found: '/Users/builder/Library/Developer/Xcode/DerivedData/Runner-xxx/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/path_provider_foundation_privacy.bundle/path_provider_foundation_privacy'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
Environment Details
- Flutter: 3.16.0
- iOS deployment target: 13.0
- Xcode: 15.2
- CocoaPods: 1.16.2
- Plugins:
image_picker: ^1.2.0,path_provider: ^2.1.5
Troubleshooting Steps Attempted
flutter cleanandflutter pub getpod deintegrateandpod install- Updated to latest plugin versions
- Cleaned DerivedData
- Verified that privacy bundles are generated in
build/ios/Release-iphoneos/withPrivacyInfo.xcprivacyfiles
Issue Description
The privacy bundles are being generated correctly with PrivacyInfo.xcprivacy files, but Xcode is looking for executable files with specific names (path_provider_foundation_privacy, image_picker_ios_privacy) inside these bundles.
Podfile Configuration
platform :ios, '13.0'
target 'Runner' do
use_frameworks! :linkage => :static
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 |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
config.build_settings['OTHER_LDFLAGS'] ||= []
config.build_settings['OTHER_LDFLAGS'] << '-ObjC'
end
end
end
Question
Why is Xcode expecting executable files instead of the standard iOS privacy bundles? Is there a configuration issue in my project, or is this a known issue with these specific plugin versions?
The build works fine for debug builds but fails specifically during IPA creation (archive process). I need to successfully build the IPA file for distribution.
The issue you’re experiencing is a known problem with Flutter iOS builds where privacy bundles are being incorrectly interpreted as Swift executable files during the IPA archive process. This occurs when plugins like path_provider_foundation and image_picker_ios include privacy bundles with .xcprivacy files, but Xcode’s build system expects these to be executable binaries rather than privacy declaration bundles.
Contents
- Understanding the Privacy Bundle Issue
- Root Cause Analysis
- Immediate Workarounds
- Long-term Solutions
- Plugin-Specific Fixes
- Best Practices for iOS Builds
Understanding the Privacy Bundle Issue
The error message indicates that Xcode is looking for executable files within the privacy bundles rather than recognizing them as privacy declaration files. This is a fundamental misunderstanding in the build process where privacy bundles are being treated as Swift executables.
According to the Flutter GitHub issue #169272, this problem occurs specifically during the IPA archive process when privacy bundles with .xcprivacy files are present. The build system incorrectly expects these to be binary executables rather than privacy declaration bundles.
Key Symptoms
- Build works fine for debug configurations
- Fails specifically during
flutter build ipaor Xcode archive process - Error mentions missing executable files in privacy bundles
- Privacy bundles are correctly generated with
PrivacyInfo.xcprivacyfiles
Root Cause Analysis
The issue stems from how Xcode processes privacy bundles during the archive phase. When Flutter plugins include privacy declarations, they create bundles with .xcprivacy files, but Xcode’s build system is misinterpreting these as executable files that should be produced by build scripts.
As explained in the Flutter issue documentation, this is particularly problematic with:
path_provider_foundationpluginimage_picker_iosplugin- Any plugin that includes privacy declarations
The error occurs because Xcode expects executable files with specific names like path_provider_foundation_privacy inside the bundle directories, but these are actually privacy declaration files, not executables.
Contributing Factors
- Static linking configuration: Your Podfile uses
use_frameworks! :linkage => :static - Privacy declarations: Modern plugins include privacy requirement declarations
- Archive process: The issue manifests specifically during IPA creation, not regular builds
Immediate Workarounds
1. Modify Podfile Configuration
Update your Podfile to address the privacy bundle interpretation issue:
platform :ios, '13.0'
target 'Runner' do
use_frameworks! :linkage => :static
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 |config|
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
config.build_settings['OTHER_LDFLAGS'] ||= []
config.build_settings['OTHER_LDFLAGS'] << '-ObjC'
# Add privacy bundle handling
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = 'com.yourcompany.app'
end
end
# Workaround for privacy bundle issues
installer.pods_project.build_configurations.each do |config|
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
end
end
2. Clean and Rebuild Thoroughly
# Complete clean sequence
flutter clean
rm -rf ios/Podfile.lock
rm -rf ios/Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/Runner-*
cd ios && pod deintegrate && pod install
cd ..
flutter clean
flutter pub get
flutter build ios --release
3. Manual Privacy Bundle Configuration
If the issue persists, manually configure the privacy bundles in your Xcode project:
- Open the iOS project in Xcode
- Select the Runner target
- Go to “Build Phases” tab
- Add a “Run Script” phase with:
#!/bin/sh
echo "Configuring privacy bundles"
find "${BUILT_PRODUCTS_DIR}" -name "*.bundle" -type d | while read -r bundle_dir; do
privacy_file="${bundle_dir}/PrivacyInfo.xcprivacy"
if [ -f "$privacy_file" ]; then
echo "Privacy file found: $privacy_file"
else
echo "Warning: No privacy file in $bundle_dir"
fi
done
Long-term Solutions
1. Update Flutter and Plugin Versions
Ensure you’re using the latest versions that address privacy bundle issues:
flutter upgrade flutter pub outdated flutter pub upgrade path_provider_foundation image_picker_ios
The Flutter team has been working on fixes for these privacy bundle interpretation issues in recent versions.
2. Configure Xcode Project Settings
Modify your Xcode project settings to properly handle privacy bundles:
- Open
ios/Runner.xcworkspacein Xcode - Select the Runner project
- Go to “Build Settings”
- Search for “Privacy” and ensure privacy-related settings are configured correctly
- Add the following to “Other Linker Flags”:
-framework Foundation-framework CoreGraphics
3. Use Alternative Build Methods
If the standard flutter build ipa continues to fail, try alternative approaches:
# Method 1: Build with Xcode directly
open ios/Runner.xcworkspace
# Archive manually in Xcode
# Method 2: Use xcodebuild
cd ios
xcodebuild -workspace Runner.xcworkspace -scheme Runner -configuration Release -archivePath Runner.xcarchive archive
xcodebuild -exportArchive -archivePath Runner.xcarchive -exportPath . -exportOptionsPlist ExportOptions.plist
Plugin-Specific Fixes
For path_provider_foundation
The path_provider_foundation plugin has had several issues with iOS builds:
-
Ensure you’re using version 2.1.5 or later:
yamlpath_provider: ^2.1.5 -
Add the following to your Podfile:
rubypod 'path_provider_foundation', :path => '../'
For image_picker_ios
The image_picker plugin has specific requirements:
-
Update to the latest version:
yamlimage_picker: ^1.2.0 -
Ensure your Podfile includes:
rubypod 'image_picker_ios', :path => '../' -
In Xcode, verify that the app’s project and target linker flags are set from “image_picker” to “image_picker_ios” as mentioned in this Stack Overflow solution.
Best Practices for iOS Builds
1. Regular Maintenance
- Keep Flutter and plugins updated regularly
- Monitor Flutter GitHub issues for privacy bundle fixes
- Test both debug and release builds frequently
2. Build Environment Setup
# Recommended pre-build cleanup
flutter clean
rm -rf ~/.pub-cache/hosted/pub.dev/*/ios
rm -rf ios/Pods
rm -rf ios/.symlinks
# Fresh installation
flutter pub get
cd ios && pod install && cd ..
3. Archive Process Optimization
- Use
flutter build ios --releasefirst to validate the build - Archive using Xcode when CLI methods fail
- Consider using CI/CD services that have updated Flutter toolchains
4. Monitoring and Debugging
Always check for these specific error patterns during builds:
- Privacy bundle related errors
- Module not found errors
- Archive process failures
- Symbolication issues
Sources
- Flutter GitHub Issue #169272 - Privacy bundles being interpreted as Swift executables
- Stack Overflow - Flutter iOS Build Error - framework image_picker not found
- Stack Overflow - Flutter : Failed to build iOS app “ARCHIVE FAILED”
- Reddit - Flutter iOS privacy bundle issues
- Flutter GitHub Issue #57246 - Xcode build error: Module ‘image_picker’ not found
- Flutter GitHub Issue #166367 - ITMS-90048: This bundle is invalid
Conclusion
The privacy bundle build error you’re encountering is a known issue in the Flutter ecosystem, particularly affecting plugins that include privacy declarations. While this can be frustrating, there are several effective solutions:
- Immediate fix: Modify your Podfile configuration and perform a thorough clean/rebuild
- Long-term solution: Keep Flutter and plugins updated to the latest versions that address these issues
- Alternative approach: Use Xcode’s archive process when CLI methods fail
- Prevention: Regular maintenance and monitoring of Flutter issue trackers for privacy bundle fixes
The key insight is that Xcode is incorrectly treating privacy declaration bundles as executable files during the archive process. This is primarily a tooling issue rather than a problem with your code or configuration. By implementing the workarounds and staying current with Flutter updates, you can successfully build and distribute your iOS app.
Remember that this issue specifically affects release builds and IPA creation—debug builds typically work fine. If you continue to experience problems, consider using alternative build methods or monitoring the Flutter GitHub issues for permanent fixes from the Flutter team.