Skip to content

Swift module dependency problem error on ios builds #1324

@wycks

Description

@wycks

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).

  1. "Module 'RevenueCat' not found" in PurchasesFlutterPlugin.h
  2. "No such module 'PurchasesHybridCommonUI'" in PurchasesUiFlutterPlugin.swift

Fix:

  1. 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
  1. 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 .

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions