From a1e20f8d2abc40ae419c1d8b3ede09f25dd8f2df Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Thu, 18 Apr 2019 21:14:12 +0700 Subject: [PATCH] Add tests for CocoaPods integration --- .../jetbrains/kotlin/gradle/CocoaPodsIT.kt | 213 +++++++++++ .../testProject/new-mpp-cocoapods/.gitignore | 8 + .../new-mpp-cocoapods/build.gradle.kts | 0 .../new-mpp-cocoapods/ios-app/Podfile | 8 + .../ios-app/ios-app.xcodeproj/project.pbxproj | 341 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../ios-app/ios-app/AppDelegate.swift | 34 ++ .../AppIcon.appiconset/Contents.json | 98 +++++ .../ios-app/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../ios-app/Base.lproj/Main.storyboard | 24 ++ .../ios-app/ios-app/Info.plist | 45 +++ .../ios-app/ios-app/ViewController.swift | 10 + .../kotlin-library/build.gradle.kts | 26 ++ .../kotlin-library/src/iosMain/kotlin/A.kt | 5 + .../pod_dependency/pod_dependency.podspec | 11 + .../pod_dependency/src/foo.h | 3 + .../pod_dependency/src/foo.m | 5 + .../new-mpp-cocoapods/settings.gradle | 13 + 20 files changed, 890 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CocoaPodsIT.kt create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/.gitignore create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/Podfile create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/AppDelegate.swift create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Info.plist create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/ViewController.swift create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/src/iosMain/kotlin/A.kt create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/pod_dependency.podspec create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.h create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.m create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/settings.gradle diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CocoaPodsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CocoaPodsIT.kt new file mode 100644 index 00000000000..d135f13e35c --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CocoaPodsIT.kt @@ -0,0 +1,213 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.gradle + +import org.jetbrains.kotlin.gradle.util.modify +import org.jetbrains.kotlin.konan.target.HostManager +import org.junit.Assume.assumeTrue +import org.junit.Test +import java.io.File +import java.util.concurrent.TimeUnit +import kotlin.test.assertEquals +import kotlin.test.fail + +class CocoaPodsIT : BaseGradleIT() { + + // We use Kotlin DSL. Earlier Gradle versions fail at accessors codegen. + val gradleVersion = GradleVersionRequired.AtLeast("4.9") + + val PODFILE_IMPORT_DIRECTIVE_PLACEHOLDER = "" + + @Test + fun testPodspec() { + assumeTrue(HostManager.hostIsMac) + val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods", gradleVersion) + + // Check that the podspec task fails if there is no Gradle wrapper in the project. + gradleProject.build(":kotlin-library:podspec") { + assertFailed() + assertContains("The Gradle wrapper is required to run the build from Xcode.") + assertContains("Please run the same command with `-Pkotlin.native.cocoapods.generate.wrapper=true` " + + "or run the `:wrapper` task to generate the wrapper manually.") + } + + // Check that we can generate the wrapper along with the podspec if the corresponding property specified + gradleProject.build(":kotlin-library:podspec", "-Pkotlin.native.cocoapods.generate.wrapper=true") { + assertSuccessful() + assertTasksExecuted(":kotlin-library:podspec", ":wrapper") + assertFileExists("gradlew") + + // Check that the podspec file is correctly generated. + val podspecFileName = "kotlin-library/kotlin_library.podspec" + val expectedPodspecContent = """ + Pod::Spec.new do |spec| + 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.authors = '' + spec.license = '' + spec.summary = 'CocoaPods test library' + + spec.static_framework = true + spec.vendored_frameworks = "build/cocoapods/framework/#{spec.name}.framework" + spec.libraries = "c++" + spec.module_name = "#{spec.name}_umbrella" + + spec.dependency 'pod_dependency', '1.0' + + spec.pod_target_xcconfig = { + 'KOTLIN_TARGET[sdk=iphonesimulator*]' => 'ios_x64', + 'KOTLIN_TARGET[sdk=iphoneos*]' => 'ios_arm', + 'KOTLIN_TARGET[sdk=macosx*]' => 'macos_x64' + } + + spec.script_phases = [ + { + :name => 'Build kotlin_library', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + set -ev + REPO_ROOT="${'$'}PODS_TARGET_SRCROOT" + "${'$'}REPO_ROOT/../gradlew" -p "${'$'}REPO_ROOT" :kotlin-library:syncFramework \ + -Pkotlin.native.cocoapods.target=${'$'}KOTLIN_TARGET \ + -Pkotlin.native.cocoapods.configuration=${'$'}CONFIGURATION \ + -Pkotlin.native.cocoapods.cflags="${'$'}OTHER_CFLAGS" \ + -Pkotlin.native.cocoapods.paths.headers="${'$'}HEADER_SEARCH_PATHS" \ + -Pkotlin.native.cocoapods.paths.frameworks="${'$'}FRAMEWORK_SEARCH_PATHS" + SCRIPT + } + ] + end + """.trimIndent() + + assertFileExists(podspecFileName) + assertEquals(expectedPodspecContent, fileInWorkingDir(podspecFileName).readText()) + } + } + + @Test + fun testInterop() { + assumeTrue(HostManager.hostIsMac) + val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods", gradleVersion) + with(gradleProject) { + // Check that a project with CocoaPods interop fails to be built from command line. + build(":kotlin-library:build") { + assertFailed() + // TODO: Test message for KT-31062. + } + + // Check that a project without CocoaPods interop can be built from command line. + gradleBuildScript("kotlin-library").modify { + it.replace("""pod("pod_dependency", "1.0")""", "") + } + projectDir.resolve("kotlin-library/src/iosMain/kotlin/A.kt").modify { + it.replace("import cocoapods.pod_dependency.*", "").replace("println(foo())", "") + } + build(":kotlin-library:linkReleaseFrameworkIOS") { + assertSuccessful() + } + } + } + + private enum class ImportMode(val directive: String) { + FRAMEWORKS("use_frameworks!"), + MODULAR_HEADERS("use_modular_headers!") + } + + private data class CommandResult( + val exitCode: Int, + val stdOut: String, + val stdErr: String + ) + + private fun runCommand( + workingDir: File, + command: String, + vararg args: String, + timeoutSec: Long = 120, + inheritIO: Boolean = false, + block: CommandResult.() -> Unit + ) { + val process = ProcessBuilder(command, *args).apply { + directory(workingDir) + if (inheritIO) { + inheritIO() + } + }.start() + + val isFinished = process.waitFor(timeoutSec, TimeUnit.SECONDS) + val stdOut = process.inputStream.bufferedReader().use { it.readText() } + val stdErr = process.errorStream.bufferedReader().use { it.readText() } + + if (!isFinished) { + process.destroyForcibly() + println("Stdout:\n$stdOut") + println("Stderr:\n$stdErr") + fail("Command '$command ${args.joinToString(" ")}' killed by timeout.".trimIndent()) + } + CommandResult(process.exitValue(), stdOut, stdErr).block() + } + + private fun doTestXcode(mode: ImportMode) { + assumeTrue(HostManager.hostIsMac) + val gradleProject = transformProjectWithPluginsDsl("new-mpp-cocoapods", gradleVersion) + + with(gradleProject) { + // Generate podspec. + gradleProject.build(":kotlin-library:podspec", "-Pkotlin.native.cocoapods.generate.wrapper=true") { + assertSuccessful() + } + + val iosAppDir = projectDir.resolve("ios-app") + + // Set import mode for Podfile. + iosAppDir.resolve("Podfile").modify { + it.replace(PODFILE_IMPORT_DIRECTIVE_PLACEHOLDER, mode.directive) + } + + // Install pods. + runCommand(iosAppDir, "pod", "install") { + assertEquals(0, exitCode, """ + |Exit code mismatch for `pod install`. + |stdout: + |$stdOut + | + |stderr: + |$stdErr + """.trimMargin() + ) + } + + // Run Xcode build. + runCommand(iosAppDir, "xcodebuild", + "-sdk", "iphonesimulator", + "-arch", "arm64", + "-configuration", "Release", + "-workspace", "ios-app.xcworkspace", + "-scheme", "ios-app", + inheritIO = true // Xcode doesn't finish the process if the PIPE redirect is used. + ) { + assertEquals(0, exitCode, """ + |Exit code mismatch for `xcodebuild`. + |stdout: + |$stdOut + | + |stderr: + |$stdErr + """.trimMargin() + ) + } + } + } + + @Test + fun testXcodeUseFrameworks() = doTestXcode(ImportMode.FRAMEWORKS) + + @Test + fun testXcodeUseModularHeaders() = doTestXcode(ImportMode.MODULAR_HEADERS) +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/.gitignore b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/.gitignore new file mode 100644 index 00000000000..6492779ad8b --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/.gitignore @@ -0,0 +1,8 @@ +ios-app/Pods +Podfile.lock +kotlin-library/kotlin_library.podspec +ios-app/ios-app.xcodeproj/xcuserdata +ios-app/ios-app.xcworkspace/xcuserdata +ios-app/ios-app.xcodeproj/project.xcworkspace/xcuserdata +ios-app/ios-app.xcworkspace/contents.xcworkspacedata +ios-app/ios-app.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/build.gradle.kts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/Podfile b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/Podfile new file mode 100644 index 00000000000..b7975e73bf9 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/Podfile @@ -0,0 +1,8 @@ + + +platform :ios, '9.0' + +target 'ios-app' do + pod 'pod_dependency', :path => '../pod_dependency' + pod 'kotlin_library', :path => '../kotlin-library' +end \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..3bf1d8a690a --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj @@ -0,0 +1,341 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 2C4835762268863D00C928E6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C4835752268863D00C928E6 /* AppDelegate.swift */; }; + 2C4835782268863D00C928E6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C4835772268863D00C928E6 /* ViewController.swift */; }; + 2C48357B2268863D00C928E6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2C4835792268863D00C928E6 /* Main.storyboard */; }; + 2C48357D2268863E00C928E6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2C48357C2268863E00C928E6 /* Assets.xcassets */; }; + 2C4835802268863E00C928E6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2C48357E2268863E00C928E6 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2C4835722268863D00C928E6 /* ios-app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-app.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2C4835752268863D00C928E6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 2C4835772268863D00C928E6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 2C48357A2268863D00C928E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 2C48357C2268863E00C928E6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 2C48357F2268863E00C928E6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 2C4835812268863E00C928E6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2C48356F2268863D00C928E6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2C4835692268863D00C928E6 = { + isa = PBXGroup; + children = ( + 2C4835742268863D00C928E6 /* ios-app */, + 2C4835732268863D00C928E6 /* Products */, + ); + sourceTree = ""; + }; + 2C4835732268863D00C928E6 /* Products */ = { + isa = PBXGroup; + children = ( + 2C4835722268863D00C928E6 /* ios-app.app */, + ); + name = Products; + sourceTree = ""; + }; + 2C4835742268863D00C928E6 /* ios-app */ = { + isa = PBXGroup; + children = ( + 2C4835752268863D00C928E6 /* AppDelegate.swift */, + 2C4835772268863D00C928E6 /* ViewController.swift */, + 2C4835792268863D00C928E6 /* Main.storyboard */, + 2C48357C2268863E00C928E6 /* Assets.xcassets */, + 2C48357E2268863E00C928E6 /* LaunchScreen.storyboard */, + 2C4835812268863E00C928E6 /* Info.plist */, + ); + path = "ios-app"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2C4835712268863D00C928E6 /* ios-app */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2C4835842268863E00C928E6 /* Build configuration list for PBXNativeTarget "ios-app" */; + buildPhases = ( + 2C48356E2268863D00C928E6 /* Sources */, + 2C48356F2268863D00C928E6 /* Frameworks */, + 2C4835702268863D00C928E6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ios-app"; + productName = "ios-app"; + productReference = 2C4835722268863D00C928E6 /* ios-app.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2C48356A2268863D00C928E6 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1020; + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = jetbrains; + TargetAttributes = { + 2C4835712268863D00C928E6 = { + CreatedOnToolsVersion = 10.2; + }; + }; + }; + buildConfigurationList = 2C48356D2268863D00C928E6 /* Build configuration list for PBXProject "ios-app" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 2C4835692268863D00C928E6; + productRefGroup = 2C4835732268863D00C928E6 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2C4835712268863D00C928E6 /* ios-app */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2C4835702268863D00C928E6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C4835802268863E00C928E6 /* LaunchScreen.storyboard in Resources */, + 2C48357D2268863E00C928E6 /* Assets.xcassets in Resources */, + 2C48357B2268863D00C928E6 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2C48356E2268863D00C928E6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C4835782268863D00C928E6 /* ViewController.swift in Sources */, + 2C4835762268863D00C928E6 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 2C4835792268863D00C928E6 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2C48357A2268863D00C928E6 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 2C48357E2268863E00C928E6 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2C48357F2268863E00C928E6 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2C4835822268863E00C928E6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 2C4835832268863E00C928E6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2C4835852268863E00C928E6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "ios-app/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.konan.ios-app"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 2C4835862268863E00C928E6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "ios-app/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.konan.ios-app"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2C48356D2268863D00C928E6 /* Build configuration list for PBXProject "ios-app" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2C4835822268863E00C928E6 /* Debug */, + 2C4835832268863E00C928E6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2C4835842268863E00C928E6 /* Build configuration list for PBXNativeTarget "ios-app" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2C4835852268863E00C928E6 /* Debug */, + 2C4835862268863E00C928E6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2C48356A2268863D00C928E6 /* Project object */; +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..136ada05267 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000000..18d981003d6 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/AppDelegate.swift b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/AppDelegate.swift new file mode 100644 index 00000000000..f02afea65bf --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/AppDelegate.swift @@ -0,0 +1,34 @@ +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..d8db8d65fd7 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000000..bfa36129419 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..f1bcf38400d --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Info.plist b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Info.plist new file mode 100644 index 00000000000..16be3b68112 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/ViewController.swift b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/ViewController.swift new file mode 100644 index 00000000000..c72b3fbd710 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/ios-app/ios-app/ViewController.swift @@ -0,0 +1,10 @@ +import UIKit +import kotlin_library + +class ViewController: UIViewController { + override func viewDidLoad() { + super.viewDidLoad() + AKt.bar() + // Do any additional setup after loading the view. + } +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/build.gradle.kts new file mode 100644 index 00000000000..eb73ced1357 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + id("org.jetbrains.kotlin.multiplatform").version("") + id("org.jetbrains.kotlin.native.cocoapods").version("") +} + +group = "com.example" +version = "1.0" + +repositories { + mavenLocal() + jcenter() + maven { setUrl("https://dl.bintray.com/kotlin/kotlinx.html/") } +} + +group = "org.jetbrains.kotlin.sample.native" +version = "1.0" + +kotlin { + iosX64("iOS") + + cocoapods { + summary = "CocoaPods test library" + homepage = "https://github.com/JetBrains/kotlin" + pod("pod_dependency", "1.0") + } +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/src/iosMain/kotlin/A.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/src/iosMain/kotlin/A.kt new file mode 100644 index 00000000000..1893d664598 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/kotlin-library/src/iosMain/kotlin/A.kt @@ -0,0 +1,5 @@ +import cocoapods.pod_dependency.* + +fun bar() { + println(foo()) +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/pod_dependency.podspec b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/pod_dependency.podspec new file mode 100644 index 00000000000..e1f4ce85ff6 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/pod_dependency.podspec @@ -0,0 +1,11 @@ +Pod::Spec.new do |spec| + spec.name = 'pod_dependency' + spec.version = '1.0' + spec.homepage = 'foo' + spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } + spec.authors = '' + spec.license = '' + spec.summary = 'foo' + spec.source_files = 'src/*' + spec.public_header_files = 'src/*.h' +end \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.h b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.h new file mode 100644 index 00000000000..77feebff9db --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.h @@ -0,0 +1,3 @@ +#import + +NSString* foo(void); \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.m b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.m new file mode 100644 index 00000000000..5912a3d87b6 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/pod_dependency/src/foo.m @@ -0,0 +1,5 @@ +#include "foo.h" + +NSString* foo() { + return @"Foo"; +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/settings.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/settings.gradle new file mode 100644 index 00000000000..b916b75776b --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-cocoapods/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + mavenLocal() + jcenter() + gradlePluginPortal() + } +} + +enableFeaturePreview('GRADLE_METADATA') + +// We move the actual library in a subproject to test accessing gradle wrapper from Xcode. +rootProject.name = "cocoapods" +include 'kotlin-library' \ No newline at end of file