tekartik / sqflite

SQLite flutter plugin
BSD 2-Clause "Simplified" License
2.87k stars 521 forks source link

Broken for iOS on Flutter 3.10 and Dart 3.0 #1008

Open nrubin29 opened 1 year ago

nrubin29 commented 1 year ago

Steps to reproduce:

  1. Create a new Flutter app.
  2. Add sqflite: ^2.2.8+2 as the only dependency.
  3. Attempt to build the app on iOS.
  4. Build fails.

In Xcode, the error is:

X File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a
! The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 11.0 to 16.4.99.
X Linker command failed with exit code 1 (use -v to see invocation)
mihaieremia commented 1 year ago

Have you tried setting your OS from 8.0 to minimum 11.0 ? On the other hand I have other errors since the upgrade to 3.10


Error (Xcode): double-quoted include "SqfliteCursor.h" in framework header, expected angle-bracketed instead
/Users/truststaking/.pub-cache/hosted/pub.dev/sqflite-2.2.8+2/ios/Classes/SqfliteDatabase.h:9:8

Error (Xcode): double-quoted include "SqfliteOperation.h" in framework header, expected angle-bracketed instead
/Users/truststaking/.pub-cache/hosted/pub.dev/sqflite-2.2.8+2/ios/Classes/SqfliteDatabase.h:10:8

Error (Xcode): double-quoted include "SqfliteImport.h" in framework header, expected angle-bracketed instead
/Users/truststaking/.pub-cache/hosted/pub.dev/sqflite-2.2.8+2/ios/Classes/SqfliteOperation.h:9:8

Error (Xcode): double-quoted include "SqfliteCursor.h" in framework header, expected angle-bracketed instead
/Users/truststaking/Documents/GitHub/xoxno/ios/Pods/Target%20Support%20Files/sqflite/sqflite-umbrella.h:12:8

Error (Xcode): double-quoted include "SqfliteDatabase.h" in framework header, expected angle-bracketed instead
/Users/truststaking/Documents/GitHub/xoxno/ios/Pods/Target%20Support%20Files/sqflite/sqflite-umbrella.h:13:8

Error (Xcode): 'Flutter/Flutter.h' file not found
/Users/truststaking/.pub-cache/hosted/pub.dev/sqflite-2.2.8+2/ios/Classes/SqfliteImport.h:10:8

Error (Xcode): (fatal) could not build module 'sqflite'
/Users/truststaking/Library/Developer/Xcode/DerivedData/Runner-fwcvjgqztrfhgafvbzxxkdyhsbrs/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/sq
flite.build/VerifyModule/sqflite_objective-c++_arm64-apple-ios14.0_gnu++14/Test/Test.framework/Headers/Test.h:0:8

Error (Xcode): (fatal) could not build module 'sqflite'
/Users/truststaking/Library/Developer/Xcode/DerivedData/Runner-fwcvjgqztrfhgafvbzxxkdyhsbrs/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/sq
flite.build/VerifyModule/sqflite_objective-c_arm64-apple-ios14.0_gnu11/Test/Test.framework/Headers/Test.h:0:8```
Carapacik commented 1 year ago

@alextekartik I think need update this from 9 to 11. https://github.com/tekartik/sqflite/blob/45b19df84e5a93ad7aaa66b8b030b89a81e2e050/sqflite/ios/sqflite.podspec#L20

alextekartik commented 1 year ago

Thanks @Carapacik I have tried this but that does not look sufficient. I have however publish an updated version (sqflite 2.2.8+4)

I'm not sure what I can do yet so any advice is welcome. What works for me:

(added in the doc here: https://github.com/tekartik/sqflite/blob/master/sqflite/doc/troubleshooting.md#xcode-14-support)

See: https://developer.apple.com/forums/thread/728021

Xcode 14 only supports building for a deployment target of iOS 11.

Here as well you need to enforce the deployment target until I find a better way as the FMDB dependency is no longer actively maintained.

In your application Podfile inside the post_install section where have this in the app template:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

you need to have (11 is used here, but you might want to specify a higher platform):

post_install do |installer|

  installer.generated_projects.each do |project|
    project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
    end
  end

  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
calebergh commented 9 months ago

With XCode 15.1, when I attempt to build, I get hard errors like @mihaieremia reports: https://github.com/tekartik/sqflite/issues/1008#issuecomment-1543796806

I'm unable to build successfully.