Question

Module 'RevenueCat' not found objective-c @import RevenueCat;

  • 29 March 2022
  • 7 replies
  • 358 views

Badge +6

I am integrating RevenueCat into a ‘mature’ UIKit Objective-C iOS app. 

@import RevenueCat;  gives me build error Module 'RevenueCat' not found

I used swift package manager to bring in 4.1. I added RevenueCat package to all the targets that should need it. No end of cleans & restarts gets it working. 

I was using an old .pch file which can cause weird #include dependency problems. After hacking to remove the .pch hey presto it worked. So I went ahead and properly removed the .pch files from the whole app, touching 100+ files. 

Then I put back @import RevenueCat; and I get the same  build error Module 'RevenueCat' not found. 

I have another target for Mac Catalyst that shares nearly all the same code. That builds fine!

Can anyone help?


7 replies

Badge +6

further details... 

I have 3 embedded App Extensions in the main app target. When I remove them, it builds and runs correctly. Also, each of the app extension targets I can build alone. 

Badge +6

I figured it out, somewhat. RevenueCat would not work with the app extensions. The place I’m doing the integration with RC I do need in the extensions, but RevenueCat itself I probably don’t need. So some conditional compilation solves it for me (I hope). 

 

#if defined(IS_MAIN_APP) 

#define IS_REVENUE_CAT

#endif

 

#ifdef IS_REVENUE_CAT

@import RevenueCat;

#endif

 

#ifdef IS_REVENUE_CAT

    RCPurchases.logLevel = RCLogLevelDebug;

    [RCPurchases configureWithAPIKey...

#endif

 

Userlevel 3
Badge +5

Hey @FocusedApps!

Thanks for following up with what was (mostly) working for you! It is totally expected that v4.1 should work with an Objective-C codebase and across app extensions. I’m going to spin up a sample Objective-C app with some extensions today to see if I can get the same behavior. 

I’ll keep you updated with any of my findings 💪 

Thanks!

Userlevel 3
Badge +5

Hey @FocusedApps!

I just created a new iOS Objective-C app with a three extensions and everything seemed to build fine. I installed RevenueCat through SPM and imported with `@import RevenueCat;` 

It seems like there must be some build settings that can probably mess this up 🤔 I don’t personally Objective-C much anymore but I can ask around to see if anybody else would be able to help diagnose this issue further! 

Badge +6

Maybe the problem I was having is this:

https://docs.revenuecat.com/docs/ios-native-3x-to-4x-migration

 

ObjC + SPM

If you expose any Purchases objects from one target to another (see example project for what this could look like), that second target will not build due to a missing autogenerated header. Currently there is a known bug in SPM whereby Xcode either doesn't pass the RevenueCat ObjC generated interface to SPM, or SPM just doesn't integrate it. You can follow along: SR-15154

 

Workaround:

You must manually add the autogenerated file we committed to the repository RevenueCat-Swift.h to your project, and #import RevenueCat-Swift.h in your bridging header. You can see how we do this in our SPMIntegration project.

 

 

Userlevel 3
Badge +5

@FocusedApps Ahhh, that does sound like it! I don’t think I exposed any from one target to another in my sample project this morning 🤦‍♂️ I definitely should have tested that but… it seems like our team already did 🤷‍♂️

Are you all good to continue with your workaround and/or the workaround in the migration? Want to make sure you are good to keep integrating RevenueCat 😊 

Badge +6

Good for now. Thanks. 

Reply