kotlin - 构建iOS框架时使用build.gradle.kts将文件添加到.framework
问题描述
我正在使用 Kotlin 多平台,我想知道在为 iOS 构建时是否可以将一些文件放入 .framwork。以下是我的 build.gradle.kts 文件的一部分:
val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
.getByName<KotlinNativeTarget>("ios")
.binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText("#!/bin/bash\n"
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
+ "cd '${rootProject.rootDir}'\n"
+ "./gradlew \$@\n")
gradlew.setExecutable(true)
}
}
构建后,我将在 build 文件夹下获得 xcode-frameworks。和xcode-frameworks下的xxx.framework。构建时如何将文件放入 xxx.framework?(ps.不是xcode-frameworks下的文件,而是xxx.framework下的一些文件)
解决方案
推荐阅读
- javascript - 多个音频地址对齐项目 HTML
- android - Firebase DataSnapshot getValue 未在初始化主体上设置属性
- oracle - 更新:功能编辑与其他设计
- c++ - 为什么我不能在我的静态函数中访问私有构造函数,如下所示?
- nginx - Kubernetes NGINX Ingress:禁用特定路径的基本身份验证
- javascript - React:当将函数传递给组件的一个实例时,为什么所有其他实例都会受到影响?
- python-3.x - 使用 urlextract 从网站中提取所有 url
- spring-boot - Shiro 中的并发会话控制
- java - 模拟通过 JSON Post 添加用户的控制器
- android - 在 GET 方法中发送 JSON 对象,并在 Android 中使用 Header