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 ?