WatermelonDB: Doesn't work with use_frameworks! / Include of non-modular header
Facing error while setting up in iOS.
Tried, -> Allow Non-Modular includes in Framework Module to Yes
Versions
"react-native": "0.63.4",
"@nozbe/watermelondb": "^0.24.0",
Error
Podfile
source 'https://github.com/cocoapods/specs.git'
platform :ios, '10.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
use_frameworks!
def firebase_pods
pod 'Firebase/Core', '7.6.0'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Analytics'
pod 'Firebase/Crashlytics'
end
def payment_pods
pod 'Stripe', '19.4.1'
pod 'Frames', '3.2.0'
end
def common_pods
pod 'ReachabilitySwift', '4.3.0'
pod 'Alamofire', '4.7.3'
pod 'SDWebImage', '5.0.6'
pod 'SDWebImageWebPCoder'
pod 'SwiftyBeaver', '1.8.2'
end
def notification_extension_pods
pod 'WebEngageAppEx'
end
target 'ceres' do
$static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket',
'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native',
'RNScreens']
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if $static_framework.include?(pod.name)
def pod.build_type;
Pod::BuildType.static_library
end
end
end
end
pod 'SwiftyJSON', '4.2.0'
pod 'GoogleAppIndexing', '2.0.3'
pod 'ReSwift', '2.1.0'
pod 'TTTAttributedLabel', '2.0.0'
firebase_pods
payment_pods
common_pods
pod 'GoogleAnalytics', '3.17.0'
pod 'GoogleMaps'
pod 'KeychainAccess', '3.1.2'
pod 'JTAppleCalendar', '7.1.6'
pod 'LiveChat', '2.0.18'
pod 'WebEngage'
pod 'PhoneNumberKit', '3.2.0'
pod 'FlagKit', '2.2'
pod 'Down', '0.9.3'
pod 'Branch', '0.37.0'
# watermelondb
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true
pod 'simdjson', path: '../node_modules/@nozbe/simdjson'
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
post_install do |installer|
flipper_post_install(installer)
end
end
target 'CeresNotificationServiceExtension' do
common_pods
notification_extension_pods
end
target 'CeresNotificationContentExtension' do
common_pods
notification_extension_pods
end
Error Log
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/WatermelonDB-umbrella.h"
^
/Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/WatermelonDB-umbrella.h:13:9: note: in file included from /Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/WatermelonDB-umbrella.h:13:
#import "Bridging.h"
^
/Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/Bridging.h:2:9: error: include of non-modular header inside framework module 'WatermelonDB.Bridging': '/Users/rahul/workspace/proteus/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/FMDB/src/fmdb/FMDB.h'
#import "FMDB.h"
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/WatermelonDB-umbrella.h"
^
/Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/WatermelonDB-umbrella.h:13:9: note: in file included from /Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/WatermelonDB-umbrella.h:13:
#import "Bridging.h"
^
/Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/Bridging.h:10:9: error: include of non-modular header inside framework module 'WatermelonDB.Bridging': '/Users/rahul/workspace/proteus/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/JSIInstaller.h'
#import "JSIInstaller.h"
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/WatermelonDB-umbrella.h"
^
/Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/WatermelonDB-umbrella.h:13:9: note: in file included from /Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/WatermelonDB-umbrella.h:13:
#import "Bridging.h"
^
/Users/rahul/Library/Developer/Xcode/DerivedData/ceres-fzfftmpyfdjscwchoicxfplvzssd/Build/Products/Debug-iphonesimulator/WatermelonDB/WatermelonDB.framework/Headers/Bridging.h:16:9: error: include of non-modular header inside framework module 'WatermelonDB.Bridging': '/Users/rahul/workspace/proteus/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/DatabaseDeleteHelper.h'
#import "DatabaseDeleteHelper.h"
^
<unknown>:0: error: could not build Objective-C module 'WatermelonDB'
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 44 (13 by maintainers)
This solution worked for me https://github.com/react-native-maps/react-native-maps/issues/3597#issuecomment-1168582636
Update: The preferred, less complicated fix is now @johnf’s below. Note that if you’re using RN 0.71+, you’ll also need to be on at least Watermelon v0.25.1+, in order to also fix #1469 .
= = = original post for nostalgia = = =
There’s a way to get this all working with react-native-firebase and
use_frameworks!. It took me a while, but here’s how to do it (@scob7).To save yourself the trouble of reapplying this patch every time manually, consider using something like patch-package, which will automatically apply this patch for you every time.
"simdjson.h" missing, follow @renatobentorocha’s instructions here: https://github.com/Nozbe/WatermelonDB/issues/1078#issuecomment-1286157927. This copiessimdjson.h/cppinto WatermelonDB’snative/shareddirectory to avoid linking problems.simdjsonfiles, so it’s expected.pod installfrom your project’siosdirectory. This will eventually run WatermelonDB’s podspec, which you modified above, and importantly, also capture the fact that the copied simdjson.cpp needs to be linked.Sorry, I had to temporarily revert the fix, because it causes some new issues in some other configurations (possibly related to Expo and interactions with RN66)…
Forcing WatermelonDB to build as a static library as per https://github.com/Nozbe/WatermelonDB/issues/1285#issuecomment-1381323060 is currently the official/recommended way of dealing with this issue 😃
I do have another idea for a much more reliable, long-term fix, but it will take me more time to develop.
@Dallas62 Hmm, you put GitHub path in package.json? If you used
0.26.0-2, this should just work@johnf’s fix works for me as well, and I verified by backing out my recommended changes, deleting
node_modulesandios/Pods, and rebuilding everything. In my case, I had moved to RN 0.71, so also needed to upgrade to Watermelon v0.25.1 (see #1469).I’ve edited my original comment above to now recommend @johnf’s fix instead. Thank you all!
@radex you should take a look to this one if you find some times, I know there is a lot of work in other issues, but this one could block developers at installation step.
@radex Tested it without the static workaround and it seems to work great!
@rafaellupo wow, thanks so much. I’m still on Managed Expo and I’ve just been reading through this thread starting to fret reverting to bare. I installed your plugin and swapped it out in my app.js and it worked like a charm. Appreciate you making that 👍
@fivecar @KrisLau @Dallas62 @johnf Hi, check out 0.26.0-2 prerelease. Two extra steps need to be done:
pod 'simdjson', path: '../node_modules/@nozbe/simdjson', modular_headers: trueI tested on this demo project (RN 0.71) to confirm that it really works: https://github.com/radex/WatermelonDB_tester
Before I checked on 🍉’s internal project where due to different project structure the simdjson issue didn’t occur
Hi @radex, The
v0.26.0-1partially solve some imports since Bridging.h is not imported. But forsimdjson.hstill got an issue.Copy and paste
simdjson.hintosharedfolder solve the issue, but not the optimal solution.@fivecar @KrisLau @Dallas62 @johnf Hi, check out
0.26.0-1prerelease, I think Watermelon should work there in the use_frameworks! mode. Please note that you should now delete the Bridging.h import from your Bridging header.Please do confirm/deny if this works for you
Yes, of course. I’m all for making 🍉 work with
use_frameworks!, it’s just that I thinkpublic_header_files = everythingis a workaround, not the right fix, since internal headers shouldn’t be needed for the user app. I’m very much interested in PRs fixing this once and for allOk so for anyone who might find themselves in a similar position, the difference for me is that I had an Expo workaround applied too so for the
WatermelonDB.podspecfile I had to change this:Then I had to do step 1 & 2 only from the comment that @fivecar linked before: https://github.com/Nozbe/WatermelonDB/issues/1078#issuecomment-1286157927
Re run
patch-package @nozbe/watermelondbCleaned the pod cache using
pod cache clean --all, deleted the.xcworkspacefolder, closed Xcode,pod update, reopened XCode. I had some other packages that caused issues as well but those were separate from this issue hahaSorry to hear that, @KrisLau . I unfortunately don’t have any insight into what’s causing your specific error. I can only report what worked for me — and it took hours to get it working, and I still don’t fully have confidence it’ll hold together.
As a workaround, I run a ruby script that modifies the .podspec file of this library, changing the public headers from
/native/ios/WatermelonDB/SupportingFiles/Bridging.h/to
native/ios/**/*.hThis ruby script is ran before doing pod install. Afterwards, proper public headers are exposed for a successful build.