Skip to content
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
2 changes: 1 addition & 1 deletion example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function useStyles() {
groupItemContainer: {
alignItems: "center",
flexDirection: "row",
marginHorizontal: margin,
paddingHorizontal: margin,
},
groupItemLabel: {
color: isDarkMode ? Colors.white : Colors.black,
Expand Down
39 changes: 34 additions & 5 deletions ios/ReactTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func application(_ application: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
self.application = application

Expand All @@ -24,21 +24,50 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
)
}

// application(_:didFinishLaunchingWithOptions:)

return true
}

// MARK: UISceneSession Lifecycle
func applicationWillTerminate(_ application: UIApplication) {
// applicationWillTerminate(_:)
}

// MARK: Push Notifications

func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
// application(_:didRegisterForRemoteNotificationsWithDeviceToken:)
}

func application(_: UIApplication,
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error)
{
// application(_:didFailToRegisterForRemoteNotificationsWithError:)
}

func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
{
// application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
}

// MARK: UISceneSession Support

func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options _: UIScene.ConnectionOptions) -> UISceneConfiguration
options: UIScene.ConnectionOptions) -> UISceneConfiguration
{
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_: UIApplication, didDiscardSceneSessions _: Set<UISceneSession>) {
func application(_ application: UIApplication,
didDiscardSceneSessions sceneSessions: Set<UISceneSession>)
{
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after
// application:didFinishLaunchingWithOptions.
Expand Down
2 changes: 2 additions & 0 deletions ios/ReactTestApp/Public/ReactTestApp-DevSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
NS_ASSUME_NONNULL_BEGIN

extern NSNotificationName const ReactTestAppDidInitializeNotification;

extern NSNotificationName const ReactTestAppWillInitializeReactNativeNotification;
extern NSNotificationName const ReactTestAppDidInitializeReactNativeNotification;
extern NSNotificationName const ReactTestAppDidRegisterAppsNotification;

extern NSNotificationName const ReactTestAppSceneDidOpenURLNotification;

NS_ASSUME_NONNULL_END
2 changes: 2 additions & 0 deletions ios/ReactTestApp/ReactTestApp-DevSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

NSNotificationName const ReactTestAppDidInitializeNotification =
@"ReactTestAppDidInitializeNotification";

NSNotificationName const ReactTestAppWillInitializeReactNativeNotification =
@"ReactTestAppWillInitializeReactNativeNotification";
NSNotificationName const ReactTestAppDidInitializeReactNativeNotification =
@"ReactTestAppDidInitializeReactNativeNotification";
NSNotificationName const ReactTestAppDidRegisterAppsNotification =
@"ReactTestAppDidRegisterAppsNotification";

NSNotificationName const ReactTestAppSceneDidOpenURLNotification =
@"ReactTestAppSceneDidOpenURLNotification";
33 changes: 24 additions & 9 deletions ios/ReactTestApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,38 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {

private lazy var reactInstance = ReactInstance()

func sceneDidDisconnect(_: UIScene) {
func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not neccessarily discarded (see
// `application:didDiscardSceneSessions` instead).
// sceneDidDisconnect(_:)
}

func sceneDidBecomeActive(_: UIScene) {
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
// sceneDidBecomeActive(_:)
}

func sceneWillResignActive(_: UIScene) {
func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
// sceneWillResignActive(_:)
}

func sceneWillEnterForeground(_: UIScene) {
func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
// sceneWillEnterForeground(_:)
}

func sceneDidEnterBackground(_: UIScene) {
func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
// sceneDidEnterBackground(_:)
}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
Expand All @@ -51,6 +56,12 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
"URLContexts": URLContexts,
]
)

// scene(_:openURLContexts:)
}

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
// scene(_:continue:)
}
}

Expand All @@ -65,8 +76,8 @@ extension SceneDelegate {
}

func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions)
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene
// `scene`.
Expand All @@ -86,6 +97,8 @@ extension SceneDelegate {
self.window = window
window.makeKeyAndVisible()
}

// scene(_:willConnectTo:options:)
}
}

