NativeScript / NativeScript

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
https://nativescript.org
MIT License
24.28k stars 1.64k forks source link

Pasting function does not work on iOS #9722

Closed mobifly-dev closed 2 years ago

mobifly-dev commented 2 years ago

Issue Description

Pasting function does not work on any of TextField or TextView, SearchBar components on iOS.

This has been tested on the latest iOS 15.2 simulator and physical devices. In both cases with the same result.

If you try to copy a text and then paste into TextField in the app it returns nothing. If you try to paste in another place outside the app it works as expected.

The tooltip with "Paste" message appear but the tap action won't return the clipboard content.

I have tested the same programatically using native SDK - UIPasteboard.generalPasteboard but also it return nil instead value.

Probably it is related with iOS 15 managed pasteboard. I also figured out that the nativesctipt used UIPasteboard.general instead generalPasteboard clipboard? Maybe this is the reason.

Something wrong here.

Reproduction

  1. Copy a text outside the app
  2. Try to paste into TextField

Relevant log output (if applicable)

No response

Environment

OS: macOS 12.1
CPU: (8) x64 Apple M1
Shell: /bin/zsh
node: 16.13.1
npm: 8.1.2
nativescript: 8.1.5

# android
java: Not Found
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: 13.2.1/13C100
cocoapods: 1.11.2
python: 2.7.18
python3: 3.8.9
ruby: 2.7.5
platforms: 
  - DriverKit 21.2
  - iOS 15.2
  - macOS 12.1
  - tvOS 15.2
  - watchOS 8.3

Dependencies

"dependencies": {
  "@klippa/nativescript-login": "^3.0.1",
  "@nativescript-community/ui-collectionview": "^4.0.48",
  "@nativescript-community/ui-image": "^4.1.0",
  "@nativescript-community/ui-label": "^1.2.0",
  "@nativescript-community/ui-material-activityindicator": "^6.1.2",
  "@nativescript-community/ui-material-bottomsheet": "^6.1.2",
  "@nativescript-community/ui-material-ripple": "^6.1.2",
  "@nativescript-community/ui-pager": "^13.0.33",
  "@nativescript-community/universal-links": "^2.0.3",
  "@nativescript/appversion": "^2.0.0",
  "@nativescript/background-http": "^5.0.2",
  "@nativescript/camera": "^5.0.9",
  "@nativescript/core": "^8.1.5",
  "@nativescript/firebase": "^11.1.3",
  "@nativescript/imagepicker": "^1.0.6",
  "@nativescript/iqkeyboardmanager": "^2.0.0",
  "@nativescript/social-share": "^2.0.4",
  "@nativescript/theme": "^3.0.2",
  "@nota/nativescript-webview-ext": "^8.0.0",
  "@nstudio/nativescript-checkbox": "^2.0.4",
  "@nstudio/nativescript-loading-indicator": "^4.1.0",
  "@nstudio/nativescript-pulltorefresh": "^3.0.2",
  "@nstudio/nativescript-snackbar": "^2.1.0",
  "@sergeymell/nativescript-svg": "^1.1.2",
  "@squirrel-social/contacts": "^1.1.1",
  "@triniwiz/nativescript-downloader": "^3.0.1",
  "@triniwiz/nativescript-videorecorder": "^4.0.2",
  "@triniwiz/nativescript-youtubeplayer": "^4.1.4",
  "date-fns": "^2.28.0",
  "jwt-decode": "^3.1.2",
  "n7-google-places-autocomplete": "^1.0.11",
  "nativescript-carousel": "^7.0.1",
  "nativescript-clipboard": "^2.1.1",
  "nativescript-imagecropper": "^4.0.3",
  "nativescript-intl": "^4.0.2",
  "nativescript-permissions": "^1.3.12",
  "nativescript-plugin-badge": "file:plugins/nativescript-plugin-badge",
  "nativescript-toasts": "file:plugins/nativescript-toasts",
  "nativescript-ui-autocomplete": "^8.0.1",
  "nativescript-ui-dataform": "^8.0.1",
  "nativescript-ui-listview": "^10.0.1",
  "nativescript-videoplayer": "^5.0.1",
  "rxjs": "^7.5.1",
  "throttle-debounce": "^3.0.1"
},
"devDependencies": {
  "@nativescript/android": "~8.1.1",
  "@nativescript/ios": "~8.1.0",
  "@nativescript/types": "~8.1.1",
  "@nativescript/webpack": "^5.0.4",
  "nativescript-worker-loader": "^0.12.1",
  "typescript": "~4.5.4"
}

Please accept these terms

mobifly-dev commented 2 years ago

Finally resolved. On latest iOS you have to add App Sandbox support to your app. More information here: https://developer.apple.com/documentation/security/app_sandbox

Go to your App_Resources/iOS, then put to your app.entitlements

<key>com.apple.security.app-sandbox</key>
<true/>

More entitlements that are required to use some iOS areas:

    <key>com.apple.security.assets.movies.read-write</key>
    <true/>
    <key>com.apple.security.assets.music.read-write</key>
    <true/>
    <key>com.apple.security.assets.pictures.read-write</key>
    <true/>
    <key>com.apple.security.device.audio-input</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.files.downloads.read-write</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <key>com.apple.security.personal-information.addressbook</key>
    <true/>
    <key>com.apple.security.personal-information.photos-library</key>
    <true/>

I think this should be added to official NativeScript documentation. Basically it is required now.