Hi everyone,
If you're encountering the following error in Xcode while executing a simple webbrowser.open() command in your Python file, you're in the right place:
"BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate to the non-deprecated UIApplication.open(:options:completionHandler:). Force returning false (NO)."
This issue arises because, starting from iOS 18, the UIApplication.openURL(:) method has been deprecated. If you created your project, dependencies, and the kivy-ios folder before iOS 18, every time you try to open a URL, the deprecated method will be called.
To resolve this issue without rebuilding the entire project and waiting for the kivy-ios toolchain to be updated, simply follow these steps:
At the very top of your main.py file remplace import webbrowser by :
from pyobjus import autoclass
from pyobjus.dylib_manager import load_framework
load_framework('/System/Library/Frameworks/UIKit.framework')
NSURL = autoclass('NSURL')
UIApplication = autoclass('UIApplication')
def open_url(url):
nsurl = NSURL.URLWithString_(url)
app = UIApplication.sharedApplication()
options = {}
app.openURL_options_completionHandler_(nsurl, options, None)
Then replace all your webbrowser.open(url) commands by open_url(url)
You no longer need webbrowser.
Hope it helped.