UIActivityViewController duplicate url in iOS-11

Viewed 998

The url is duplicated when the user choose "Copy" from the activity controller in iOS 11 only. It was working properly on iOS 10

Using the below code

@IBAction func shareButtonPressed() {
    guard let url = URL(string: "http://google.com") else { return }
    let shareText = "Share Text!"
    let items: [Any] = [shareText, url]
    let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
    present(activityViewController, animated: true, completion: nil)
}

gives the shared text as:

Share Text! 
http://google.comhttp://google.com
1 Answers

I managed to fix it by using the url as String instead of URL.

let items: [Any] = [shareText, url.absoluteString]
Related