I was trying to use UIPasteboard.general.url to get some content, and I found that UIPasteboard.general.string could get the Universal Clipboard (other devices' clipboard like Mac's and iPad's) while UIPasteboard.general.url could only get the local Clipboard.
Below is a simply way to reproduce (in SwiftUI)
Button(Text("getURL")){
print("url is \(UIPasteboard.general.url)")
print("string is \(UIPasteboard.general.string)")
}
First you copy this link (actually any url string is OK) in Mac http://pic1.win4000.com/wallpaper/2019-08-05/5d47e530bcf01.jpg . And click the above button in your iOS device, you'll see something like this in your log
url is nil
string is Optional("http://pic1.win4000.com/wallpaper/2019-08-05/5d47e530bcf01.jpg")
2. Second you simply paste it into your iOS device(Universal Clipboard on) and copy it so that your local pasteboard have this content. And then click the above button in your iOS device, you'll see something like this in your log
url is Optional("http://pic1.win4000.com/wallpaper/2019-08-05/5d47e530bcf01.jpg")
string is Optional("http://pic1.win4000.com/wallpaper/2019-08-05/5d47e530bcf01.jpg")
Post
Replies
Boosts
Views
Activity
How to delete my question in Developer Forum
Carelessly created duplicate questions, is there a way to delete my question?
Description
I have the following code in a working project, after migrating from SwiftUI1.0 to SwiftUI2.0, it behaves abnormally.
// @Published var backgroundImage:UIImage?
XXView()
.onReceive(document.$backgroundImage) { image in
zoomToFit(image, in: geometry.size)
}
In the old SwiftUI 1.0(Xcode 11.5), this will normally work and will be triggered once when launching the View. (Because backgroundImage is nil at first and then get inited)
But in SwiftUI2.0(Xcode 12.0 beta2), this will not work and it zoomToFit will be triggered twice when launching the View.
In zoomToFit function, I printed the size of image and geometry size, here is the result
// Xcode 11.5
Optional((284.0, 177.0))
(0.0, 0.0)
// Xcode 12.0 beta2
Optional((284.0, 177.0))
(0.0, 0.0)
Optional((284.0, 177.0))
(414.0, 647.69091796875)
Reproduce
Below is a simply way to reproduce
New a project
If you are creating this using Xcode 12, remember to choose lifeCycle to UIKit App Delegate(easy to work with both Xcode version) - Add the following to ContentView.swift
import SwiftUI
class Store: ObservableObject {
		@Published var image = 2
}
struct ContentView: View {
		@ObservedObject var store = Store()
		var body: some View {
				NavigationView {
						List(0 ..< 5) { _ in
								NavigationLink(
										destination: Text("destination")
												.onReceive(self.store.$image) { _ in
														print("1")
												},
										label: {
												Text("test")
								})
						}
				}
		}
}
And you'll find it will print "1" once in old Xcode 11.5 while print "1" twice in Xcode 12.0 beta2
In the new Swift Playground App format, we can share code between an iPad's Playground and Mac's Xcode. But some key behaviors are inconsistent.
For example, using Xcode/iPad Playground to new a Test "Swift Playground App" and adding the following code.
We'll see "1" on Xcode while "2" on iPad Playground App
Test.swiftpm
struct ContentView: View {
var body: some View {
#if SWIFT_PACKAGE
Text("1") // Using Xcode to open
#else
Text("2") // Using iPad Playground App to open
#endif
}
}
I think for a Swift Playground App, they should both to be "1"
Description
We used to use FIFinderSyncController.showExtensionManagementInterface() to navigate to the corresponding Setting's path via a button in our app to make the user enable our FinderSync App. (Or user can navigate manually via "System Settings -> Privacy & Security -> Extensions -> Added Extensions" themselves in Settings.app)
But the UI is now disappearing on macOS 15.0
As a result, if user had previously enabled it, user will now be unable to disable it, and if user had not previously enabled it, user will never be able to enable it.
STEPS TO REPRODUCE
Create an empty macOS app xcodeprojc, add Finder Sync Extension and run it.
Or you can use the repo here to reproduce the issue. https://github.com/Kyle-Ye/MenuHelper