Commit e4ab1ed9 authored by jiangyh's avatar jiangyh

支持ios端

parent cf79f399
...@@ -15,8 +15,6 @@ kotlin { ...@@ -15,8 +15,6 @@ kotlin {
ohosArm64 { ohosArm64 {
binaries { binaries {
sharedLib { sharedLib {
// 注意:这里的 baseName 必须与你 publish 任务中引用的文件名对应
// 如果你 publish 任务里写的是 libkn.so,这里 baseName 应该是 "kn"
baseName = "kn" baseName = "kn"
} }
} }
...@@ -33,6 +31,15 @@ kotlin { ...@@ -33,6 +31,15 @@ kotlin {
} }
sourceSets { sourceSets {
val commonMain by getting
val iosMain by creating {
dependsOn(commonMain)
}
val iosSimulatorArm64Main by getting {
dependsOn(iosMain)
}
androidMain.dependencies { androidMain.dependencies {
implementation(libs.androidx.activity.compose) implementation(libs.androidx.activity.compose)
implementation(project(":lib-arith")) implementation(project(":lib-arith"))
...@@ -42,9 +49,6 @@ kotlin { ...@@ -42,9 +49,6 @@ kotlin {
commonTest.dependencies { commonTest.dependencies {
implementation(libs.kotlin.test) implementation(libs.kotlin.test)
} }
val ohosArm64Main by getting {
dependsOn(commonMain.get())
}
} }
} }
......
...@@ -2,7 +2,7 @@ package com.example.testdemo ...@@ -2,7 +2,7 @@ package com.example.testdemo
import platform.UIKit.UIDevice import platform.UIKit.UIDevice
class IOSPlatform: Platform { class IOSPlatform : Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
} }
......
package com.example.testdemo
fun appInfoForIos(): String = appInfo()
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
package com.example.testdemo package com.example.testdemo
import androidx.compose.ui.window.ComposeUIViewController import platform.UIKit.UIViewController
import platform.UIKit.UIScreen
import platform.UIKit.UILabel
import platform.UIKit.NSTextAlignmentCenter
fun MainViewController() = ComposeUIViewController { App() } fun MainViewController(): UIViewController {
\ No newline at end of file val vc = UIViewController()
val label = UILabel(frame = UIScreen.mainScreen.bounds)
label.text = appInfo()
label.textAlignment = NSTextAlignmentCenter
label.numberOfLines = 0
vc.view.addSubview(label)
return vc
}
\ No newline at end of file
package com.example.testdemo
import platform.UIKit.UIDevice
class IOSPlatform : Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
actual fun getPlatform(): Platform = IOSPlatform()
\ No newline at end of file
...@@ -12,5 +12,5 @@ android.nonTransitiveRClass=true ...@@ -12,5 +12,5 @@ android.nonTransitiveRClass=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.java.home=/Users/jiangyuhuan/zulu-17.jdk/Contents/Home org.gradle.java.home=/Users/jiangyuhuan/zulu-17.jdk/Contents/Home
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true # kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.mpp.applyDefaultHierarchyTemplate=false kotlin.mpp.applyDefaultHierarchyTemplate=false
\ No newline at end of file
...@@ -4,4 +4,5 @@ PRODUCT_NAME=TestDemo ...@@ -4,4 +4,5 @@ PRODUCT_NAME=TestDemo
PRODUCT_BUNDLE_IDENTIFIER=com.example.testdemo.TestDemo$(TEAM_ID) PRODUCT_BUNDLE_IDENTIFIER=com.example.testdemo.TestDemo$(TEAM_ID)
CURRENT_PROJECT_VERSION=1 CURRENT_PROJECT_VERSION=1
MARKETING_VERSION=1.0 MARKETING_VERSION=1.0
\ No newline at end of file FRAMEWORK_SEARCH_PATHS = $(inherited) $(SRCROOT)/../composeApp/build/bin/iosSimulatorArm64/debugFramework $(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(PLATFORM_NAME)
\ No newline at end of file
...@@ -6,8 +6,22 @@ ...@@ -6,8 +6,22 @@
objectVersion = 77; objectVersion = 77;
objects = { objects = {
/* Begin PBXCopyFilesBuildPhase section */
C3BDEF042EFD07FA009E7973 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
A97A87862563B6DF27204162 /* TestDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; A97A87862563B6DF27204162 /* TestDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
C30D7A892EFD056000BCA3E2 /* ComposeApp */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = ComposeApp; path = "../composeApp/build/xcode-frameworks/Debug/iphonesimulator18.2/ComposeApp.framework/ComposeApp"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ /* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
...@@ -20,20 +34,34 @@ ...@@ -20,20 +34,34 @@
}; };
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ /* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */
C3BDEF052EFD07FA009E7973 /* Exceptions for "iosApp" folder in "Embed Frameworks" phase from "iosApp" target */ = {
isa = PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet;
attributesByRelativePath = {
ComposeApp.framework = (CodeSignOnCopy, RemoveHeadersOnCopy, );
};
buildPhase = C3BDEF042EFD07FA009E7973 /* Embed Frameworks */;
membershipExceptions = (
ComposeApp.framework,
);
};
/* End PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */ /* Begin PBXFileSystemSynchronizedRootGroup section */
A9C270782B7F20D80BDB8EF7 /* Configuration */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = Configuration;
sourceTree = "<group>";
};
DBB6A45A75CE30E8D898B97C /* iosApp */ = { DBB6A45A75CE30E8D898B97C /* iosApp */ = {
isa = PBXFileSystemSynchronizedRootGroup; isa = PBXFileSystemSynchronizedRootGroup;
exceptions = ( exceptions = (
BDD43DEBB46AE8B613E12CE8 /* Exceptions for "iosApp" folder in "iosApp" target */, BDD43DEBB46AE8B613E12CE8 /* Exceptions for "iosApp" folder in "iosApp" target */,
C3BDEF052EFD07FA009E7973 /* Exceptions for "iosApp" folder in "Embed Frameworks" phase from "iosApp" target */,
); );
path = iosApp; path = iosApp;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
A9C270782B7F20D80BDB8EF7 /* Configuration */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = Configuration;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */ /* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -52,6 +80,7 @@ ...@@ -52,6 +80,7 @@
children = ( children = (
A9C270782B7F20D80BDB8EF7 /* Configuration */, A9C270782B7F20D80BDB8EF7 /* Configuration */,
DBB6A45A75CE30E8D898B97C /* iosApp */, DBB6A45A75CE30E8D898B97C /* iosApp */,
C30D7A882EFD056000BCA3E2 /* Frameworks */,
434BB2BEBAAD1EF3344B36DA /* Products */, 434BB2BEBAAD1EF3344B36DA /* Products */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -64,6 +93,14 @@ ...@@ -64,6 +93,14 @@
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
C30D7A882EFD056000BCA3E2 /* Frameworks */ = {
isa = PBXGroup;
children = (
C30D7A892EFD056000BCA3E2 /* ComposeApp */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
...@@ -75,6 +112,7 @@ ...@@ -75,6 +112,7 @@
3083BBDCEBD76F70C9A00F86 /* Sources */, 3083BBDCEBD76F70C9A00F86 /* Sources */,
E1AA503124D45A9B74D81F7D /* Frameworks */, E1AA503124D45A9B74D81F7D /* Frameworks */,
6408C3101CC6A32331304200 /* Resources */, 6408C3101CC6A32331304200 /* Resources */,
C3BDEF042EFD07FA009E7973 /* Embed Frameworks */,
); );
buildRules = ( buildRules = (
); );
...@@ -167,6 +205,38 @@ ...@@ -167,6 +205,38 @@
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
07528D70979D286CF9833559 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/iosApp",
);
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iosApp/Info.plist;
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",
);
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
1F0D5DFC7C12EB75BA76AA72 /* Debug */ = { 1F0D5DFC7C12EB75BA76AA72 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReferenceAnchor = A9C270782B7F20D80BDB8EF7 /* Configuration */; baseConfigurationReferenceAnchor = A9C270782B7F20D80BDB8EF7 /* Configuration */;
...@@ -290,7 +360,7 @@ ...@@ -290,7 +360,7 @@
}; };
name = Release; name = Release;
}; };
07528D70979D286CF9833559 /* Debug */ = { D598E5DA5A52E5DDA852D7E0 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = arm64; ARCHS = arm64;
...@@ -301,34 +371,10 @@ ...@@ -301,34 +371,10 @@
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}"; DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; FRAMEWORK_SEARCH_PATHS = (
INFOPLIST_FILE = iosApp/Info.plist;
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)", "$(inherited)",
"@executable_path/Frameworks", "$(PROJECT_DIR)/iosApp",
); );
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
D598E5DA5A52E5DDA852D7E0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = iosApp/Info.plist; INFOPLIST_FILE = iosApp/Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
...@@ -370,4 +416,4 @@ ...@@ -370,4 +416,4 @@
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };
rootObject = 9C08729B8B60D436CD0ABF8B /* Project object */; rootObject = 9C08729B8B60D436CD0ABF8B /* Project object */;
} }
\ No newline at end of file
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSError.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
@class UIViewController;
@protocol ComposeAppPlatform;
NS_ASSUME_NONNULL_BEGIN
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wincompatible-property-type"
#pragma clang diagnostic ignored "-Wnullability"
#pragma push_macro("_Nullable_result")
#if !__has_feature(nullability_nullable_result)
#undef _Nullable_result
#define _Nullable_result _Nullable
#endif
__attribute__((swift_name("KotlinBase")))
@interface ComposeAppBase : NSObject
- (instancetype)init __attribute__((unavailable));
+ (instancetype)new __attribute__((unavailable));
+ (void)initialize __attribute__((objc_requires_super));
@end
@interface ComposeAppBase (ComposeAppBaseCopying) <NSCopying>
@end
__attribute__((swift_name("KotlinMutableSet")))
@interface ComposeAppMutableSet<ObjectType> : NSMutableSet<ObjectType>
@end
__attribute__((swift_name("KotlinMutableDictionary")))
@interface ComposeAppMutableDictionary<KeyType, ObjectType> : NSMutableDictionary<KeyType, ObjectType>
@end
@interface NSError (NSErrorComposeAppKotlinException)
@property (readonly) id _Nullable kotlinException;
@end
__attribute__((swift_name("KotlinNumber")))
@interface ComposeAppNumber : NSNumber
- (instancetype)initWithChar:(char)value __attribute__((unavailable));
- (instancetype)initWithUnsignedChar:(unsigned char)value __attribute__((unavailable));
- (instancetype)initWithShort:(short)value __attribute__((unavailable));
- (instancetype)initWithUnsignedShort:(unsigned short)value __attribute__((unavailable));
- (instancetype)initWithInt:(int)value __attribute__((unavailable));
- (instancetype)initWithUnsignedInt:(unsigned int)value __attribute__((unavailable));
- (instancetype)initWithLong:(long)value __attribute__((unavailable));
- (instancetype)initWithUnsignedLong:(unsigned long)value __attribute__((unavailable));
- (instancetype)initWithLongLong:(long long)value __attribute__((unavailable));
- (instancetype)initWithUnsignedLongLong:(unsigned long long)value __attribute__((unavailable));
- (instancetype)initWithFloat:(float)value __attribute__((unavailable));
- (instancetype)initWithDouble:(double)value __attribute__((unavailable));
- (instancetype)initWithBool:(BOOL)value __attribute__((unavailable));
- (instancetype)initWithInteger:(NSInteger)value __attribute__((unavailable));
- (instancetype)initWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable));
+ (instancetype)numberWithChar:(char)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedChar:(unsigned char)value __attribute__((unavailable));
+ (instancetype)numberWithShort:(short)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedShort:(unsigned short)value __attribute__((unavailable));
+ (instancetype)numberWithInt:(int)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedInt:(unsigned int)value __attribute__((unavailable));
+ (instancetype)numberWithLong:(long)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedLong:(unsigned long)value __attribute__((unavailable));
+ (instancetype)numberWithLongLong:(long long)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedLongLong:(unsigned long long)value __attribute__((unavailable));
+ (instancetype)numberWithFloat:(float)value __attribute__((unavailable));
+ (instancetype)numberWithDouble:(double)value __attribute__((unavailable));
+ (instancetype)numberWithBool:(BOOL)value __attribute__((unavailable));
+ (instancetype)numberWithInteger:(NSInteger)value __attribute__((unavailable));
+ (instancetype)numberWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable));
@end
__attribute__((swift_name("KotlinByte")))
@interface ComposeAppByte : ComposeAppNumber
- (instancetype)initWithChar:(char)value;
+ (instancetype)numberWithChar:(char)value;
@end
__attribute__((swift_name("KotlinUByte")))
@interface ComposeAppUByte : ComposeAppNumber
- (instancetype)initWithUnsignedChar:(unsigned char)value;
+ (instancetype)numberWithUnsignedChar:(unsigned char)value;
@end
__attribute__((swift_name("KotlinShort")))
@interface ComposeAppShort : ComposeAppNumber
- (instancetype)initWithShort:(short)value;
+ (instancetype)numberWithShort:(short)value;
@end
__attribute__((swift_name("KotlinUShort")))
@interface ComposeAppUShort : ComposeAppNumber
- (instancetype)initWithUnsignedShort:(unsigned short)value;
+ (instancetype)numberWithUnsignedShort:(unsigned short)value;
@end
__attribute__((swift_name("KotlinInt")))
@interface ComposeAppInt : ComposeAppNumber
- (instancetype)initWithInt:(int)value;
+ (instancetype)numberWithInt:(int)value;
@end
__attribute__((swift_name("KotlinUInt")))
@interface ComposeAppUInt : ComposeAppNumber
- (instancetype)initWithUnsignedInt:(unsigned int)value;
+ (instancetype)numberWithUnsignedInt:(unsigned int)value;
@end
__attribute__((swift_name("KotlinLong")))
@interface ComposeAppLong : ComposeAppNumber
- (instancetype)initWithLongLong:(long long)value;
+ (instancetype)numberWithLongLong:(long long)value;
@end
__attribute__((swift_name("KotlinULong")))
@interface ComposeAppULong : ComposeAppNumber
- (instancetype)initWithUnsignedLongLong:(unsigned long long)value;
+ (instancetype)numberWithUnsignedLongLong:(unsigned long long)value;
@end
__attribute__((swift_name("KotlinFloat")))
@interface ComposeAppFloat : ComposeAppNumber
- (instancetype)initWithFloat:(float)value;
+ (instancetype)numberWithFloat:(float)value;
@end
__attribute__((swift_name("KotlinDouble")))
@interface ComposeAppDouble : ComposeAppNumber
- (instancetype)initWithDouble:(double)value;
+ (instancetype)numberWithDouble:(double)value;
@end
__attribute__((swift_name("KotlinBoolean")))
@interface ComposeAppBoolean : ComposeAppNumber
- (instancetype)initWithBool:(BOOL)value;
+ (instancetype)numberWithBool:(BOOL)value;
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Greeting")))
@interface ComposeAppGreeting : ComposeAppBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (NSString *)greet __attribute__((swift_name("greet()")));
@end
__attribute__((swift_name("Platform")))
@protocol ComposeAppPlatform
@required
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("IOSPlatform")))
@interface ComposeAppIOSPlatform : ComposeAppBase <ComposeAppPlatform>
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
@property (readonly) NSString *name __attribute__((swift_name("name")));
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("AppKt")))
@interface ComposeAppAppKt : ComposeAppBase
/**
* 跨平台共享逻辑函数
* 它调用了期望函数 getPlatform(),并根据不同平台的实现返回对应的文字
*/
+ (NSString *)appInfo __attribute__((swift_name("appInfo()")));
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("App_iosKt")))
@interface ComposeAppApp_iosKt : ComposeAppBase
+ (NSString *)appInfoForIos __attribute__((swift_name("appInfoForIos()")));
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("MainViewControllerKt")))
@interface ComposeAppMainViewControllerKt : ComposeAppBase
+ (UIViewController *)MainViewController __attribute__((swift_name("MainViewController()")));
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("Platform_iosKt")))
@interface ComposeAppPlatform_iosKt : ComposeAppBase
+ (id<ComposeAppPlatform>)getPlatform __attribute__((swift_name("getPlatform()")));
@end
#pragma pop_macro("_Nullable_result")
#pragma clang diagnostic pop
NS_ASSUME_NONNULL_END
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>ComposeApp</string>
<key>CFBundleIdentifier</key>
<string>com.example.testdemo.ComposeApp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>ComposeApp</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneSimulator</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>MinimumOSVersion</key>
<string>14.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
</dict>
</plist>
\ No newline at end of file
framework module "ComposeApp" {
umbrella header "ComposeApp.h"
export *
module * { export * }
use Foundation
}
import UIKit
import SwiftUI import SwiftUI
import ComposeApp import ComposeApp // 对应 KMP 导出的 Framework 名
struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
struct ContentView: View { struct ContentView: View {
var body: some View { var body: some View {
ComposeView() VStack {
.ignoresSafeArea() // 调用你刚修改的 appInfo()
Text(AppKt.appInfo())
.multilineTextAlignment(.center)
.padding()
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment