drift
drift copied to clipboard
Could not build Objective-C module 'SQLite3'
Describe the bug When trying to build for iOS `flutter build iOS
Redefinition of 'sqlite3_file
/Users/x/StudioProjects/app_name/ios/Pods/sqlite3/sqlite-src-3460100/sqlite3.h:731:8 Redefinition of 'sqlite3_file'
/Users/x/StudioProjects/app_name/ios/Pods/sqlite3/sqlite-src-3460100/sqlite3.h:837:8 Redefinition of 'sqlite3_io_methods
```
Libs
```
drift: ^2.20.0
sqlite3_flutter_libs: ^0.5.0
drift_flutter: ^0.2.0
dev_dependencies:
build_runner: ^2.4.12
drift_dev: ^2.20.1
```
Anyone ran into a solution for this ? I tried a few things such as : Pod file
Getting rid of sqlite3 lib(flutter)
` pod 'SQLite.swift/standalone'
#pod 'sqlite3', '~> 3.46.0'
#pod 'sqlite3', '~> 3.35'
#pod 'sqlite3', :modular_headers => true`
sqlite3_flutter_libs should be removed. drift_flutter includes it automatically. I'm assuming there is some clashing going on.
I don't think that's it, drift_flutter simply depends on sqlite3_flutter_libs.
My best guess is that there's another dependency also linking sqlite3, does adding this snippet fix anything?
My best guess is that there's another dependency also linking sqlite3, does adding this snippet fix anything?
I am having the same issue that @psikosen and the snippet suggested but @simolus3 doesn't seem to be working, at least for this case. I am trying to figure out how to solve it. If I get something useful, I will let you know.
Thanks for pointing to the snippet!
Update
After fighting a lot with that issue, I have to be honest: I really don't know how I "fixed" it. In the process of disabling some dependencies and trying to figure out why I was getting the redefinition error, I clean a lot of times the build directory and the pods (Pods and Podfile.lock).
When I was completely exhausted I returned to a previous commit to undo all my work, then clean the build directory but using Xcode (Product => Clean Build Folder) instead of flutter clean, then remove the Pods directory and the Podfile.lock, recover all the dependencies I had previously defined in pubspec.yml and finally run it again with VSCode and, suddenly, surprisingly, I didn't get the error.
I am not really happy with this, because I don't know exactly what happens beyond the possibility that the "Clean Build Folder" of Xcode cleans more than the flutter clean, but I don't know exactly what.
If I get more information, I will let you know. Just for reference, I leave here the dependencies I am using in my pubspec.yml file.
dependencies:
device_info_plus: ^9.1.1
drift: ^2.15.0
flutter:
sdk: flutter
flutter_blue_plus: ^1.31.10
flutter_native_splash: ^2.3.5
flutter_riverpod: ^2.6.1
freezed: ^2.4.6
freezed_annotation: ^2.4.1
go_router: ^13.0.1
icons_plus: ^5.0.0
json_annotation: ^4.8.1
logger: ^2.0.2+1
package_info_plus: ^4.2.0
path: ^1.8.3
path_provider: ^2.1.2
permission_handler: ^11.2.0
riverpod_annotation: ^2.6.1
shared_preferences: ^2.2.2
sqlite3: ^2.4.6
sqlite3_flutter_libs: ^0.5.19
flutter_spinkit: ^5.2.0
dio: ^5.4.3+1
embrace: ^3.0.1
embrace_dio: ^3.0.0
Update
As another note, the only difference I see in my Podfile.lock from the current state to the previous (which was failing with the redefinition issue) is EmbraceIO and embrace_ios related pods updated from 6.4.2 to 6.5.0 and the sqlite3 pods added by sqlite3_flutter_libs. However, before the issues was "fixed" and after I have checked embrace dependency and it doesn't seem to include sqlite3 nor link it, and its changelog and commits history only indicates it updates the iOS SDK.
Updated
I confirm that my codebase is now running on both, iOS and Android, using the sqlite3_flutter_libs (v0.5.26).
@simolus3 Any update on this issue, I am facing same issue.
@wdcs-vivekmakvana Does the Podfile snippet I've linked above also not work for you?
I have tried suggested solution this but It won't work for me.
Logs :
` Swift Compiler Error (Xcode): Redefinition of 'sqlite3_file' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:738:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_io_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:845:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vfs' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:1481:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mem_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:1781:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_module' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7356:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_info' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7502:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7505:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_orderby' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7512:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint_usage' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7517:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7682:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab_cursor' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7706:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mutex_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:8203:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_page' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:8976:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods2' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:9141:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:9164:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_snapshot' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:10569:15
Swift Compiler Error (Xcode): Typedef redefinition with different types ('struct (unnamed struct at .../build/ios/Debug-dev-iphonesimulator/sqlite3/sqlite3.framework/Headers/sqlite3.h:10570:16)' vs 'struct sqlite3_snapshot') .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:10571:2
Swift Compiler Error (Xcode): Could not build Objective-C module 'SQLite3' `
Issue Description
I'm encountering SQLite redefinition errors while trying to build an iOS app using GitHub Actions. I'm working on a Windows OS and using GitHub Actions to build iOS outputs.
Environment
- OS: Windows 11 (using GitHub Actions with macos-latest runner for iOS build)
- Flutter version: 3.29.0
- drift: ^2.25.1
- drift_dev: ^2.15.2
- sqlite3_flutter_libs: ^0.5.30
Error
When trying to build, I get multiple SQLite redefinition errors:
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_file'
/Users/runner/work/ios-lemoni-app/ios-lemoni-app/ios/Pods/sqlite3/sqlite-src-3490000/sqlite3.h:738:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_io_methods'
/Users/runner/work/ios-lemoni-app/ios-lemoni-app/ios/Pods/sqlite3/sqlite-src-3490000/sqlite3.h:845:7
[... multiple similar redefinition errors ...]
Swift Compiler Error (Xcode): Typedef redefinition with different types ('struct (unnamed struct at /Users/runner/work/ios-lemoni-app/ios-lemoni-app/build/ios/Release-iphoneos/sqlite3/sqlite3.framework/Headers/sqlite3.h:10664:16)' vs 'struct sqlite3_snapshot')
/Users/runner/work/ios-lemoni-app/ios-lemoni-app/ios/Pods/sqlite3/sqlite-src-3490000/sqlite3.h:10665:2
Swift Compiler Error (Xcode): Could not build Objective-C module 'SQLite3'
Encountered error while building for device.
Error: Process completed with exit code 1.
Steps I've Tried
- Updated Podfile as suggested in the issue:
platform :ios, '13.0'
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# iOS deployment target
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
new_xcconfig = xcconfig.sub(' -l"sqlite3"', '')
File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
end
end
end
- Updated GitHub Actions workflow:
- name: Clean iOS build and pods
run: |
cd ios
rm -rf Pods Podfile.lock build
pod cache clean --all
pod repo update
pod install --repo-update
- Updated package versions in pubspec.yaml to match the suggested versions.
Additional Information
During pod installation, I get these logs which might be relevant:
Installing sqflite_darwin (0.0.4)
Installing sqlite3 (3.49.0)
Installing sqlite3_flutter_libs (0.0.1)
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig` in your build configuration (`Flutter/Debug.xcconfig`).
Generating Pods project
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig` in your build configuration (`Flutter/Release.xcconfig`).
[multiple build setting override warnings...]
The issue persists despite following the suggested solutions. Any additional guidance would be greatly appreciated.
GitHub Actions Workflow
Here's my complete workflow configuration for reference:
name: build
on:
workflow_dispatch:
jobs:
build-ios:
name: ios build
runs-on: macos-latest
env:
VERSION: ""
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
architecture: x64
- name: Update CocoaPods
run: |
gem install cocoapods
pod --version
- name: Flutter pub get with config override
run: |
flutter clean
flutter pub get
- name: Clean iOS build and pods
run: |
cd ios
rm -rf Pods Podfile.lock build
pod cache clean --all
pod repo update
pod install --repo-update
- name: Flutter build iOS
run: flutter build ios -t lib/main.dart --release --no-codesign
- name: Create Payload directory
run: mkdir -p build/ios/iphoneos/Payload
- name: Move app to Payload
run: mv build/ios/iphoneos/Runner.app/ build/ios/iphoneos/Payload/
- name: Zip output to IPA
run: cd build/ios/iphoneos && zip -qq -r -9 FlutterIpaExport.ipa Payload
- name: Extract version from pubspec
run: |
echo "VERSION=$(cat pubspec.yaml | grep version: | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/ios/iphoneos/FlutterIpaExport.ipa
tag: ${{ env.VERSION }}
overwrite: true
body: "version ${{ env.VERSION }} ios"
I have tried suggested solution this but It won't work for me.
Logs :
` Swift Compiler Error (Xcode): Redefinition of 'sqlite3_file' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:738:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_io_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:845:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vfs' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:1481:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mem_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:1781:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_module' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7356:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_info' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7502:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7505:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_orderby' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7512:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint_usage' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7517:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7682:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab_cursor' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:7706:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mutex_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:8203:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_page' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:8976:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods2' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:9141:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:9164:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_snapshot' .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:10569:15
Swift Compiler Error (Xcode): Typedef redefinition with different types ('struct (unnamed struct at .../build/ios/Debug-dev-iphonesimulator/sqlite3/sqlite3.framework/Headers/sqlite3.h:10570:16)' vs 'struct sqlite3_snapshot') .../ios/Pods/sqlite3/sqlite-src-3480000/sqlite3.h:10571:2
Swift Compiler Error (Xcode): Could not build Objective-C module 'SQLite3' `
were you able to fix this?
this is very frustrating, we can't build our project anymore on iOS because of this issue.
Surprisingly, using Xcode 26 works, but as you may be aware, we can't ship our app using this Xcode version...
fixed it by forking the repo and removing all darwin/iOS code
in your pubspec.yaml replace drift_flutter or sqlite3_flutter_libs with this:
sqlite3_flutter_libs:
git:
url: https://github.com/frapeti/sqlite3.dart
ref: main
path: sqlite3_flutter_libs