Skip to content

Commit

Permalink
Migrate compose to ios integration to UIKit
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Feb 15, 2024
1 parent 9bd9b37 commit 6e48ab0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 49 deletions.
54 changes: 24 additions & 30 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -13,7 +13,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
A93A953729CC810C00F8E227 /* Material 3 gallery.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Material 3 gallery.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A93A953729CC810C00F8E227 /* Material 3 gallery.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Material 3 gallery.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A93A953A29CC810C00F8E227 /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = "<group>"; };
A93A953E29CC810D00F8E227 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A93A954129CC810D00F8E227 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -219,6 +219,8 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "";
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -273,6 +275,8 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "";
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand All @@ -292,26 +296,21 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"${inherited}",
"$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
FRAMEWORK_SEARCH_PATHS = (
"${inherited}",
"$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = (
"${inherited}",
"-framework",
ComposeApp,
);
OTHER_LDFLAGS = (
"${inherited}",
"-framework",
ComposeApp,
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.terrakok.iosApp;
PRODUCT_NAME = "Material 3 gallery";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -329,26 +328,21 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"${inherited}",
"$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
FRAMEWORK_SEARCH_PATHS = (
"${inherited}",
"$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = (
"${inherited}",
"-framework",
ComposeApp,
);
OTHER_LDFLAGS = (
"${inherited}",
"-framework",
ComposeApp,
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.terrakok.iosApp;
PRODUCT_NAME = "Material 3 gallery";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
31 changes: 12 additions & 19 deletions iosApp/iosApp/iosApp.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import UIKit
import SwiftUI
import ComposeApp

@main
struct iosApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

struct ContentView: View {
var body: some View {
ComposeView().ignoresSafeArea(.all)
}
}
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainKt.MainViewController()
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
if let window = window {
window.rootViewController = MainKt.MainViewController()
window.makeKeyAndVisible()
}
return true
}

func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}

0 comments on commit 6e48ab0

Please sign in to comment.