diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 2c3f518..ba71c7d 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -13,6 +13,13 @@ 27CD0B552AFC8D38003665EB /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27CD0B542AFC8D38003665EB /* Preview Assets.xcassets */; }; 27CD0B5D2AFC8DA7003665EB /* OpenGraph in Frameworks */ = {isa = PBXBuildFile; productRef = 27CD0B5C2AFC8DA7003665EB /* OpenGraph */; }; 27CD0B5F2AFC8DA7003665EB /* OpenSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 27CD0B5E2AFC8DA7003665EB /* OpenSwiftUI */; }; + 27D49DFB2BA604FB00F6E2E2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D49DFA2BA604FB00F6E2E2 /* AppDelegate.swift */; }; + 27D49DFD2BA604FB00F6E2E2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D49DFC2BA604FB00F6E2E2 /* SceneDelegate.swift */; }; + 27D49DFF2BA604FB00F6E2E2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D49DFE2BA604FB00F6E2E2 /* ViewController.swift */; }; + 27D49E022BA604FB00F6E2E2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27D49E002BA604FB00F6E2E2 /* Main.storyboard */; }; + 27D49E042BA604FC00F6E2E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27D49E032BA604FC00F6E2E2 /* Assets.xcassets */; }; + 27D49E072BA604FC00F6E2E2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27D49E052BA604FC00F6E2E2 /* LaunchScreen.storyboard */; }; + 27D49E0E2BA60AF600F6E2E2 /* OpenSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 27D49E0D2BA60AF600F6E2E2 /* OpenSwiftUI */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -23,6 +30,14 @@ 27CD0B522AFC8D38003665EB /* Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Example.entitlements; sourceTree = ""; }; 27CD0B542AFC8D38003665EB /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 27CD0B612AFC8E0E003665EB /* OpenSwiftUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = OpenSwiftUI; path = ..; sourceTree = ""; }; + 27D49DF82BA604FB00F6E2E2 /* HostingExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HostingExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 27D49DFA2BA604FB00F6E2E2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 27D49DFC2BA604FB00F6E2E2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 27D49DFE2BA604FB00F6E2E2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 27D49E012BA604FB00F6E2E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 27D49E032BA604FC00F6E2E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 27D49E062BA604FC00F6E2E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 27D49E082BA604FC00F6E2E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,6 +50,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 27D49DF52BA604FB00F6E2E2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 27D49E0E2BA60AF600F6E2E2 /* OpenSwiftUI in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -43,7 +66,9 @@ children = ( 27CD0B612AFC8E0E003665EB /* OpenSwiftUI */, 27CD0B4B2AFC8D37003665EB /* Example */, + 27D49DF92BA604FB00F6E2E2 /* HostingExample */, 27CD0B4A2AFC8D37003665EB /* Products */, + 27D49E0C2BA60AF600F6E2E2 /* Frameworks */, ); sourceTree = ""; }; @@ -51,6 +76,7 @@ isa = PBXGroup; children = ( 27CD0B492AFC8D37003665EB /* Example.app */, + 27D49DF82BA604FB00F6E2E2 /* HostingExample.app */, ); name = Products; sourceTree = ""; @@ -75,6 +101,27 @@ path = "Preview Content"; sourceTree = ""; }; + 27D49DF92BA604FB00F6E2E2 /* HostingExample */ = { + isa = PBXGroup; + children = ( + 27D49DFA2BA604FB00F6E2E2 /* AppDelegate.swift */, + 27D49DFC2BA604FB00F6E2E2 /* SceneDelegate.swift */, + 27D49DFE2BA604FB00F6E2E2 /* ViewController.swift */, + 27D49E002BA604FB00F6E2E2 /* Main.storyboard */, + 27D49E032BA604FC00F6E2E2 /* Assets.xcassets */, + 27D49E052BA604FC00F6E2E2 /* LaunchScreen.storyboard */, + 27D49E082BA604FC00F6E2E2 /* Info.plist */, + ); + path = HostingExample; + sourceTree = ""; + }; + 27D49E0C2BA60AF600F6E2E2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -99,6 +146,26 @@ productReference = 27CD0B492AFC8D37003665EB /* Example.app */; productType = "com.apple.product-type.application"; }; + 27D49DF72BA604FB00F6E2E2 /* HostingExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 27D49E092BA604FC00F6E2E2 /* Build configuration list for PBXNativeTarget "HostingExample" */; + buildPhases = ( + 27D49DF42BA604FB00F6E2E2 /* Sources */, + 27D49DF52BA604FB00F6E2E2 /* Frameworks */, + 27D49DF62BA604FB00F6E2E2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HostingExample; + packageProductDependencies = ( + 27D49E0D2BA60AF600F6E2E2 /* OpenSwiftUI */, + ); + productName = HostingExample; + productReference = 27D49DF82BA604FB00F6E2E2 /* HostingExample.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -106,12 +173,15 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1500; + LastSwiftUpdateCheck = 1520; LastUpgradeCheck = 1500; TargetAttributes = { 27CD0B482AFC8D37003665EB = { CreatedOnToolsVersion = 15.0; }; + 27D49DF72BA604FB00F6E2E2 = { + CreatedOnToolsVersion = 15.2; + }; }; }; buildConfigurationList = 27CD0B442AFC8D37003665EB /* Build configuration list for PBXProject "Example" */; @@ -130,6 +200,7 @@ projectRoot = ""; targets = ( 27CD0B482AFC8D37003665EB /* Example */, + 27D49DF72BA604FB00F6E2E2 /* HostingExample */, ); }; /* End PBXProject section */ @@ -144,6 +215,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 27D49DF62BA604FB00F6E2E2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27D49E072BA604FC00F6E2E2 /* LaunchScreen.storyboard in Resources */, + 27D49E042BA604FC00F6E2E2 /* Assets.xcassets in Resources */, + 27D49E022BA604FB00F6E2E2 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -156,8 +237,37 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 27D49DF42BA604FB00F6E2E2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27D49DFF2BA604FB00F6E2E2 /* ViewController.swift in Sources */, + 27D49DFB2BA604FB00F6E2E2 /* AppDelegate.swift in Sources */, + 27D49DFD2BA604FB00F6E2E2 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXVariantGroup section */ + 27D49E002BA604FB00F6E2E2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 27D49E012BA604FB00F6E2E2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 27D49E052BA604FC00F6E2E2 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 27D49E062BA604FC00F6E2E2 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 27CD0B562AFC8D38003665EB /* Debug */ = { isa = XCBuildConfiguration; @@ -349,6 +459,67 @@ }; name = Release; }; + 27D49E0A2BA604FC00F6E2E2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = VB7MJ8R223; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = HostingExample/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.HostingExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 27D49E0B2BA604FC00F6E2E2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = VB7MJ8R223; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = HostingExample/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = top.kyleye.HostingExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -370,6 +541,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 27D49E092BA604FC00F6E2E2 /* Build configuration list for PBXNativeTarget "HostingExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27D49E0A2BA604FC00F6E2E2 /* Debug */, + 27D49E0B2BA604FC00F6E2E2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ @@ -381,6 +561,10 @@ isa = XCSwiftPackageProductDependency; productName = OpenSwiftUI; }; + 27D49E0D2BA60AF600F6E2E2 /* OpenSwiftUI */ = { + isa = XCSwiftPackageProductDependency; + productName = OpenSwiftUI; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 27CD0B412AFC8D37003665EB /* Project object */; diff --git a/Example/HostingExample/AppDelegate.swift b/Example/HostingExample/AppDelegate.swift new file mode 100644 index 0000000..923734c --- /dev/null +++ b/Example/HostingExample/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// HostingExample +// +// Created by Kyle on 2024/3/17. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, 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. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // 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. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Example/HostingExample/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/HostingExample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Example/HostingExample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/HostingExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/HostingExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/Example/HostingExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/HostingExample/Assets.xcassets/Contents.json b/Example/HostingExample/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Example/HostingExample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/HostingExample/Base.lproj/LaunchScreen.storyboard b/Example/HostingExample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Example/HostingExample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/HostingExample/Base.lproj/Main.storyboard b/Example/HostingExample/Base.lproj/Main.storyboard new file mode 100644 index 0000000..25a7638 --- /dev/null +++ b/Example/HostingExample/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/HostingExample/Info.plist b/Example/HostingExample/Info.plist new file mode 100644 index 0000000..dd3c9af --- /dev/null +++ b/Example/HostingExample/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/Example/HostingExample/SceneDelegate.swift b/Example/HostingExample/SceneDelegate.swift new file mode 100644 index 0000000..b0d206b --- /dev/null +++ b/Example/HostingExample/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// HostingExample +// +// Created by Kyle on 2024/3/17. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + 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 necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + 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. + } + + 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). + } + + 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. + } + + 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. + } + + +} + diff --git a/Example/HostingExample/ViewController.swift b/Example/HostingExample/ViewController.swift new file mode 100644 index 0000000..4fc07d2 --- /dev/null +++ b/Example/HostingExample/ViewController.swift @@ -0,0 +1,32 @@ +// +// ViewController.swift +// HostingExample +// +// Created by Kyle on 2024/3/17. +// + +import UIKit +#if !OEPNSWIFTUI +import SwiftUI +#else +import OpenSwiftUI +#endif + +class ViewController: UINavigationController { + override func viewDidAppear(_ animated: Bool) { + let vc = UIHostingController(rootView: ContentView()) + pushViewController(vc, animated: false) + } +} + +struct ContentView: UIViewRepresentable { + func makeUIView(context: Context) -> UIView { + let view = UIView() + view.backgroundColor = .red + return view + } + + func updateUIView(_ uiView: UIView, context: Context) { + print("Update UIView") + } +}