Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Error In iOS #192

Open
yairsts opened this issue Nov 14, 2023 · 11 comments
Open

Compiler Error In iOS #192

yairsts opened this issue Nov 14, 2023 · 11 comments

Comments

@yairsts
Copy link

yairsts commented Nov 14, 2023

I use sqlcipher_flutter_libs: 0.6.0, in Android everthing works properly, but in iOS I got some errors.


Launching lib/main.dart on iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 24BHMJRJR7
Xcode build done.                                           33.5s
Failed to build iOS app
Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_file'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:727:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_io_methods'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:833:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vfs'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:1463:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mem_methods'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:1763:7
Swift Compiler Error (Xcode): Conflicting types for 'sqlite3_create_filename'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:3915:28

Swift Compiler Error (Xcode): Conflicting types for 'sqlite3_free_filename'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:3922:16

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_module'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7192:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_info'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7332:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7335:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_orderby'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7342:9

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint_usage'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7347:9
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7510:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab_cursor'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:7534:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mutex_methods'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:8029:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_page'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:8798:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods2'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:8963:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:8986:7
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_snapshot'
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:10360:15

Swift Compiler Error (Xcode): Typedef redefinition with different types ('struct (unnamed struct at /Documents/git/enc/build/ios/Debug-Runner-iphoneos/SQLCipher/SQLCipher.framework/Headers/sqlite3.h:10361:16)' vs 'struct sqlite3_snapshot')
/Documents/git/enc/ios/Pods/SQLCipher/sqlite3.h:10362:2
Swift Compiler Error (Xcode): Could not build Objective-C module 'SQLite3'


Help please 🙏🏼

@simolus3
Copy link
Owner

It sounds like you might be linking both sqlite3 and sqlcipher, for instance because another Flutter plugin or native dependency needs sqlite. Did you try adding this to your podspec?

@yairsts
Copy link
Author

yairsts commented Nov 15, 2023

Yes, this is my Podfile:

platform :ios, '11.0'

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      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

this is my OTHER_LDFLAGS:

OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-l\"c++\"",
"-l\"z\"",
"-framework",
"\"AVFoundation\"",
"-framework",
"\"Accelerate\"",
"-framework",
"\"CoreData\"",
"-framework",
"\"CoreGraphics\"",
"-framework",
"\"CoreImage\"",
"-framework",
"\"CoreLocation\"",
"-framework",
"\"CoreTelephony\"",
"-framework",
"\"CoreText\"",
"-framework",
"\"FBLPromises\"",
"-framework",
"\"FirebaseABTesting\"",
"-framework",
"\"FirebaseAnalytics\"",
"-framework",
"\"FirebaseCore\"",
"-framework",
"\"FirebaseCoreExtension\"",
"-framework",
"\"FirebaseCoreInternal\"",
"-framework",
"\"FirebaseCrashlytics\"",
"-framework",
"\"FirebaseDynamicLinks\"",
"-framework",
"\"FirebaseInstallations\"",
"-framework",
"\"FirebaseMessaging\"",
"-framework",
"\"FirebaseRemoteConfig\"",
"-framework",
"\"FirebaseSessions\"",
"-framework",
"\"FirebaseSharedSwift\"",
"-framework",
"\"Foundation\"",
"-framework",
"\"GLKit\"",
"-framework",
"\"GoogleAppMeasurement\"",
"-framework",
"\"GoogleAppMeasurementIdentitySupport\"",
"-framework",
"\"GoogleDataTransport\"",
"-framework",
"\"GoogleMaps\"",
"-framework",
"\"GoogleMapsBase\"",
"-framework",
"\"GoogleMapsCore\"",
"-framework",
"\"GoogleUtilities\"",
"-framework",
"\"IOSSecuritySuite\"",
"-framework",
"\"ImageIO\"",
"-framework",
"\"IosAwnCore\"",
"-framework",
"\"MTBBarcodeScanner\"",
"-framework",
"\"Metal\"",
"-framework",
"\"OpenGLES\"",
"-framework",
"\"Promises\"",
"-framework",
"\"QuartzCore\"",
"-framework",
"\"Security\"",
"-framework",
"\"StoreKit\"",
"-framework",
"\"SystemConfiguration\"",
"-framework",
"\"UIKit\"",
"-framework",
"\"awesome_notifications\"",
"-framework",
"\"awesome_notifications_core\"",
"-framework",
"\"device_info\"",
"-framework",
"\"device_info_plus\"",
"-framework",
"\"firebase_analytics\"",
"-framework",
"\"firebase_core\"",
"-framework",
"\"firebase_crashlytics\"",
"-framework",
"\"firebase_dynamic_links\"",
"-framework",
"\"firebase_messaging\"",
"-framework",
"\"firebase_remote_config\"",
"-framework",
"\"flutter_jailbreak_detection\"",
"-framework",
"\"flutter_native_splash\"",
"-framework",
"\"flutter_secure_storage\"",
"-framework",
"\"google_maps_flutter_ios\"",
"-framework",
"\"location\"",
"-framework",
"\"map_launcher\"",
"-framework",
"\"nanopb\"",
"-framework",
"\"open_filex\"",
"-framework",
"\"package_info_plus\"",
"-framework",
"\"path_provider_foundation\"",
"-framework",
"\"permission_handler_apple\"",
"-framework",
"\"qr_code_scanner\"",
"-framework",
"\"share_plus\"",
"-framework",
"\"shared_preferences_foundation\"",
"-framework",
"\"sms_autofill\"",
"-framework",
"\"sqlite3\"",
"-framework",
"\"sqlite3_flutter_libs\"",
"-framework",
"\"url_launcher_ios\"",
"-framework",
"\"vibration\"",
"-framework",
"\"webview_flutter_wkwebview\"",
"-weak_framework",
"\"LinkPresentation\"",
"-weak_framework",
"\"UserNotifications\"",
"-weak_framework",
"\"WebKit\"",
"-framework",
SQLCipher,
);

