Post not yet marked as solved
In order to localize string interpolation inside SwiftUI Text Views, String(localized:) and AttributedString(localized:), the project or framework's build settings needs to have Use Compiler to Extract Swift Strings enabled (e.g. SWIFT_EMIT_LOC_STRINGS=YES).
However, while testing exports it appears that exporting localizations (Product > Export Localizations) are always done using a RELEASE build rather than a DEBUG build.
For us, this is problematic as release builds use certificates that are only used by the build system. Software or internationalization engineers trying to export localizations with Use Compiler to Extract Swift Strings enabled, will run into issues as the swift compiler step will fail.
Is there a way to make localization exports use a DEBUG build rather than a RELEASE build? Or alternatively ignore signing for localization exports?
Post not yet marked as solved
We are using a SwiftUI view backed by PencilKit and are experiencing an issue on iOS 16 where drawn strokes disappear from the drawing (the drawing is empty after the stroke ends). Debugging the issue shows that PKCanvasView's drawing collection of strokes is increasing, yet they are not being rendered.
Details:
I'm on macOS 12.6 Monterey
The bug surfaces in Xcode 14.1 / iOS 16.1 (I didn't check the Xcode 14.0 / 14.0.1).
The code works as expected in Xcode 13.4.1 / iOS 15.5.
The bug appears not to happen on device (iPhone 13 Pro / iOS 16.1.1)
Example code demonstrating the issue:
I have added a couple of print statements to show what is happening and to count the brush strokes of the PKDrawing. Please see the attached GIFs below that demonstrate the issue.
import SwiftUI
import PencilKit
public struct TestCanvas {
private static let defaultTool = PKInkingTool(.pen, color: .darkGray, width: 5)
}
// MARK: UIViewRepresentable
extension TestCanvas: UIViewRepresentable {
public func makeUIView(context: Context) -> some UIView {
print("make ui view")
let canvasView = PKCanvasView()
canvasView.delegate = context.coordinator
canvasView.drawingPolicy = .anyInput
canvasView.tool = Self.defaultTool
canvasView.isRulerActive = false
canvasView.backgroundColor = .clear
canvasView.isOpaque = true
return canvasView
}
public func updateUIView(_ uiView: UIViewType, context: Context) {
print("update ui view")
}
public func makeCoordinator() -> Coordinator {
Coordinator(self)
}
}
// MARK: Coordinator
public extension TestCanvas {
@MainActor final class Coordinator: NSObject {
private let parent: TestCanvas
init(_ parent: TestCanvas) {
print("init coordinator")
self.parent = parent
super.init()
}
}
}
// MARK: PKCanvasViewDelegate
extension TestCanvas.Coordinator: PKCanvasViewDelegate {
public func canvasViewDidEndUsingTool(_ canvasView: PKCanvasView) {
print("canvas did end using tool (\(canvasView.drawing.strokes.count) strokes)")
}
public func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) {
print("drawing did change (\(canvasView.drawing.strokes.count) strokes)")
}
}
Xcode 14.1 / iOS 16.1
PencilKit issue occurs on Xcode 14.1 / iOS 16.1 Simulator. Note the strokes disappear, yet the drawing's strokes keep incrementing.
Xcode 13.4.1 / iOS 15.5
It works fine in Xcode 13.4.1 / iOS 15.5 Simulator.
iPhone 13 Pro / iOS 16.1.1
I don't experience the issue on device (iPhone 13 Pro, iOS 16.1.1).