最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xcode - How to set multiple specs for iOS turbomodule? - Stack Overflow

programmeradmin2浏览0评论

I take a reference from official document, it's working. /docs/turbo-native-modules-introduction?platforms=ios

But when I try to set multiple specs for iOS, I get the error

10 duplicate symbols
Linker command failed with exit code 1 (use -v to see invocation)

Here is what I try:

step 1 npx @react-native-community/cli@latest init FirstApp

"react-native": "0.77.0",

step 2 add codegen setting in package.json

  "codegenConfig": {
    "libraries": [
      {
        "name": "NativeLocalStorageSpec",
        "type": "modules",
        "jsSrcsDir": "specs",
        "android": {
          "javaPackageName": "com.nativelocalstorage"
        }
      },
      {
        "name": "NativeBluetoothSpec",
        "type": "modules",
        "jsSrcsDir": "specs",
        "android": {
          "javaPackageName": "com.nativebluetooth"
        }
      }
    ]
  },

step 3 add file under specs folder (RN root project)

specs/NativeBluetooth.ts

import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

export interface Spec extends TurboModule {
  enableBluetooth(): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('NativeBluetooth');

specs/NativeLocalStorage.ts

import type {TurboModule} from 'react-native';
import {TurboModuleRegistry} from 'react-native';

export interface Spec extends TurboModule {
  setItem(value: string, key: string): void;
  getItem(key: string): string | null;
  removeItem(key: string): void;
  clear(): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('NativeLocalStorage');

step 4 type terminal command

cd ios

bundle install

bundle exec pod install

and then open XCode build the project get the error:

10 duplicate symbols

Linker command failed with exit code 1 (use -v to see invocation)

What is the problem ?

发布评论

评论列表(0)

  1. 暂无评论