Generate podspec for XCFramework suitable for publishing
#KT-47812 #KT-47633 #KT-43815 #KT-42630 #KT-42105 #KT-48808 Merge-request: KT-MR-4483
This commit is contained in:
committed by
Space
parent
7493914a52
commit
cd9d74b029
+98
-14
@@ -162,7 +162,7 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
fun testPodspecMultiple() = doTestPodspec(
|
||||
cocoapodsMultipleKtPods,
|
||||
mapOf("kotlin-library" to null, "second-library" to null),
|
||||
mapOf("kotlin-library" to kotlinLibraryPodspecContent(), "second-library" to secondLibraryPodspecContent()),
|
||||
mapOf("kotlin-library" to kotlinLibraryPodspecContent(), "second-library" to secondLibraryPodspecContent("second_library")),
|
||||
)
|
||||
|
||||
@Test
|
||||
@@ -324,7 +324,7 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
}.also { writeText(it) }
|
||||
}
|
||||
hooks.addHook {
|
||||
assertContains("Cocoapods Integration requires version of this project to be specified.")
|
||||
assertContains("Cocoapods Integration requires pod version to be specified.")
|
||||
}
|
||||
|
||||
project.build(POD_IMPORT_TASK_NAME, "-Pkotlin.native.cocoapods.generate.wrapper=true") {
|
||||
@@ -863,8 +863,8 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
val framework = fileInWorkingDir("build/cocoapods/framework/cocoapods.framework/cocoapods")
|
||||
with(runProcess(listOf("file", framework.absolutePath), projectDir)) {
|
||||
assertTrue(isSuccessful)
|
||||
assertTrue(output.contains("\\(for architecture armv7\\):\\s+current ar archive random librar".toRegex()))
|
||||
assertTrue(output.contains("\\(for architecture arm64\\):\\s+current ar archive random library".toRegex()))
|
||||
assertTrue(output.contains("\\(for architecture armv7\\):\\s+current ar archive".toRegex()))
|
||||
assertTrue(output.contains("\\(for architecture arm64\\):\\s+current ar archive".toRegex()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,6 +925,60 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
project.testWithWrapper(":compileIosMainKotlinMetadata")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPodPublishing() {
|
||||
hooks.addHook {
|
||||
assertTasksExecuted(":podPublishReleaseXCFramework")
|
||||
assertTasksExecuted(":podPublishDebugXCFramework")
|
||||
assertFileExists("build/cocoapods/publish/release/cocoapods.xcframework")
|
||||
assertFileExists("build/cocoapods/publish/debug/cocoapods.xcframework")
|
||||
assertFileExists("build/cocoapods/publish/release/cocoapods.podspec")
|
||||
assertFileExists("build/cocoapods/publish/debug/cocoapods.podspec")
|
||||
val actualPodspecContentWithoutBlankLines = fileInWorkingDir("build/cocoapods/publish/release/cocoapods.podspec").readText()
|
||||
.lineSequence()
|
||||
.filter { it.isNotBlank() }
|
||||
.joinToString("\n")
|
||||
|
||||
assertEquals(publishPodspecContent, actualPodspecContentWithoutBlankLines)
|
||||
}
|
||||
|
||||
project.testWithWrapper(":podPublishXCFramework")
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testPodPublishingWithCustomProperties() {
|
||||
|
||||
with(project.gradleBuildScript()) {
|
||||
appendToCocoapodsBlock("name = \"CustomPod\"")
|
||||
appendToCocoapodsBlock("version = \"2.0\"")
|
||||
appendToCocoapodsBlock("publishDir = projectDir.resolve(\"CustomPublishDir\")")
|
||||
appendToCocoapodsBlock("license = \"'MIT'\"")
|
||||
appendToCocoapodsBlock("authors = \"{ 'Kotlin Dev' => 'kotlin.dev@jetbrains.com' }\"")
|
||||
appendToCocoapodsBlock("extraSpecAttributes[\"social_media_url\"] = \"'https://twitter.com/kotlin'\"")
|
||||
appendToCocoapodsBlock("extraSpecAttributes[\"vendored_frameworks\"] = \"'CustomFramework.xcframework'\"")
|
||||
appendToCocoapodsBlock("extraSpecAttributes[\"libraries\"] = \"'xml'\"")
|
||||
addPod(defaultPodName)
|
||||
}
|
||||
|
||||
hooks.addHook {
|
||||
assertTasksExecuted(":podPublishReleaseXCFramework")
|
||||
assertTasksExecuted(":podPublishDebugXCFramework")
|
||||
assertFileExists("CustomPublishDir/release/cocoapods.xcframework")
|
||||
assertFileExists("CustomPublishDir/debug/cocoapods.xcframework")
|
||||
assertFileExists("CustomPublishDir/release/CustomPod.podspec")
|
||||
assertFileExists("CustomPublishDir/debug/CustomPod.podspec")
|
||||
val actualPodspecContentWithoutBlankLines = fileInWorkingDir("CustomPublishDir/release/CustomPod.podspec").readText()
|
||||
.lineSequence()
|
||||
.filter { it.isNotBlank() }
|
||||
.joinToString("\n")
|
||||
|
||||
assertEquals(publishPodspecCustomContent, actualPodspecContentWithoutBlankLines)
|
||||
}
|
||||
|
||||
project.testWithWrapper(":podPublishXCFramework")
|
||||
}
|
||||
|
||||
// paths
|
||||
|
||||
private fun CompiledProject.url() = externalSources().resolve("url")
|
||||
@@ -1411,18 +1465,17 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
spec.name = 'kotlin_library'
|
||||
spec.version = '1.0'
|
||||
spec.homepage = 'https://github.com/JetBrains/kotlin'
|
||||
spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
|
||||
spec.source = { :http=> ''}
|
||||
spec.authors = ''
|
||||
spec.license = ''
|
||||
spec.summary = 'CocoaPods test library'
|
||||
spec.vendored_frameworks = "build/cocoapods/framework/${frameworkName ?: "kotlin_library"}.framework"
|
||||
spec.libraries = "c++"
|
||||
spec.module_name = "#{spec.name}_umbrella"
|
||||
spec.vendored_frameworks = 'build/cocoapods/framework/${frameworkName ?: "kotlin_library"}.framework'
|
||||
spec.libraries = 'c++'
|
||||
spec.dependency 'pod_dependency', '1.0'
|
||||
spec.dependency 'subspec_dependency/Core', '1.0'
|
||||
spec.pod_target_xcconfig = {
|
||||
'KOTLIN_PROJECT_PATH' => ':kotlin-library',
|
||||
'PRODUCT_MODULE_NAME' => 'kotlin_library',
|
||||
'PRODUCT_MODULE_NAME' => '${frameworkName ?: "kotlin_library"}',
|
||||
}
|
||||
spec.script_phases = [
|
||||
{
|
||||
@@ -1451,16 +1504,15 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
spec.name = 'second_library'
|
||||
spec.version = '1.0'
|
||||
spec.homepage = 'https://github.com/JetBrains/kotlin'
|
||||
spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
|
||||
spec.source = { :http=> ''}
|
||||
spec.authors = ''
|
||||
spec.license = ''
|
||||
spec.summary = 'CocoaPods test library'
|
||||
spec.vendored_frameworks = "build/cocoapods/framework/${frameworkName ?: "second_library"}.framework"
|
||||
spec.libraries = "c++"
|
||||
spec.module_name = "#{spec.name}_umbrella"
|
||||
spec.vendored_frameworks = 'build/cocoapods/framework/${frameworkName ?: "second_library"}.framework'
|
||||
spec.libraries = 'c++'
|
||||
spec.pod_target_xcconfig = {
|
||||
'KOTLIN_PROJECT_PATH' => ':second-library',
|
||||
'PRODUCT_MODULE_NAME' => 'second_library',
|
||||
'PRODUCT_MODULE_NAME' => '${frameworkName ?: "kotlin_library"}',
|
||||
}
|
||||
spec.script_phases = [
|
||||
{
|
||||
@@ -1484,6 +1536,38 @@ class CocoaPodsIT : BaseGradleIT() {
|
||||
end
|
||||
""".trimIndent()
|
||||
|
||||
private val publishPodspecContent = """
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'cocoapods'
|
||||
spec.version = '1.0'
|
||||
spec.homepage = 'https://github.com/JetBrains/kotlin'
|
||||
spec.source = { :http=> ''}
|
||||
spec.authors = ''
|
||||
spec.license = ''
|
||||
spec.summary = 'CocoaPods test library'
|
||||
spec.vendored_frameworks = 'cocoapods.xcframework'
|
||||
spec.libraries = 'c++'
|
||||
spec.ios.deployment_target = '13.5'
|
||||
end
|
||||
""".trimIndent()
|
||||
|
||||
private val publishPodspecCustomContent = """
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = 'CustomPod'
|
||||
spec.version = '2.0'
|
||||
spec.homepage = 'https://github.com/JetBrains/kotlin'
|
||||
spec.source = { :http=> ''}
|
||||
spec.authors = { 'Kotlin Dev' => 'kotlin.dev@jetbrains.com' }
|
||||
spec.license = 'MIT'
|
||||
spec.summary = 'CocoaPods test library'
|
||||
spec.ios.deployment_target = '13.5'
|
||||
spec.dependency 'AFNetworking'
|
||||
spec.social_media_url = 'https://twitter.com/kotlin'
|
||||
spec.vendored_frameworks = 'CustomFramework.xcframework'
|
||||
spec.libraries = 'xml'
|
||||
end
|
||||
""".trimIndent()
|
||||
|
||||
companion object {
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
|
||||
Reference in New Issue
Block a user