React-Native应用中的ARM64建筑符号未定义

发布于 2025-02-13 00:19:57 字数 1378 浏览 0 评论 0原文

我正在尝试在反应本机中使用React微视角。为此,我试图使用React-Native-Native static-server在本地服务器中为React App构建服务,并在Web视图中使用它。但是,当我为iOS运行时,我将面对这个问题;

Undefined symbols for architecture arm64:
  "_RCTRegisterModule", referenced from:
      +[FPStaticServer load] in FPStaticServer.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

将构建文件复制到iOS应用程序的根,这是我的反应代码。

import React, {FC, useEffect, useState} from 'react';
import RNFS from 'react-native-fs';
import StaticServer from 'react-native-static-server';
import WebView, {WebViewProps} from 'react-native-webview';

export type TpWebPortalProps = {} & WebViewProps;

const TpWebPortal: FC<TpWebPortalProps> = () => {
  const [source, setSource] = useState('');

  useEffect(() => {
    const path = RNFS.MainBundlePath + '/portals/count';

    const server = new StaticServer(8080, path);
    server.start().then(url => {
      setSource(url);
      console.log('Serving at URL', url);
    });

    return () => {
      server.stop();
    };
  }, []);

  return (
    <WebView
      style={{flex: 1}}
      source={{
        uri: source
      }}
      originWhitelist={['*']}
      javaScriptEnabled
      domStorageEnabled
      allowFileAccess
    />
  );
};

export default TpWebPortal;

I am trying to use a react microfrontend in react-native. To do this, i am trying to serve react app build in local server with react-native-static-server and use it inside web-view. But, i am facing with this problem when i run it for ios;

Undefined symbols for architecture arm64:
  "_RCTRegisterModule", referenced from:
      +[FPStaticServer load] in FPStaticServer.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The build file is copied to root of ios app and here is my react-native code;

import React, {FC, useEffect, useState} from 'react';
import RNFS from 'react-native-fs';
import StaticServer from 'react-native-static-server';
import WebView, {WebViewProps} from 'react-native-webview';

export type TpWebPortalProps = {} & WebViewProps;

const TpWebPortal: FC<TpWebPortalProps> = () => {
  const [source, setSource] = useState('');

  useEffect(() => {
    const path = RNFS.MainBundlePath + '/portals/count';

    const server = new StaticServer(8080, path);
    server.start().then(url => {
      setSource(url);
      console.log('Serving at URL', url);
    });

    return () => {
      server.stop();
    };
  }, []);

  return (
    <WebView
      style={{flex: 1}}
      source={{
        uri: source
      }}
      originWhitelist={['*']}
      javaScriptEnabled
      domStorageEnabled
      allowFileAccess
    />
  );
};

export default TpWebPortal;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文