Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
testDemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyh
testDemo
Commits
e4ab1ed9
Commit
e4ab1ed9
authored
Dec 25, 2025
by
jiangyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持ios端
parent
cf79f399
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
365 additions
and
59 deletions
+365
-59
build.gradle.kts
composeApp/build.gradle.kts
+9
-5
Platform.ios.kt
.../iosArm64Main/kotlin/com/example/testdemo/Platform.ios.kt
+1
-1
App_ios.kt
...oseApp/src/iosMain/kotlin/com/example/testdemo/App_ios.kt
+3
-0
MainViewController.kt
...iosMain/kotlin/com/example/testdemo/MainViewController.kt
+14
-2
Platform.ios.kt
...atorArm64Main/kotlin/com/example/testdemo/Platform.ios.kt
+9
-0
gradle.properties
gradle.properties
+1
-1
Config.xcconfig
iosApp/Configuration/Config.xcconfig
+2
-1
project.pbxproj
iosApp/iosApp.xcodeproj/project.pbxproj
+79
-33
ComposeApp
iosApp/iosApp/ComposeApp.framework/ComposeApp
+0
-0
ComposeApp.h
iosApp/iosApp/ComposeApp.framework/Headers/ComposeApp.h
+200
-0
Info.plist
iosApp/iosApp/ComposeApp.framework/Info.plist
+31
-0
module.modulemap
iosApp/iosApp/ComposeApp.framework/Modules/module.modulemap
+8
-0
ContentView.swift
iosApp/iosApp/ContentView.swift
+8
-16
No files found.
composeApp/build.gradle.kts
View file @
e4ab1ed9
...
...
@@ -15,8 +15,6 @@ kotlin {
ohosArm64
{
binaries
{
sharedLib
{
// 注意:这里的 baseName 必须与你 publish 任务中引用的文件名对应
// 如果你 publish 任务里写的是 libkn.so,这里 baseName 应该是 "kn"
baseName
=
"kn"
}
}
...
...
@@ -33,6 +31,15 @@ kotlin {
}
sourceSets
{
val
commonMain
by
getting
val
iosMain
by
creating
{
dependsOn
(
commonMain
)
}
val
iosSimulatorArm64Main
by
getting
{
dependsOn
(
iosMain
)
}
androidMain
.
dependencies
{
implementation
(
libs
.
androidx
.
activity
.
compose
)
implementation
(
project
(
":lib-arith"
))
...
...
@@ -42,9 +49,6 @@ kotlin {
commonTest
.
dependencies
{
implementation
(
libs
.
kotlin
.
test
)
}
val
ohosArm64Main
by
getting
{
dependsOn
(
commonMain
.
get
())
}
}
}
...
...
composeApp/src/iosMain/kotlin/com/example/testdemo/Platform.ios.kt
→
composeApp/src/ios
Arm64
Main/kotlin/com/example/testdemo/Platform.ios.kt
View file @
e4ab1ed9
...
...
@@ -2,7 +2,7 @@ package com.example.testdemo
import
platform.UIKit.UIDevice
class
IOSPlatform
:
Platform
{
class
IOSPlatform
:
Platform
{
override
val
name
:
String
=
UIDevice
.
currentDevice
.
systemName
()
+
" "
+
UIDevice
.
currentDevice
.
systemVersion
}
...
...
composeApp/src/iosMain/kotlin/com/example/testdemo/App_ios.kt
0 → 100644
View file @
e4ab1ed9
package
com.example.testdemo
fun
appInfoForIos
():
String
=
appInfo
()
composeApp/src/iosMain/kotlin/com/example/testdemo/MainViewController.kt
View file @
e4ab1ed9
@file
:
OptIn
(
kotlinx
.
cinterop
.
ExperimentalForeignApi
::
class
)
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
()
}
\ No newline at end of file
fun
MainViewController
():
UIViewController
{
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
composeApp/src/iosSimulatorArm64Main/kotlin/com/example/testdemo/Platform.ios.kt
0 → 100644
View file @
e4ab1ed9
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
gradle.properties
View file @
e4ab1ed9
...
...
@@ -12,5 +12,5 @@ android.nonTransitiveRClass=true
android.useAndroidX
=
true
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
\ No newline at end of file
iosApp/Configuration/Config.xcconfig
View file @
e4ab1ed9
...
...
@@ -5,3 +5,4 @@ PRODUCT_BUNDLE_IDENTIFIER=com.example.testdemo.TestDemo$(TEAM_ID)
CURRENT_PROJECT_VERSION=1
MARKETING_VERSION=1.0
FRAMEWORK_SEARCH_PATHS = $(inherited) $(SRCROOT)/../composeApp/build/bin/iosSimulatorArm64/debugFramework $(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(PLATFORM_NAME)
\ No newline at end of file
iosApp/iosApp.xcodeproj/project.pbxproj
View file @
e4ab1ed9
...
...
@@ -6,8 +6,22 @@
objectVersion
=
77
;
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 */
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 */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
...
...
@@ -20,20 +34,34 @@
};
/* 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 */
A9C270782B7F20D80BDB8EF7
/* Configuration */
=
{
isa
=
PBXFileSystemSynchronizedRootGroup
;
path
=
Configuration
;
sourceTree
=
"<group>"
;
};
DBB6A45A75CE30E8D898B97C
/* iosApp */
=
{
isa
=
PBXFileSystemSynchronizedRootGroup
;
exceptions
=
(
BDD43DEBB46AE8B613E12CE8
/* Exceptions for "iosApp" folder in "iosApp" target */
,
C3BDEF052EFD07FA009E7973
/* Exceptions for "iosApp" folder in "Embed Frameworks" phase from "iosApp" target */
,
);
path
=
iosApp
;
sourceTree
=
"<group>"
;
};
A9C270782B7F20D80BDB8EF7
/* Configuration */
=
{
isa
=
PBXFileSystemSynchronizedRootGroup
;
path
=
Configuration
;
sourceTree
=
"<group>"
;
};
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -52,6 +80,7 @@
children
=
(
A9C270782B7F20D80BDB8EF7
/* Configuration */
,
DBB6A45A75CE30E8D898B97C
/* iosApp */
,
C30D7A882EFD056000BCA3E2
/* Frameworks */
,
434BB2BEBAAD1EF3344B36DA
/* Products */
,
);
sourceTree
=
"<group>"
;
...
...
@@ -64,6 +93,14 @@
name
=
Products
;
sourceTree
=
"<group>"
;
};
C30D7A882EFD056000BCA3E2
/* Frameworks */
=
{
isa
=
PBXGroup
;
children
=
(
C30D7A892EFD056000BCA3E2
/* ComposeApp */
,
);
name
=
Frameworks
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
...
...
@@ -75,6 +112,7 @@
3083BBDCEBD76F70C9A00F86
/* Sources */
,
E1AA503124D45A9B74D81F7D
/* Frameworks */
,
6408C3101CC6A32331304200
/* Resources */
,
C3BDEF042EFD07FA009E7973
/* Embed Frameworks */
,
);
buildRules
=
(
);
...
...
@@ -167,6 +205,38 @@
/* End PBXSourcesBuildPhase 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 */
=
{
isa
=
XCBuildConfiguration
;
baseConfigurationReferenceAnchor
=
A9C270782B7F20D80BDB8EF7
/* Configuration */
;
...
...
@@ -290,7 +360,7 @@
};
name
=
Release
;
};
07528D70979D286CF9833559
/* Debug
*/
=
{
D598E5DA5A52E5DDA852D7E0
/* Release
*/
=
{
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ARCHS
=
arm64
;
...
...
@@ -301,34 +371,10 @@
DEVELOPMENT_ASSET_PATHS
=
"\"iosApp/Preview Content\""
;
DEVELOPMENT_TEAM
=
"${TEAM_ID}"
;
ENABLE_PREVIEWS
=
YES
;
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
=
(
FRAMEWORK_SEARCH_PATHS
=
(
"$(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
;
INFOPLIST_FILE
=
iosApp/Info.plist
;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation
=
YES
;
...
...
iosApp/iosApp/ComposeApp.framework/ComposeApp
0 → 100644
View file @
e4ab1ed9
File added
iosApp/iosApp/ComposeApp.framework/Headers/ComposeApp.h
0 → 100644
View file @
e4ab1ed9
#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
iosApp/iosApp/ComposeApp.framework/Info.plist
0 → 100644
View file @
e4ab1ed9
<
?xml
v
e
rsion="
1
.
0
"
e
n
c
o
d
ing="UT
F
-
8
"?
>
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
<
string
>
ComposeApp
<
/string
>
<
k
e
y
>
CFBundleIdentifier
<
/k
e
y
>
<
string
>
com.example.testdemo.ComposeApp
<
/string
>
<
k
e
y
>
CFBundleInfoDictionaryVersion
<
/k
e
y
>
<
string
>
6.0
<
/string
>
<
k
e
y
>
CFBundleName
<
/k
e
y
>
<
string
>
ComposeApp
<
/string
>
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.0
<
/string
>
<
k
e
y
>
CFBundleSupportedPlatforms
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
iPhoneSimulator
<
/string
>
<
/
a
rr
a
y
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
string
>
1
<
/string
>
<
k
e
y
>
MinimumOSVersion
<
/k
e
y
>
<
string
>
14.0
<
/string
>
<
k
e
y
>
UIDeviceFamily
<
/k
e
y
>
<
a
rr
a
y
>
<
int
e
g
e
r
>
1
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
/
a
rr
a
y
>
<
/
d
i
c
t
>
<
/plist
>
\ No newline at end of file
iosApp/iosApp/ComposeApp.framework/Modules/module.modulemap
0 → 100644
View file @
e4ab1ed9
framework module "ComposeApp" {
umbrella header "ComposeApp.h"
export *
module * { export * }
use Foundation
}
iosApp/iosApp/ContentView.swift
View file @
e4ab1ed9
import
UIKit
import
SwiftUI
import
ComposeApp
struct
ComposeView
:
UIViewControllerRepresentable
{
func
makeUIViewController
(
context
:
Context
)
->
UIViewController
{
MainViewControllerKt
.
MainViewController
()
}
func
updateUIViewController
(
_
uiViewController
:
UIViewController
,
context
:
Context
)
{}
}
import
ComposeApp
// 对应 KMP 导出的 Framework 名
struct
ContentView
:
View
{
var
body
:
some
View
{
ComposeView
()
.
ignoresSafeArea
()
VStack
{
// 调用你刚修改的 appInfo()
Text
(
AppKt
.
appInfo
())
.
multilineTextAlignment
(
.
center
)
.
padding
()
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment