Post

Replies

Boosts

Views

Activity

UIPasteboard bug?
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")
2
0
2.6k
Jul ’20
SwiftUI onReceive question && Publisher bug?
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 { &#9;&#9;@Published var image = 2 } struct ContentView: View { &#9;&#9;@ObservedObject var store = Store() &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;NavigationView { &#9;&#9;&#9;&#9;&#9;&#9;List(0 ..< 5) { _ in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink( &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;destination: Text("destination") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.onReceive(self.store.$image) { _ in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print("1") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;label: { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("test") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;} } And you'll find it will print "1" once in old Xcode 11.5 while print "1" twice in Xcode 12.0 beta2
0
0
3.2k
Jul ’20
[Bug] SWIFT_PACKAGE not defined in iPad Playgrounds 4
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"
1
0
638
Feb ’22
FinderSync Extension UI disappear on macOS 15's Setting
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
2
2
254
Sep ’24