2

So we have an app, it's minimum target is iOS11. We have introduced Pencil kit (iOS13 only). So need to support both iOS11 and 13. The app will compile and run as long as we use stored properties in functions.

However when we use new variables in functions i.e. PKToolPicker we get the following error Undefined symbol: _OBJC_CLASS_$_PKToolPicker.

import UIKit
#if canImport(PencilKit)
import PencilKit
#endif

@available(iOS 13.0, *)
class ViewController: UIViewController, PKToolPickerObserver {

    #if canImport(PencilKit)
    private var drawing: PKDrawing!
    private var canvasView: PKCanvasView!
    #endif

    override func viewDidLoad() {
        super.viewDidLoad()
        #if canImport(PencilKit)
        if let window = parent?.view.window, let toolPicker = PKToolPicker.shared(for: window) {
            canvasView.becomeFirstResponder()
        }
        #endif
    }
}

Help?

byaruhaf
  • 4,128
  • 2
  • 32
  • 50
t.ios
  • 1,024
  • 12
  • 18

1 Answers1

0

What version of Deployment Target did you set? Maybe try to change #if canImport(PencilKit) to *if #available(iOS 13.0, )

Honza K.
  • 113
  • 8
  • Deployment target has to be iOS11. `*if #available(iOS 13.0, )` only compiles once inside the class. – t.ios Aug 23 '19 at 13:25