morrowdigital / watermelondb-expo-plugin

119 stars 30 forks source link

ExpoModulesProvider.swift fails to find 'ExpoModulesCore' module for target 'x86_64-apple-ios-simulator' on macOS M1 #20

Closed adblanc closed 7 months ago

adblanc commented 1 year ago

Hi,

When building the example app on my mac m1, I get the following error :


   6 |  */
   7 | 
>  8 | import ExpoModulesCore
     |        ^ could not find module 'ExpoModulesCore' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator

I need to manually remove "arm64" in the project excluded architectures done in setExcludedArchitectures by the plugin.

Steps to reproduce :

thejoaov commented 1 year ago

Hi,

When building the example app on my mac m1, I get the following error :


   6 |  */
   7 | 
>  8 | import ExpoModulesCore
     |        ^ could not find module 'ExpoModulesCore' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator

I need to manually remove "arm64" in the project excluded architectures done in setExcludedArchitectures by the plugin.

Steps to reproduce :

  • yarn ios in example app

Hi @adblanc, you can use this patch i made with patch-package, and rebuild your app with expo prebuild

diff --git a/node_modules/@morrowdigital/watermelondb-expo-plugin/build/withWatermelon.js b/node_modules/@morrowdigital/watermelondb-expo-plugin/build/withWatermelon.js
index 4b6fbdc..5187275 100644
--- a/node_modules/@morrowdigital/watermelondb-expo-plugin/build/withWatermelon.js
+++ b/node_modules/@morrowdigital/watermelondb-expo-plugin/build/withWatermelon.js
@@ -98,7 +98,14 @@ const withCocoaPods = (config) => {
   pod 'WatermelonDB', :path => '../node_modules/@nozbe/watermelondb'
   pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true
   pod 'simdjson', path: '../node_modules/@nozbe/simdjson', :modular_headers => true\n\n  `;
-                await fs.writeFile(filePath, slicedContent.join(patchKey));
+                const newContent = slicedContent.join(patchKey);
+                await fs.writeFile(filePath, newContent);
+                const postPatchKey = "target_installation_result.resource_bundle_targets.each do |resource_bundle_target|";
+                const postPatchSlicedContent = newContent.split(postPatchKey);
+                postPatchSlicedContent[0] += `target_installation_result.native_target.build_configurations.each do |config|
+          config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
+      end\n      `;
+                await fs.writeFile(filePath, postPatchSlicedContent.join(postPatchKey));
             }
             else {
                 throw new Error("Please make sure you have watermelondb installed");
gokul1099 commented 9 months ago

removing amr64 in Excluded architecture(EXCLUDED_ARCHS) fixed the issue for me

killerchip commented 7 months ago

Closing as it was dealt with in version 2.3.1 https://github.com/morrowdigital/watermelondb-expo-plugin/pull/33