Var*_*rio 6 ios ios-frameworks kotlin bitcode kotlin-multiplatform
我们使用Kotlin在Android和iOS之间共享库.
我们设置了一切,但在iOS上我需要启用Bitcode.经过研究,我找到了解决方案:
kotlin {
targets {
fromPreset(presets.jvm, 'jvm') {
mavenPublication {
artifactId = 'my-lib-name'
}
}
// Switch here to presets.iosArm64 to build library for iPhone device || iosX64 for emulator
fromPreset(presets.iosArm64, 'iOS') {
compilations.main.outputKinds('FRAMEWORK')
compilations.main.extraOpts '-Xembed-bitcode' // for release binaries
compilations.main.extraOpts '-Xembed-bitcode-marker'// for debug binaries
}
}
}
Run Code Online (Sandbox Code Playgroud)
但问题是现在,我有,如果是,我如何在发布和调试二进制文件和特定标志之间分开?我可以简单地添加两个标志没有任何缺点吗?
也许有人可以启发我谢谢
由于适用于 iOS 框架的 Kotlin 1.3.20 位码嵌入开箱即用。如果需要,您还可以手动配置嵌入:
kotlin {
iosArm64("ios") {
binaries {
framework {
// The following embedding modes are available:
// - "marker" - Embed placeholder LLVM IR data as a marker.
// Has the same effect as '-Xembed-bitcode-marker.'
// - "bitcode" - Embed LLVM IR bitcode as data.
// Has the same effect as the '-Xembed-bitcode'.
// - "disable" - Don't embed LLVM IR bitcode.
embedBitcode("marker")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
目前,同一 iOS 目标的所有二进制链接任务都共享编译器和链接器选项,因此无法单独为它们设置选项。请关注KT-26887获取更新。
如果您可以负担使用不同选项运行多个构建,则可以有条件地设置选项并使用标志运行构建:
compilations.main.outputKinds('FRAMEWORK')
if (project.findProperty("releaseFramework") == "true")
compilations.main.extraOpts '-Xembed-bitcode' // for release binaries
else
compilations.main.extraOpts '-Xembed-bitcode-marker'// for debug binaries
Run Code Online (Sandbox Code Playgroud)
然后分别运行带有或不带有标志的构建:
./gradlew linkDebugFrameworkIOS
Run Code Online (Sandbox Code Playgroud)
和
./gradlew linkReleaseFrameworkIOS -PreleaseFramework=true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
362 次 |
| 最近记录: |