Displaying alerts shows compiler warnings

I'm pretty new to Swift and I'm having some trouble implementing alerts into my SpriteKit game. Well, it works however it keeps giving warnings:

2022-06-03 02:04:04.465264+0100 Project14[57880:10648157] [LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionViewCell that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <_UIAlertControllerTextFieldViewCollectionCell: 0x13ed18d70; frame = (0 24; 270 24); gestureRecognizers = <NSArray: 0x6000009c81b0>; layer = <CALayer: 0x600000713600>>

2022-06-03 02:06:16.239075+0100 Project14[57880:10648157] [HardwareKeyboard] -[UIApplication getKeyboardDevicePropertiesForSenderID:shouldUpdate:usingSyntheticEvent:], failed to fetch device property for senderID (778835616971358211) use primary keyboard info instead.

How do I get rid of this warnings? Thanks.

   
    let alert = UIAlertController(title: "title", message: "message", preferredStyle: UIAlertController.Style.alert)
    
    alert.addTextField { field in

        field.placeholder = "Input your name"
        field.isSecureTextEntry = false
        field.textAlignment = .left

    }
    
    alert.addAction(UIAlertAction(title: "OK", style: .default) { _ in
        print("ok")
    })
    
    alert.addAction(UIAlertAction(title: "Cancel", style: .default) { _ in
       print("cancel")
    })
    
    view?.window?.rootViewController?.present(alert, animated: true)
    
}

I cannot use just present(alert, animated: true). In this case I get compiler error - "Value of type 'SceneMenu' has no member 'present'"

Could you show more code so that we understand the context (where is SceneMenu ? Is this in a UICollectionViewCell ?).

Do you run in simulator ? If so, just ignore the keyboard message.

Hi. Sorry for the late reply. Here is the whole code:

GameViewController.swift

import SpriteKit

class GameViewController: UIViewController {
   
  override func viewDidLoad() {
     
    let scene = SceneMenu(size: view.frame.size)
    scene.scaleMode = .aspectFill
    scene.backgroundColor = .white
     
    let view = view as! SKView
    view.presentScene(scene)
     
  }
   
}

SceneMenu.swift:

import SpriteKit

class SceneMenu: SKScene {
   
  override init(size: CGSize) {
     
    super.init(size: size)
     
    let btnAlert = SKLabelNode(text: "Show Alert")
    btnAlert.name = "btn_alert"
    btnAlert.fontSize = 20
    btnAlert.fontColor = SKColor.blue
    btnAlert.fontName = "Avenir"
    btnAlert.position = CGPoint(x: size.width / 2, y: size.height / 2)
    addChild(btnAlert)
     
  }
   
  required init?(coder aDecoder: NSCoder) {
     
    fatalError("init(coder:) has not been implemented")
     
  }
   
  func showAlert() {
     
    let alert = UIAlertController(title: "title", message: "message", preferredStyle: UIAlertController.Style.alert)
     
    alert.addTextField { field in
      field.placeholder = "Type your name"
    }
     
    alert.addAction(UIAlertAction(title: "OK", style: .default) { _ in
      print("OK")
    })
     
    view?.window?.rootViewController?.present(alert, animated: true)
     
  }
   
  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
     
    if let touch = touches.first {
       
      let location = touch.location(in: self)
      let action = atPoint(location)
       
      if action.name == "btn_alert" {
         
        showAlert()
         
      }
       
    }
     
  }
   
}

The code works, however every time I run the code I get two warnings (on device & in emulator).

Debug warning #1:

2022-06-04 15:31:46.134563+0100 Game16[86767:3617120] [LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionViewCell that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <_UIAlertControllerTextFieldViewCollectionCell: 0x122022da0; frame = (0 0; 270 24); gestureRecognizers = <NSArray: 0x600000a97e40>; layer = <CALayer: 0x600000498220>>

Debug warning #2:

2022-06-04 15:32:10.228624+0100 Game16[86767:3617120] [HardwareKeyboard] -[UIApplication getKeyboardDevicePropertiesForSenderID:shouldUpdate:usingSyntheticEvent:], failed to fetch device property for senderID (778835616971358211) use primary keyboard info instead.

Any help how to get rid of this warnings would be appreciated. Thanks.

After further testing, I noticed that debug warning #1 is displayed on both device and in emulator, while debug warning #2 is displayed only on emulator.

Debug warning #1 <- that's the only issue now.

While debug warning #2 is displayed only in emulator which can be resolved by disabling "Connect Hardware Keyboard".

The error tells about UICollectionViewCell. But I do not see any UICollectionView in your code.

For error #2, that's what I wrote before: Do you run in simulator ? If so, just ignore the keyboard message.

There is no UICollectionViewCall in my code, any suggestion what it can be or how to resolve? You can use the above code to replicate the issue.

Error #2, you were right. thanks

I am also having the same problem.

This warning is creepy, even though the device seems to work fine.

  1. Xcode Version 14.0 beta 6 (14A5294g)

  2. iPad Air 4Generation iPadOS 16 beta7

  3. iPhoneSE 2Generation iOS 16 beta7

Displaying alerts shows compiler warnings
 
 
Q