2.0.1 on RN 0.87: Android import/focus, iOS paste tag, pod install, PasteInputModule compile, missing Swift module
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 52/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- android, ios, react-native, typescript
Rechercherichtung
Start with src/PasteInput.tsx, src/NativePasteInputModule.ts, and src/PasteTextInput.tsx; trace the Android module import and the iOS registration effects, then check the native command definitions. Reproduce the three platform-specific failures with React Native 0.87.0. Done means Android imports without the TurboModule error and exposes working focus and blur methods, while iOS registers the input and fires onPaste when __nativeTag is absent.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
SUMMARY
Local patch-package diff against @mattermost/[email protected] (src/PasteInput.tsx, src/PasteTextInput.tsx, ios/PasteInputModule.mm). It fixes four separate bugs. Items 4 and 6 are Podfile workarounds and are not part of the patch. 2.0.1 is the latest release (2026-05-09).
1. Android: importing the package crashes
Importing PasteInput throws before the component mounts:
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'PasteInputModule' could not be found
Any screen that imports the package crashes on Android, even if it never pastes.
src/NativePasteInputModule.ts evaluates this at module scope:
export default TurboModuleRegistry.getEnforcing<Spec>('PasteInputModule');
src/PasteInput.tsx imports that module at the top level. NativeEventEmitter is created only when Platform.OS === 'ios', but the import still runs getEnforcing on Android.
On Android the native class is a stub, not a TurboModule. Paste goes through PasteTextInput / PasteTextInputManager, and registerTextInput on this module is a no-op.
/**
* TurboModule stub for Android.
* This module exists only to satisfy codegen requirements.
*/
class PasteInputModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext)
Fix: do not import the module at the top level. Require it only on the iOS path, and create NativeEventEmitter there.
import type NativePasteInputModule from './NativePasteInputModule';
function getNativePasteInputModule(): NativePasteInputModule {
return require('./NativePasteInputModule').default;
}
Use that helper in both iOS useEffects (registerTextInput, addListener, unregisterTextInput, and the config update).
2. iOS: paste never registers because __nativeTag is missing
PasteInputIOSComponent reads the tag like this:
// @ts-ignore - __nativeTag is an internal property
const nativeTag = textInputRef.current?.__nativeTag;
On Fabric that property is undefined, so the effect returns before registerTextInput. onPaste never fires.
Fix: fall back to the public API.
const nativeTag = textInputRef.current?.__nativeTag
?? (textInputRef.current ? findNodeHandle(textInputRef.current) : null);
This part overlaps https://github.com/mattermost/react-native-paste-input/issues/54 and https://github.com/mattermost/react-native-paste-input/pull/55. The other items in this issue are not covered there.
3. Android: ref.focus() and ref.blur() are missing
PasteTextInput assigns clear, isFocused, getNativeRef, and setSelection onto the instance. It does not assign focus or blur, so ref.current.focus() / ref.current.blur() throw on Android.
Commands.focus and Commands.blur already exist on the native component.
Fix: assign them next to clear:
focus(): void {
if (inputRef.current != null) {
Commands.focus(inputRef.current);
}
},
blur(): void {
if (inputRef.current != null) {
Commands.blur(inputRef.current);
}
},
4. iOS: pod install fails
react-native-paste-input.podspec raises unless ENV['RCT_NEW_ARCH_ENABLED'] == '1'.
On 0.87 that variable is set inside use_react_native!, which runs after use_native_modules! has already evaluated the podspec. New Architecture is the only architecture since 0.82, but the env var is still nil at that point, so install aborts:
react-native-paste-input 2.0.1 requires the React Native New Architecture (Fabric/TurboModules).
Workaround: ENV['RCT_NEW_ARCH_ENABLED'] = '1' in the Podfile before use_native_modules!.
5. iOS: PasteInputModule.mm does not compile
getSurfacePresenter assigns self.bridge.surfacePresenter to RCTSurfacePresenterBridgeAdapter *.
On 0.87 with prebuilt React-Core that property is id<RCTSurfacePresenterStub>, and RCTSurfacePresenterBridgeAdapter is only forward-declared (RCTRootViewFactory.h). Xcode errors:
- cannot initialize a variable of type 'RCTSurfacePresenterBridgeAdapter *' with an rvalue of type 'id'
- receiver type 'RCTSurfacePresenterBridgeAdapter' for instance message is a forward declaration
- property 'surfacePresenter' cannot be found in forward class object 'RCTSurfacePresenterBridgeAdapter'
Fix: keep the value as id and resolve surfacePresenter via performSelector, the same way the bridgeless branch already does. If the object has no such property, return it as the presenter.
6. iOS: Swift cannot import react_native_paste_input
The README tells AppDelegate.swift to import react_native_paste_input and call PasteInputModule.setup. The pod is Objective-C++ only (ios/**/*.{h,m,mm,swift,cpp} matches no Swift files). s.swift_version does not make CocoaPods emit a module map, and the podspec never sets DEFINES_MODULE. Headers land in Pods/Headers/Public/react-native-paste-input, but Swift explicit modules (Xcode / iOS SDK 27) have no module map to load:
Unable to resolve module dependency: 'react_native_paste_input'
import react_native_paste_input
Fix: set DEFINES_MODULE to YES in the podspec before install_modules_dependencies, so CocoaPods generates the react_native_paste_input module map. Hyphens in the pod name are already rewritten to underscores, which matches the documented import.
Workaround: in the Podfile pre_install, call set_use_modular_headers_for_pod('react-native-paste-input', true) on the app target definition, then run pod install again.
Expected
- Importing
PasteInputon Android does not callgetEnforcing. - On iOS, the text input is registered and
onPastefires when__nativeTagis absent. - On Android,
ref.focus()andref.blur()callCommands.focus/Commands.blur. pod installcompletes on RN 0.87 without settingRCT_NEW_ARCH_ENABLEDby hand.ios/PasteInputModule.mmcompiles against prebuilt React-Core.import react_native_paste_inputresolves inAppDelegate.swiftwithout a consumer Podfile hook.
ENVIRONMENT
- Platform: Android, iOS
- @mattermost/react-native-paste-input: 2.0.1
- react-native: 0.87.0
- react: 19.2.3
- Xcode / iOS SDK 27 (Swift explicit modules)
STEPS TO REPRODUCE
- Android import. Import
PasteInputfrom a screen and open that screen. The app throwsTurboModuleRegistry.getEnforcing(...): 'PasteInputModule' could not be foundbefore the input mounts. - iOS paste. Render
PasteInputwithonPasteand paste an image.__nativeTagis undefined,registerTextInputis never called,onPastedoes not fire. - Android focus. Take a ref to
PasteInputand callref.current.focus()orref.current.blur(). The call throws because those methods are not assigned on the instance. - iOS pods. Run
pod installon RN 0.87 with the stock Podfile. The paste-input podspec raises before pods are installed. - iOS compile. After setting
RCT_NEW_ARCH_ENABLED=1, archive or build the app.PasteInputModule.mmfails onRCTSurfacePresenterBridgeAdapter. - iOS Swift import. Follow the README
AppDelegate.swiftsnippet (import react_native_paste_input, thenPasteInputModule.setup). Build the app target. Swift reportsUnable to resolve module dependency: 'react_native_paste_input'.
- Vorherrschende Sprache
- Objective-C
- Sterne
- 213
- Forks
- 39
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus mattermost/react-native-paste-input
-
v2 paste interception silently bails on RN 0.76+ Fabric (uses `__nativeTag` which is undefined)Evtl. vergeben @manan19 hat das vor 172 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
mattermost/react-native-paste-input#54 · 1 Kommentar ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
-
Not compatible with webOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
mattermost/react-native-paste-input#47 · 6 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
Alle Issues in mattermost/react-native-paste-input
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
-
[FEATURE REQUEST] Replace "Nothing to see here-yet" text string with "This Tweet has been deleted"Offenenhancement
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 70/100
NeoFreeBird/app#204 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
lynx-family/lynx#10587 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
SwiftOldDriver/iOS-Weekly#5480 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Hammerspoon/hammerspoon#3913 ·