Skip to content

Commit

Permalink
feat: add Swift entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Jan 8, 2024
1 parent 60e72d7 commit 32260e7
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 10 deletions.
20 changes: 20 additions & 0 deletions packages/rn-tester/RNTester-visionOS/App.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// App.swift
// RNTester-visionOS
//
// Created by Oskar Kwaśniewski on 21/12/2023.
// Copyright © 2023 Facebook. All rights reserved.
//

import SwiftUI

@main
struct NavTestApp: App {
@UIApplicationDelegateAdaptor var delegate: AppDelegate

var body: some Scene {
WindowGroup {
Text("Hey")
}
}
}
28 changes: 28 additions & 0 deletions packages/rn-tester/RNTester-visionOS/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AppDelegate.swift
// RNTester-visionOS
//
// Created by Oskar Kwaśniewski on 21/12/2023.
// Copyright © 2023 Facebook. All rights reserved.
//

import Foundation
import UIKit
import React
import React_RCTAppDelegate

class AppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
private var bridge: RCTBridge?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Do magic
print("application did finish launching")
return true
}

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
sceneConfig.delegateClass = SceneDelegate.self
return sceneConfig
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// ReactRootViewRepresentable.swift
// RNTester-visionOS
//
// Created by Oskar Kwaśniewski on 21/12/2023.
// Copyright © 2023 Facebook. All rights reserved.
//

import SwiftUI
import React

struct ReactRootViewRepresentable: UIViewRepresentable {
var bridge: RCTBridge
var moduleName: String

func updateUIView(_ uiView: UIViewType, context: Context) {
// Do nothing
}

func makeUIView(context: Context) -> some UIView {
let rootView = RCTRootView(bridge: bridge, moduleName: moduleName, initialProperties: nil)

return rootView
}
}
24 changes: 24 additions & 0 deletions packages/rn-tester/RNTester-visionOS/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// SceneDelegate.swift
// RNTester-visionOS
//
// Created by Oskar Kwaśniewski on 21/12/2023.
// Copyright © 2023 Facebook. All rights reserved.
//

import Foundation
import UIKit

