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

can not build #11

Closed
iwater opened this issue May 15, 2023 · 3 comments
Closed

can not build #11

iwater opened this issue May 15, 2023 · 3 comments
Labels
question Further information is requested

Comments

@iwater
Copy link

iwater commented May 15, 2023

截屏2023-05-15 17 23 26
@cawfree
Copy link
Owner

cawfree commented May 16, 2023

Hi, I just tried to install the latest version of react-native-webassembly as follows:

npx create-react-native-app -t with-typescript xxx
cd xxx
yarn add react-native-webassembly axios
npx expo prebuild
cd ios && pod install
cd ..
yarn ios

Then I loaded up some simple example inside App.tsx:

import * as React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as WebAssembly from 'react-native-webassembly';
import axios from 'axios';

export default function App() {

  React.useEffect(() => void (async () => {

    try {
      const {data} = await axios({
        url: 'https://github.com/torch2424/wasm-by-example/raw/master/examples/hello-world/demo/assemblyscript/hello-world.wasm',
        method: 'get',
        responseType: 'arraybuffer',
      });
      const x = await WebAssembly.instantiate<{add: (a: number, b: number) => number}>(data);
      console.warn(x.instance.exports.add(1000, 2000));
    } catch (e) {
      console.error(e);
    }

  })(), []);

  return (
    <View style={styles.container}>
      <Text>Open up App.tsx to start working on your app!</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

This works as expected.

This may suggest a configuration issue with your project; the MutableMemoryHeaderBuffer class in particular expects to be derived from React Native's MutableBuffer.

It could be a couple of things:

  • A React Native version issue (the above example uses 0.71.1).
  • A Hermes issue (is Hermes enabled in your Podfile?).

It could also be some other configuration issues, but these would be my bet.

@cawfree cawfree added the question Further information is requested label May 16, 2023
@iwater
Copy link
Author

iwater commented May 16, 2023

I use 0.69.10 with hermes enable, when installed react-native-webassembly@0.3.2, build without error, so is react-native-webassembly@0.3.3 only support 0.71.1+ ?

@cawfree
Copy link
Owner

cawfree commented Nov 3, 2023

I use 0.69.10 with hermes enable, when installed react-native-webassembly@0.3.2, build without error, so is react-native-webassembly@0.3.3 only support 0.71.1+ ?

Hey @iwater, sorry for the delay getting back to you. I believe this was one of those move-fast-break-things situations when we had basically zero users.

Hope you were able to make the upgrade and it wasn't too painful (but hey, it's React Native).

@cawfree cawfree closed this as completed Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants