There is error when launch app which use Pencil kit
When I try with iOS15 simulator or Xcode editor preview it crashed
Here is error message
Library not loaded: /usr/lib/swift/libswiftPencilKit.dylibI
Reason: tried: '/Users/.../Products/Debug-iphonesimulator/libswiftPencilKit.dylib' (no such file)
There is no problem with iOS14.5 simulator
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm implementing swift UI image view overlaid by canvas view in Pencil kit
Because Pencil kit is in UIKit
I create another class for creating gesture recognizer
Thankfully it work so I can zoom or pan on canvas view and the underling image view is responding
But unlikely using Gesture and GestureState in SwiftUI
It cause memory issue when I just zoom image it take almost 1GB
Here is my code
class GestureDelegate: NSObject, ObservableObject, UIGestureRecognizerDelegate {
var zoomScale: CGFloat {
fixedZoomScale * gestureZoomScale
}
var fixedZoomScale: CGFloat = 1
@Published var gestureZoomScale: CGFloat = 1
private(set) lazy var pinchGestureRecognizer: UIPinchGestureRecognizer = {
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(pinchImage(_:)))
pinchGesture.delegate = self
return pinchGesture
}()
Here is canvas view in UIViewRepresentable
There is pan gesture recognizer also but there is no problem with pan gesture
struct BlurMaskView: UIViewRepresentable {
private let canvas: PKCanvasView
private let gestureDelegate: GestureDelegate
func makeUIView(context: Context) -> PKCanvasView {
canvas.drawingPolicy = .anyInput
canvas.tool = tool
canvas.backgroundColor = .clear
canvas.addGestureRecognizer(gestureDelegate.pinchGestureRecognizer)
canvas.addGestureRecognizer(gestureDelegate.panGestureRecognizer)
return canvas
}
I have widget for schedule app
I tried get my widget updated according to user's schedule
Here is actual code for 'get timeline' in timeline provider
note that I make 2 entries for each user schedule
( one for notice start of schedule one hour early, the other for notice end of schedule)
let entryBeforehand = ScheduleEntry(
date: oneHourEarly,
holiday: holidays?[day.toInt],
scheduleTable: contractTable(start: day, tablePtr: &schedules))
entries.append(entryBeforehand)
let entryExpired = ScheduleEntry(
date: dateExpired,
holiday: holidays?[day.toInt],
scheduleTable: contractTable(start: day, tablePtr: &schedules))
entries.append(entryExpired)
But both entries can't trigger widget updating itself