0

can i use below one ?

let app = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication

for app store build instead of

let app = UIApplication.shared

in my application i was using let app = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication at some places inside my SDK but after integrating my SDK in notification extension i found compilation issue due UIApplication.shared is unavailable for extension. i replaced UIApplication.shared with UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication. Now i can build my application successfully.

  • Hi Amit, Yes you can use it why not. I found this documentation in the apple doc it has no violation: https://developer.apple.com/documentation/objectivec/nsobject/1416468-value – ankitjaiswal Aug 01 '23 at 05:30
  • I have doubt as UIApplication.shared is not available in Notification extension if it is not available some how using key path we are trying to achieve. error UIApplication.shared is unavailable for extension using above solution we are trying to violet the rule. – Amit Saxena Aug 01 '23 at 12:59

0 Answers0