class SceneDelegate: NSObject, UIWindowSceneDelegate {
func sceneWillEnterForeground(_ scene: UIScene) {
// ...
}

func sceneDidBecomeActive(_ scene: UIScene) {
// ...
}

func sceneWillResignActive(_ scene: UIScene) {
// ...
}
}
28 changes: 18 additions & 10 deletions packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
5C60EB1C226440DB0018C04F /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C60EB1B226440DB0018C04F /* AppDelegate.mm */; };
763DC37D2B0F824400D2C0C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 763DC37C2B0F824400D2C0C5 /* Assets.xcassets */; };
763DC3802B0F824400D2C0C5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 763DC37F2B0F824400D2C0C5 /* Preview Assets.xcassets */; };
763DC3862B0F839A00D2C0C5 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C60EB1B226440DB0018C04F /* AppDelegate.mm */; };
763DC3872B0F839A00D2C0C5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
763DC3882B0F839A00D2C0C5 /* SwiftTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832F45BA2A8A6E1F0097B4E6 /* SwiftTest.swift */; };
763DC38A2B0F83B500D2C0C5 /* FlexibleSizeExampleView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 27F441E81BEBE5030039B79C /* FlexibleSizeExampleView.mm */; };
763DC38B2B0F83B500D2C0C5 /* UpdatePropertiesExampleView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 272E6B3C1BEA849E001FCF37 /* UpdatePropertiesExampleView.mm */; };
76E4BB282B34909800B02A15 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76E4BB272B34909800B02A15 /* App.swift */; };
76E4BB2C2B34932200B02A15 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76E4BB2B2B34932200B02A15 /* AppDelegate.swift */; };
76E4BB2E2B34940500B02A15 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76E4BB2D2B34940500B02A15 /* SceneDelegate.swift */; };
76E4BB302B34950500B02A15 /* ReactRootViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76E4BB2F2B34950500B02A15 /* ReactRootViewRepresentable.swift */; };
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8145AE05241172D900A3F8DA /* LaunchScreen.storyboard */; };
832F45BB2A8A6E1F0097B4E6 /* SwiftTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832F45BA2A8A6E1F0097B4E6 /* SwiftTest.swift */; };
CD10C7A5290BD4EB0033E1ED /* RCTEventEmitterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CD10C7A4290BD4EB0033E1ED /* RCTEventEmitterTests.m */; };
Expand Down Expand Up @@ -108,6 +107,10 @@
763DC37C2B0F824400D2C0C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
763DC37F2B0F824400D2C0C5 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
763DC3812B0F824400D2C0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
76E4BB272B34909800B02A15 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
76E4BB2B2B34932200B02A15 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
76E4BB2D2B34940500B02A15 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
76E4BB2F2B34950500B02A15 /* ReactRootViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactRootViewRepresentable.swift; sourceTree = "<group>"; };
7CDA7A212644C6BB8C0D00D8 /* Pods-RNTesterIntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.release.xcconfig"; path = "Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.release.xcconfig"; sourceTree = "<group>"; };
8145AE05241172D900A3F8DA /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNTester/LaunchScreen.storyboard; sourceTree = "<group>"; };
832F45BA2A8A6E1F0097B4E6 /* SwiftTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SwiftTest.swift; path = RNTester/SwiftTest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -299,6 +302,10 @@
763DC3732B0F824200D2C0C5 /* RNTester-visionOS */ = {
isa = PBXGroup;
children = (
76E4BB2D2B34940500B02A15 /* SceneDelegate.swift */,
76E4BB2B2B34932200B02A15 /* AppDelegate.swift */,
76E4BB272B34909800B02A15 /* App.swift */,
76E4BB2F2B34950500B02A15 /* ReactRootViewRepresentable.swift */,
763DC37C2B0F824400D2C0C5 /* Assets.xcassets */,
763DC3812B0F824400D2C0C5 /* Info.plist */,
763DC37E2B0F824400D2C0C5 /* Preview Content */,
Expand Down Expand Up @@ -885,11 +892,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
763DC38B2B0F83B500D2C0C5 /* UpdatePropertiesExampleView.mm in Sources */,
763DC38A2B0F83B500D2C0C5 /* FlexibleSizeExampleView.mm in Sources */,
763DC3882B0F839A00D2C0C5 /* SwiftTest.swift in Sources */,
763DC3862B0F839A00D2C0C5 /* AppDelegate.mm in Sources */,
763DC3872B0F839A00D2C0C5 /* main.m in Sources */,
76E4BB2C2B34932200B02A15 /* AppDelegate.swift in Sources */,
76E4BB282B34909800B02A15 /* App.swift in Sources */,
76E4BB302B34950500B02A15 /* ReactRootViewRepresentable.swift in Sources */,
76E4BB2E2B34940500B02A15 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1123,6 +1129,7 @@
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/RCTDeprecation/RCTDeprecation-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/RCTFabric/React-RCTFabric-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/RCTTypeSafety/RCTTypeSafety-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React/React-Core-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/ReactCommon/ReactCommon-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_Codegen/React-Codegen-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_Fabric/React-Fabric-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_NativeModulesApple/React-NativeModulesApple-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_RCTAppDelegate/React-RCTAppDelegate-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/SocketRocket/SocketRocket-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/fmt/fmt-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/folly/RCT-Folly-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/glog/glog-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/jsi/React-jsi-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_debug/React-debug-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_renderer_debug/React-rendererdebug-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_renderer_graphics/React-graphics-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_renderer_imagemanager/React-ImageManager-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_utils/React-utils-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/yoga/Yoga-visionOS.modulemap\"";
PRODUCT_BUNDLE_IDENTIFIER = "com.meta.RNTester.localDevelopment.RNTester-visionOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "xros xrsimulator";
Expand Down Expand Up @@ -1220,6 +1227,7 @@
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/RCTDeprecation/RCTDeprecation-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/RCTFabric/React-RCTFabric-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/RCTTypeSafety/RCTTypeSafety-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React/React-Core-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/ReactCommon/ReactCommon-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_Codegen/React-Codegen-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_Fabric/React-Fabric-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_NativeModulesApple/React-NativeModulesApple-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/React_RCTAppDelegate/React-RCTAppDelegate-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/SocketRocket/SocketRocket-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/fmt/fmt-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/folly/RCT-Folly-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/glog/glog-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/jsi/React-jsi-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_debug/React-debug-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_renderer_debug/React-rendererdebug-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_renderer_graphics/React-graphics-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_renderer_imagemanager/React-ImageManager-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/react_utils/React-utils-visionOS.modulemap\" -Xcc -fmodule-map-file=\"${PODS_ROOT}/Headers/Public/yoga/Yoga-visionOS.modulemap\"";
PRODUCT_BUNDLE_IDENTIFIER = "com.meta.RNTester.localDevelopment.RNTester-visionOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "xros xrsimulator";
Expand Down

0 comments on commit 32260e7

Please sign in to comment.