Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(objc): Workaround for Swift/ObjC template issues #1494

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions templates/project/App/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions templates/project/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 5 additions & 0 deletions templates/project/App/Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
*/

#import <Cordova/Cordova.h>

#define __CORDOVA_SILENCE_HEADER_DEPRECATIONS
#import "AppDelegate.h"
#import "MainViewController.h"
#undef __CORDOVA_SILENCE_HEADER_DEPRECATIONS
13 changes: 7 additions & 6 deletions templates/project/App/MainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions templates/project/App/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

import Cordova

@objc(MainViewController) // Remove compat hack in Cordova iOS 9
class ViewController: CDVViewController {
@_objcImplementation
extension MainViewController {
}

class ViewController: MainViewController {
}