优化配置,修复 demo bug
1,network 框架完善 2,websocket 机制完善 3,设计文档整理到架构文档 4,脚本,配置完善
This commit is contained in:
@@ -217,6 +217,117 @@ with open(path, 'w') as f:
|
||||
f.write(content)
|
||||
PY
|
||||
|
||||
# ---- Step 3.5: 修正 podspec swift_version ----
|
||||
# flutter create 默认生成 swift_version = '5.0',统一改为项目标准 6.2
|
||||
for podspec in \
|
||||
"$PKG_DIR/ios/${PKG_NAME}.podspec" \
|
||||
"$PKG_DIR/macos/${PKG_NAME}.podspec"; do
|
||||
if [[ -f "$podspec" ]]; then
|
||||
sed -i '' "s/s.swift_version = '5.0'/s.swift_version = '6.2'/" "$podspec"
|
||||
fi
|
||||
done
|
||||
|
||||
# Flutter SDK 尚未完整标注 Swift 6 并发属性,用 @preconcurrency import 将
|
||||
# FlutterMethodNotImplemented 等全局变量的并发警告降级,避免编译失败。
|
||||
# 注意:不在类上加 @MainActor,否则与 FlutterPlugin 协议的 nonisolated 要求冲突,
|
||||
# 导致 ConformanceIsolation 编译错误。
|
||||
for swift_file in \
|
||||
"$PKG_DIR/ios/Classes/${PASCAL_NAME}SdkPlugin.swift" \
|
||||
"$PKG_DIR/macos/Classes/${PASCAL_NAME}SdkPlugin.swift"; do
|
||||
if [[ -f "$swift_file" ]]; then
|
||||
sed -i '' \
|
||||
's/^import Flutter$/@preconcurrency import Flutter/' \
|
||||
"$swift_file"
|
||||
fi
|
||||
done
|
||||
|
||||
# ---- Step 3.6: 替换 Android build.gradle → build.gradle.kts(Kotlin DSL + Compose) ----
|
||||
# flutter create 默认生成 Groovy build.gradle,统一替换为 Kotlin DSL
|
||||
ANDROID_DIR="$PKG_DIR/android"
|
||||
[[ -f "$ANDROID_DIR/build.gradle" ]] && rm "$ANDROID_DIR/build.gradle"
|
||||
|
||||
cat > "$ANDROID_DIR/build.gradle.kts" << GRADLE_EOF
|
||||
group = "com.example.${PKG_NAME}"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
buildscript {
|
||||
val kotlinVersion = "2.2.20"
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:8.11.1")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:\$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
// 若该 SDK 需要 Compose,取消注释下面两行,并在 dependencies 中加 compose runtime
|
||||
// id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.${PKG_NAME}"
|
||||
compileSdk = 36
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("main") { java.srcDirs("src/main/kotlin") }
|
||||
getByName("test") { java.srcDirs("src/test/kotlin") }
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
}
|
||||
|
||||
// 若该 SDK 需要 Compose,取消注释
|
||||
// buildFeatures { compose = true }
|
||||
|
||||
testOptions {
|
||||
unitTests {
|
||||
isIncludeAndroidResources = true
|
||||
all {
|
||||
it.useJUnitPlatform()
|
||||
it.outputs.upToDateWhen { false }
|
||||
it.testLogging {
|
||||
events("passed", "skipped", "failed", "standardOut", "standardError")
|
||||
showStandardStreams = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// 若该 SDK 需要 Compose,取消注释以下两行并按需引入具体组件:
|
||||
// val composeBom = platform("androidx.compose:compose-bom:2025.05.01")
|
||||
// implementation(composeBom)
|
||||
// implementation("androidx.compose.runtime:runtime")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.mockito:mockito-core:5.0.0")
|
||||
}
|
||||
GRADLE_EOF
|
||||
|
||||
# ---- Step 4: IDE 配置 ----
|
||||
echo "[4/5] Updating IDE config..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user