morrowdigital / watermelondb-expo-plugin

119 stars 30 forks source link

Won't build with a fresh Expo project (SDK 48) #13

Closed davidkhuu closed 1 year ago

davidkhuu commented 1 year ago

Forgive me if I'm missing something but this plugin doesn't seem to work for me?

I started a new Expo project to test if it was issues with my current project but I still can't get it to work.

Steps I followed:

  1. Initiate a new Expo project (SDK 48): expo-cli init expo-app

  2. Following the setup instructions: I added WatermelonDB and this plugin: yarn add @nozbe/watermelondb @morrowdigitial/watermelondb-expo-plugin I added expo-build-properties: npx expo install expo-build-properties

  3. Added the plugin to the plugins array in app.json:

    {
    "expo": {
    "name": "expo-app",
    "slug": "expo-app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.anonymous.expo-app"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "com.anonymous.expoapp"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      "expo-build-properties"
    ]
    },
    "plugins": [
    "@morrowdigital/watermelondb-expo-plugin",
    [
      "expo-build-properties",
      {
        "android": {
          "kotlinVersion": "1.6.10"
        }
      }
    ]
    ]
    }
  4. I run expo prebuild/expo run:ios and I get the same error:

    
    npx expo run:ios
    ✔ Created native project | gitignore skipped
    ✔ Updated package.json and added index.js entry point for iOS and Android
    › Installing using yarn
    > yarn install
    ✔ Config synced
    ⚠️  Something went wrong running `pod install` in the `ios` directory.
    Command `pod install` failed.
    └─ Cause: The following Swift pods cannot yet be integrated as static libraries:

The Swift pod WatermelonDB depends upon React-jsi, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set use_modular_headers! globally in your Podfile, or specify :modular_headers => true for particular dependencies.



I also deleted the **ios** and **android** folder and also tried running `prebuild` with the `--clean` option.

Without the WatermelonDB package, it builds successfully. I'm just curious if I'm missing a step to get this plugin working with an Expo project. Maybe whatever discussion comes from this could be added to the README?
brunokiafuka commented 1 year ago

Hi @davidkhuu can you modify your app.json to be like shown below and re-run step 4.

{
  "expo": {
    "name": "expo-app",
    "slug": "expo-app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.anonymous.expo-app"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "com.anonymous.expoapp"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      "@morrowdigital/watermelondb-expo-plugin",
      [
          "expo-build-properties",
          {
            "android": {
              "kotlinVersion": "1.6.10"
           }
        }
     ]
    ]
  },
}
davidkhuu commented 1 year ago

Hi @brunokiafuka, that looks like it resolves that! I feel dumb. I could've sworn I tried it adding the plugins property inside and out of the expo property in the app.json file and neither was working.

I appreciate the help!

brunokiafuka commented 1 year ago

It happens @davidkhuu, glad to hear that the issue is solved.