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

Error: "xcodebuild redefinition of 'sqlite3_xxx'" when building fresh expo project #65

Open
felixsebastian opened this issue Dec 10, 2024 · 6 comments

Comments

@felixsebastian
Copy link

felixsebastian commented Dec 10, 2024

Problem

Can't build expo app, get a bunch of errors like

❌  (ios/Pods/Headers/Public/react-native-quick-sqlite/sqlite3.h:723:8)

  721 | */
  722 | typedef struct sqlite3_file sqlite3_file;
> 723 | struct sqlite3_file {
      |        ^ redefinition of 'sqlite3_file'
  724 |   const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
  725 | };
  726 |

Also get a warning when I run expo-doctor about this package being 'Untested on New Architecture'

Steps to reproduce

  1. create an expo app with npx create-expo-app
  2. install with npx expo install @journeyapps/react-native-quick-sqlite
  3. Try and build the project with npx expo run:ios
@felixsebastian felixsebastian closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
@histefhere
Copy link

Having this problem as well when using eas build

@mugikhan
Copy link
Contributor

mugikhan commented Dec 17, 2024

Hey @felixsebastian and @histefhere
This issue is caused by multiple versions of SQLite3 being included in your project, which happens because expo-updates also depends on SQLite. The solution is to enable the third-party SQLite pod for expo-updates.
To fix this, update your ios/Podfile.properties.json to include the following configuration:

{
  "expo.updates.useThirdPartySQLitePod": "true"
}

For more details, you can refer to the discussion in Expo issue #30546.

Let us know if this works for you.

@mugikhan mugikhan reopened this Dec 17, 2024
@DeliveranceTechSolutions

I'm confused because I see the original developer list the fix as:

expo.updates.use3rdPartySQLitePod: "true" via 30826

Is the correct syntax what you have provided @mugikhan ?

My issue pertains to an error starting with

` 37 | #include <regex.h>
38 |

39 | static void sqlite_regexp(sqlite3_context* context, int argc, sqlite3_value** values) {
| ^ unknown type name 'sqlite3_context'; did you mean 'exsqlite3_context'?
40 | if ( argc < 2 ) {
41 | sqlite3_result_error(context, "SQL function regexp() called with missing arguments.", -1);
42 | return;`

Platform: ios

Target OS: 15.1

I reinstalled pods, changed configs, took out any db interactions I had, etc. however, I still come to the same problem.

It's actually a problem with react-native-sqlite-storage; however, I'm guessing that's common knowledge?

@mugikhan
Copy link
Contributor

mugikhan commented Dec 18, 2024

@DeliveranceTechSolutions My statement is correct, I have tested it personally and it works. It also aligns with what is currently in the Expo package See here.

Is there any other packages you are using that could be providing sqlite3 maybe expo-sqlite?
You can also try cleaning the expo build (rm -rf .expo) and rerunning the build.

@histefhere
Copy link

histefhere commented Dec 27, 2024

After running prebuild I added {
"expo.updates.useThirdPartySQLitePod": "true"
} to ios/Podfile.properties.json, and then after that I ran npx expo run:ios, which successfully build the app on the simulator. However when I then run an EAS build I still get this error:

Build failed: The "Run fastlane" step failed because of an error in the Xcode build process. We automatically detected following errors in your Xcode build logs:
redefinition of 'sqlite3_file'
redefinition of 'sqlite3_io_methods'
redefinition of 'sqlite3_vfs'
redefinition of 'sqlite3_mem_methods'
conflicting types for 'sqlite3_create_filename'
conflicting types for 'sqlite3_free_filename'
redefinition of 'sqlite3_module'
redefinition of 'sqlite3_index_info'
redefinition of 'sqlite3_index_constraint'
redefinition of 'sqlite3_index_orderby'
redefinition of 'sqlite3_index_constraint_usage'
redefinition of 'sqlite3_vtab'
redefinition of 'sqlite3_vtab_cursor'
redefinition of 'sqlite3_mutex_methods'
redefinition of 'sqlite3_pcache_page'
redefinition of 'sqlite3_pcache_methods2'
redefinition of 'sqlite3_pcache_methods'
redefinition of 'sqlite3_snapshot'
typedef redefinition with different types ('struct (unnamed struct at /Users/expo/workingdir/build/ios/Pods/Headers/Public/react-native-quick-sqlite/sqlite3.h:10109:16)' vs 'struct sqlite3_snapshot')
could not build Objective-C module 'SQLite3'
Refer to "Xcode Logs" below for additional, more detailed logs.

@stevensJourney
Copy link
Collaborator

stevensJourney commented Dec 30, 2024

I tested this locally and on EAS build. Adding my findings here for context.

I ran the following to create a fresh app.

npx create-expo-app
npx expo install @journeyapps/react-native-quick-sqlite
npx expo run:ios

For me this did not give any errors. The app launched after building. Since this issue is related to multiple definitions of SQLite, I manually added expo-updates with npx expo install expo-updates. I could then reproduce the issue.

I followed the steps recommended by Mugi of adding the settings to my /ios/Podfile.properties.json file and the build then succeeded locally. I then triggered an EAS build with eas build -p ios --profile preview which also succeeded.

For some background: It seems like expo-updates will use the system version of SQLite now by default. If the system SQLite3 library is used in conjunction with React Native Quick SQLite then these redefinition of ... errors will be present. Setting expo.updates.use3rdPartySQLitePod: "true" will cause expo-updates to instead install the sqlite3 pod dependency. This still technically results in multiple versions of SQLite being present in the project, which is not ideal, but with the default project linking settings this seems to be less error prone than using the system version. If using frameworks with static linking other issues may still arise.

@histefhere I'd start by verifying the ios folder and Podfile.properties.json files are not added to any gitignore of easignore entries. Otherwise could you share a minimal reproducible example repo?

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