Expand All @@ -97,8 +110,8 @@ extension SceneDelegate {

extension SceneDelegate {
func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions)
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions)
{
guard let windowScene = scene as? UIWindowScene else {
assertionFailure("Default scene configuration should have been loaded by now")
Expand All @@ -120,6 +133,8 @@ extension SceneDelegate {
self.window = window

window.makeKeyAndVisible()

// scene(_:willConnectTo:options:)
}
}

Expand Down
15 changes: 15 additions & 0 deletions ios/test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ def app_config(project_root)
[manifest['name'], manifest['displayName'], manifest['version'], manifest['singleApp']]
end

def apply_config_plugins(project_root)
begin
resolve_module('@expo/config-plugins')
rescue StandardError
# Skip if `@expo/config-plugins` cannot be found
return
end

apply_config_plugins = File.join(__dir__, '..', 'scripts', 'apply-config-plugins.mjs')
result = system("node \"#{apply_config_plugins}\" \"#{project_root}\"")
raise 'Failed to apply config plugins' unless result
end

def autolink_script_path
package_path = resolve_module('@react-native-community/cli-platform-ios')
File.join(package_path, 'native_modules')
Expand Down Expand Up @@ -465,6 +478,8 @@ def use_test_app_internal!(target_platform, options)
end
end

apply_config_plugins(project_root)

Pod::UI.notice(
"`#{xcodeproj}` was sourced from `react-native-test-app`. " \
'All modifications will be overwritten next time you run `pod install`.'
Expand Down
71 changes: 45 additions & 26 deletions macos/ReactTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,42 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
true
}

func applicationDidFinishLaunching(_: Notification) {
NotificationCenter.default.post(
name: .ReactTestAppDidInitialize,
object: nil
)

initialize()

// applicationDidFinishLaunching(_:)
}

func applicationWillTerminate(_: Notification) {
// Insert code here to tear down your application
// applicationWillTerminate(_:)
}

// MARK: Push Notifications

func application(_ application: NSApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
// application(_:didRegisterForRemoteNotificationsWithDeviceToken:)
}

func application(_ application: NSApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error)
{
// application(_:didFailToRegisterForRemoteNotificationsWithError:)
}

// MARK: - User interaction
func application(_ application: NSApplication,
didReceiveRemoteNotification userInfo: [String: Any])
{
// application(_:didReceiveRemoteNotification:)
}

// MARK: User interaction

@IBAction
func onLoadEmbeddedBundleSelected(_: NSMenuItem) {
Expand All @@ -50,7 +81,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
}

// MARK: - Private
// MARK: Private

private enum WindowSize {
static let defaultSize = CGSize(width: 640, height: 480)
Expand All @@ -76,22 +107,7 @@ extension AppDelegate {
!(mainWindow?.contentViewController is ViewController)
}

func applicationWillFinishLaunching(_: Notification) {
if Session.shouldRememberLastComponent {
rememberLastComponentMenuItem.state = .on
}

showReactMenu()
}

func applicationDidFinishLaunching(_: Notification) {
defer {
NotificationCenter.default.post(
name: .ReactTestAppDidInitialize,
object: nil
)
}

func initialize() {
guard let (manifest, checksum) = Manifest.fromFile() else {
let item = reactMenu.addItem(
withTitle: "Could not load 'app.json'",
Expand Down Expand Up @@ -149,6 +165,14 @@ extension AppDelegate {
manifestChecksum = checksum
}

func applicationWillFinishLaunching(_: Notification) {
if Session.shouldRememberLastComponent {
rememberLastComponentMenuItem.state = .on
}

showReactMenu()
}

@objc
private func onComponentSelected(menuItem: NSMenuItem) {
guard let component = menuItem.representedObject as? Component else {
Expand Down Expand Up @@ -257,6 +281,8 @@ extension AppDelegate {
#if ENABLE_SINGLE_APP_MODE

extension AppDelegate {
func initialize() {}

func applicationWillFinishLaunching(_: Notification) {
guard let window = mainWindow else {
assertionFailure("Main window should have been instantiated by now")
Expand All @@ -282,13 +308,6 @@ extension AppDelegate {
showReactMenu()
#endif // DEBUG
}

func applicationDidFinishLaunching(_: Notification) {
NotificationCenter.default.post(
name: .ReactTestAppDidInitialize,
object: nil
)
}
}

#endif // ENABLE_SINGLE_APP_MODE
Expand Down
Loading