Swift module dependency problem error on ios builds
Environment
flutter doctor` was fine, even though it wasn't...
- purchases-flutter` 8.72
- purchases_ui_flutter: ^8.7.2
- Xcode version:** Xcode 16.3 (Build 16E140)
- Flutter version:** Flutter 3.29.3 on channel stable
- CocoaPods version:** 1.16.2 - CocoaPods 1.16+
- iOS deployment target:** 14.0
- macOS version:** macOS 15.3 (24D60)
- Swift version:** Swift 5.0
- Device/Simulator: Running on physical iPhone with iOS 18.3
Error in build fail after "flutter run"
Could not build the precompiled application for the device.
Parse Issue (Xcode): Module 'RevenueCat' not found
/Users/joe/.pub-cache/hosted/pub.dev/purchases_flutter-8.7.2/ios/Classes/PurchasesFlutterPlugin.h:5:8
Swift Compiler Error (Xcode): No such module 'PurchasesHybridCommonUI'
/Users/joe/.pub-cache/hosted/pub.dev/purchases_ui_flutter-8.7.2/ios/Classes/PurchasesUiFlutterPlugin.swift:
6:7
Error launching application on iPhone.
Swift modules weren't properly finding each other during the build process. The fix required two specific changes in the post_install block on the podfile (see below).
- "Module 'RevenueCat' not found" in PurchasesFlutterPlugin.h
- "No such module 'PurchasesHybridCommonUI'" in PurchasesUiFlutterPlugin.swift
Fix:
- Adding BUILD_LIBRARY_FOR_DISTRIBUTION flag for the RevenueCat modules:
if ['RevenueCat', 'PurchasesHybridCommon', 'PurchasesHybridCommonUI', 'RevenueCatUI'].include?(target.name)
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
- Explicitly setting the Swift module include paths for the purchases plugins:
if target.name == 'purchases_flutter' || target.name == 'purchases_ui_flutter'
config.build_settings['SWIFT_INCLUDE_PATHS'] = '$(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/RevenueCat" "${PODS_CONFIGURATION_BUILD_DIR}/PurchasesHybridCommon" "${PODS_CONFIGURATION_BUILD_DIR}/PurchasesHybridCommonUI"'
end
RevenueCat plugins could improve their podspec files to better specify their module dependencies and build requirements. The current implementation required manual Podfile modifications .
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
Hey @wycks thanks for reporting!
I have passed this onto our team internally 🙏
Hi @wycks, thank you for your report!
I've been looking into this and I've created a Flutter app from scratch using v8.7.2 of purchases_flutter and purchases_ui_flutter to see if I could reproduce the issue.
purchases_flutter: 8.7.2
purchases_ui_flutter: 8.7.2
I was able to build and run the basic sample app in my own iPhone (iOS 18.5) and in the simulator (iOS 18.3) without any errors.
Console:
ajpallares@Antonios-MacBook-Pro revenuecat_flutter_app % flutter run
Connected devices:
macOS (desktop) • macos • darwin-arm64 • macOS 15.5 24F74 darwin-arm64
Chrome (web) • chrome • web-javascript • Google Chrome XXX.X.XXXX.XX
Wirelessly connected devices:
iPhone de AJPallares (wireless) (mobile) • XXXXXXXX-XXXXXXXXXXXXXXXX • ios • iOS 18.5 22F76
[1]: macOS (macos)
[2]: Chrome (chrome)
[3]: iPhone de AJPallares (wireless) (XXXXXXXX-XXXXXXXXXXXXXXXX)
Please choose one (or "q" to quit): 3
Launching lib/main.dart on iPhone de AJPallares (wireless) in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 7MJXQBJQU8
Running Xcode build...
└─Compiling, linking and signing... 2,276ms
Xcode build done. 7.7s
You may be prompted to give access to control Xcode. Flutter uses Xcode to run your app. If access is not allowed, you can change this through your Settings > Privacy & Security > Automation.
Installing and launching... 39.5s
Syncing files to device iPhone de AJPallares (wireless)... 14ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on iPhone de AJPallares (wireless) is available at: http://127.0.0.1:57577/F0JdIOVrCYE=/
The Flutter DevTools debugger and profiler on iPhone de AJPallares (wireless) is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:57577/F0JdIOVrCYE=/
To help us reproduce the issue, it would be great to have more information about your setup:
- Could you share the output of flutter doctor -v (to make sure we can reproduce the exact same environment)
- CocoaPods:
- Are there any other local por overrides or custom Podfile setups in the project?
- Could you share the relevant parts of your
ios/Podfile? - Do you have other post-install hooks?
You mentioned two fixes:
- Adding BUILD_LIBRARY_FOR_DISTRIBUTION flag for the RevenueCat modules
- Explicitly setting the Swift module include paths for the purchases plugins
Are the two fixes required or does it work for you with only one of the two?