Still i get this error.

@simolus3
Copy link
Owner

Do you have a dependency on both sqlite3_flutter_libs and sqlcipher_flutter_libs? -framework sqlite3 and -framework sqlite3_flutter_libs should not appear in that list if you want to use SQLCipher.

@yairsts
Copy link
Author

yairsts commented Nov 15, 2023

No, I removed sqlite3_flutter_libs. -framework sqlite3_flutter_libs left, I remove it now and unfortunately, I still get the error
Of course, I delete all Pods folder and podfile.lock and run Pod install

@typexy
Copy link

typexy commented Nov 15, 2023

having the same issue here. thought it was an issue due to flutter version upgrade. but downgraded it again, still the same issue.

@typexy
Copy link

typexy commented Nov 15, 2023

but for me I have the following dependencies:

  • drift: 2.13.1
  • sqlite3_flutter_libs: 0.5.17, and tried it also with 0.5.18

@typexy
Copy link

typexy commented Nov 15, 2023


Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): Redefinition of 'sqlite3_file'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:728:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_io_methods'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:834:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vfs'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:1464:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mem_methods'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:1764:7

Swift Compiler Error (Xcode): Conflicting types for 'sqlite3_create_filename'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:3919:28

Swift Compiler Error (Xcode): Conflicting types for 'sqlite3_free_filename'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:3926:16

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_module'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7183:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_info'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7323:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7326:9

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_orderby'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7333:9

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_index_constraint_usage'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7338:9

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7501:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_vtab_cursor'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:7525:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_mutex_methods'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:8020:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_page'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:8790:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods2'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:8955:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_pcache_methods'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:8978:7

Swift Compiler Error (Xcode): Redefinition of 'sqlite3_snapshot'
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:10352:15

Swift Compiler Error (Xcode): Typedef redefinition with different types ('struct (unnamed struct at /Users/robin/IdeaProjects/app/app/build/ios/Debug-iphoneos/sqlite3/sqlite3.framework/Headers/sqlite3.h:10353:16)' vs 'struct sqlite3_snapshot')
/Users/robin/IdeaProjects/app/app/ios/Pods/sqlite3/sqlite-src-3430100/sqlite3.h:10354:2

Swift Compiler Error (Xcode): Could not build Objective-C module 'SQLite3'

@typexy
Copy link

typexy commented Nov 15, 2023

It sounds like you might be linking both sqlite3 and sqlcipher, for instance because another Flutter plugin or native dependency needs sqlite. Did you try adding this to your podspec?

It also doesn't work with this fix suggestion.

@easazade
Copy link

I have the same problem. there should be a fix for this

@easazade
Copy link

easazade commented Mar 5, 2024

writing this comment if you have the same problem as me and are desperate for a fix, maybe this works for you.
If you are using drift database package and using sqlite3_flutter_libs package only to making sqlite3 database to work on Android. maybe you can fork the repo and delete the iOS side of the plugin. that way iOS compiles successfully and Android app works as well.
here is my fork if you need it.
https://github.com/easazade/sqlite3.dart/tree/remove-ios

@psikosen
Copy link

psikosen commented Sep 6, 2024

Any fix for this yet ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants