This is an automated email from the ASF dual-hosted git repository. dpogue pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
The following commit(s) were added to refs/heads/master by this push: new ecac2944 fix(objc): Workaround for Swift/ObjC template issues (#1494) ecac2944 is described below commit ecac29443b1f1215bcd140fc3d836067cfc900ca Author: Darryl Pogue <dar...@dpogue.ca> AuthorDate: Tue Oct 8 01:27:23 2024 -0700 fix(objc): Workaround for Swift/ObjC template issues (#1494) This uses "non-standard" Swift annotations, but they've been supported by the past few versions of Xcode and are in the process of being standardized. Most importantly, they work for what we need. Closes GH-1487. --- templates/project/App/AppDelegate.h | 13 +++++++------ templates/project/App/AppDelegate.swift | 7 +++---- templates/project/App/Bridging-Header.h | 5 +++++ templates/project/App/MainViewController.h | 13 +++++++------ templates/project/App/ViewController.swift | 6 ++++-- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/templates/project/App/AppDelegate.h b/templates/project/App/AppDelegate.h index 99e6a3e5..62a77631 100644 --- a/templates/project/App/AppDelegate.h +++ b/templates/project/App/AppDelegate.h @@ -19,10 +19,11 @@ #import <Cordova/CDVAppDelegate.h> -#warning It is unsafe to rely on the AppDelegate class as an extension point. \ - Update your code to extend CDVAppDelegate instead -- \ - This code will stop working in Cordova iOS 9! +#ifndef __CORDOVA_SILENCE_HEADER_DEPRECATIONS + #warning It is unsafe to rely on the AppDelegate class as an extension point. \ + Update your code to extend CDVAppDelegate instead -- \ + This code will stop working in Cordova iOS 9! +#endif -@class AppDelegate; - -#import "App-Swift.h" +@interface AppDelegate : CDVAppDelegate +@end diff --git a/templates/project/App/AppDelegate.swift b/templates/project/App/AppDelegate.swift index aa50cfe9..e6ef28ff 100644 --- a/templates/project/App/AppDelegate.swift +++ b/templates/project/App/AppDelegate.swift @@ -18,12 +18,11 @@ */ import UIKit -import Cordova @main -@objc // Remove compat hack in Cordova iOS 9 -class AppDelegate: CDVAppDelegate { - override func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { +@_objcImplementation +extension AppDelegate { + open override func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } } diff --git a/templates/project/App/Bridging-Header.h b/templates/project/App/Bridging-Header.h index 2644cdb1..9dec5295 100644 --- a/templates/project/App/Bridging-Header.h +++ b/templates/project/App/Bridging-Header.h @@ -18,3 +18,8 @@ */ #import <Cordova/Cordova.h> + +#define __CORDOVA_SILENCE_HEADER_DEPRECATIONS +#import "AppDelegate.h" +#import "MainViewController.h" +#undef __CORDOVA_SILENCE_HEADER_DEPRECATIONS diff --git a/templates/project/App/MainViewController.h b/templates/project/App/MainViewController.h index 22c0cb26..ddb37c4a 100644 --- a/templates/project/App/MainViewController.h +++ b/templates/project/App/MainViewController.h @@ -19,10 +19,11 @@ #import <Cordova/CDVViewController.h> -#warning It is unsafe to rely on the MainViewController class as an extension point. \ - Update your code to extend CDVViewController instead -- \ - This code will stop working in Cordova iOS 9! +#ifndef __CORDOVA_SILENCE_HEADER_DEPRECATIONS + #warning It is unsafe to rely on the MainViewController class as an extension point. \ + Update your code to extend CDVViewController instead -- \ + This code will stop working in Cordova iOS 9! +#endif -@class MainViewController; - -#import "App-Swift.h" +@interface MainViewController : CDVViewController +@end diff --git a/templates/project/App/ViewController.swift b/templates/project/App/ViewController.swift index f72f1f3e..87837032 100644 --- a/templates/project/App/ViewController.swift +++ b/templates/project/App/ViewController.swift @@ -19,7 +19,9 @@ import Cordova -@objc(MainViewController) // Remove compat hack in Cordova iOS 9 -class ViewController: CDVViewController { +@_objcImplementation +extension MainViewController { } +class ViewController: MainViewController { +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org