Unable to Disable/Hide Writing Tools in iOS 18

Hi everyone,

I’m working on an app that uses WKWebView. Due to security concerns, our customers want the app to disable copy-paste functionality and similar options (such as Lookup and Share, allowing users to extract text from the app or save it as a file.

I was able to disable copy-paste and remove UIMenu options like Lookup and Share.

Everything worked fine until the iOS 18.1 beta, which introduced a new menu called Writing Tools (Apple Intelligence) that has its own copy and share buttons

I've tried several ways to remove it

  1. Remove all UIMenu items using canPerformAction, and it works for all menus but Writing Tools, which still remains
 override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
        return false
    }
  1. Remove it from UIMenuBuilder
    override func buildMenu(with builder: UIMenuBuilder) {
        builder.remove(menu: .lookup)
        builder.remove(menu: .share)
    }
    

But unfortunately, UIMenuBuilder does not have an identifier for Writing Tools, and it seems like there are no API changes from Xcode 15 to Xcode 16 (https://developer.apple.com/documentation/uikit/uimenu/identifier)

It seems like the only way to disable it through MDM configuration (key: allowWritingTools), but we don't use MDM

https://developer.apple.com/documentation/devicemanagement/restrictions

Environment

  • iOS Version: iOS 18.1 beta4
  • Device: iPhone 15 Pro
  • App platform: iOS
  • Xcode version: 16.0
  • MacOS: 15.0

Thank you

Answered by DTS Engineer in 805433022

Hello @stevz,

Thank you for asking this question!

You can disable Writing Tools on your WKWebView by setting the writingToolsBehavior of your WKWebViewConfiguration to .none.

Best regards,

Greg

Accepted Answer

Hello @stevz,

Thank you for asking this question!

You can disable Writing Tools on your WKWebView by setting the writingToolsBehavior of your WKWebViewConfiguration to .none.

Best regards,

Greg

Hi @DTS Engineer , Does this require Xcode 16.1? I'm on Xcode Version 16.0 (16A242d), and I'm getting the error: Value of type 'WKWebViewConfiguration' has no member 'writingToolsBehavior'.

Hey @baofromsf,

Interesting, no it does not require Xcode 16.1, I was able to successfully compile that code using Xcode 16 (16A242d). Could you attach your full build log that shows the full error?

Best regards,

Greg

I found that this happens when the deployment target is set to iOS 16. This can be reproduced on a brand new project.

Here's a full log:

thanks for your help @DTS Engineer

Is there a workaround to keep deployment target to iOS 16 while still making this work?

Hi @DTS Engineer / Greg,

Thank you for your help. I was able to disable it, but only when the deployment target is set to iOS 18. If I set it to below iOS 18 (iOS16 / iOS17), I'm getting the same error as @baofromsf (even with #available).

I am using the same version of Xcode 16.0 as you (16A242d).

Hello @stevz,

Thanks for the additional info! Yes it appears that the property only exists if your deployment target is iOS 18+.

Please file a bug report for this issue using Feedback Assistant.

Best regards,

Greg

Hi @DTS Engineer / Greg,

I've filled out a bug report through Feedback Assistant, case id: FB15294096

I was able to work around this issue with NSInvocation in Objective-C:

WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];

SEL selector = @selector(setWritingToolsBehavior:);
NSMethodSignature *sig = [config methodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig];
[invocation setSelector:selector];
[invocation setTarget:config];

NSInteger arg = (NSInteger)UIWritingToolsBehaviorNone;
[invocation setArgument:&arg atIndex:2];
[invocation invoke];

This works to set the writingToolsBehavior to none, and I don't get the Writing Tools option in my popup when selecting text in my WKWebView.

Unable to Disable/Hide Writing Tools in iOS 18
 
 
Q