From e774f3fe778b5c4f8c621ff997c2aa8f0ba5fbcf Mon Sep 17 00:00:00 2001 From: Kirill Shmakov Date: Wed, 17 Apr 2019 18:54:45 +0300 Subject: [PATCH] Update iOS template for XCode 10.2 Info.plist generated by default does not provide required bundle id key. Added separated Info.plist and its usage is explicitly specified. See KOTLIN-CR-2913. --- ...nGradleMobileMultiplatformModuleBuilder.kt | 11 +- .../xcode/XcodeProjectConfigurator.kt | 131 ++++++++---------- 2 files changed, 69 insertions(+), 73 deletions(-) diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileMultiplatformModuleBuilder.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileMultiplatformModuleBuilder.kt index 9140e723248..11e26e5d9ad 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileMultiplatformModuleBuilder.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileMultiplatformModuleBuilder.kt @@ -56,6 +56,7 @@ class KotlinGradleMobileMultiplatformModuleBuilder : val androidMain = src.createKotlinSampleFileWriter(mainSourceName, jvmTargetName, languageName = "java") val androidTest = src.createKotlinSampleFileWriter(mainTestName, languageName = "java", fileName = "SampleTestsAndroid.kt") + val appInfo = appDir.createChildData(appDir,"Info.plist").bufferedWriter() val androidLocalProperties = rootDir.createChildData(this, "local.properties").bufferedWriter() val androidRoot = src.findChild(mainSourceName)!! val androidManifest = androidRoot.createChildData(this, "AndroidManifest.xml").bufferedWriter() @@ -69,6 +70,8 @@ class KotlinGradleMobileMultiplatformModuleBuilder : val nativeMain = src.createKotlinSampleFileWriter(nativeSourceName, nativeTargetName) val nativeTest = src.createKotlinSampleFileWriter(nativeTestName, fileName = "SampleTestsIOS.kt") + val xcodeConfigurator = XcodeProjectConfigurator() + try { commonMain.write( """ @@ -269,14 +272,18 @@ sdk.dir=PleaseSpecifyAndroidSdkPathHere """.trimIndent() ) + + appInfo.write(xcodeConfigurator.templatePlist("""CFBundlePackageType +FMWK""")) + } finally { listOf( - commonMain, commonTest, androidMain, androidTest, nativeMain, nativeTest, + commonMain, commonTest, androidMain, androidTest, nativeMain, nativeTest, appInfo, androidLocalProperties, androidManifest, androidStrings, androidStyles, androidActivityMain ).forEach(BufferedWriter::close) } - XcodeProjectConfigurator().createSkeleton(rootDir) + xcodeConfigurator.createSkeleton(rootDir) } diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/xcode/XcodeProjectConfigurator.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/xcode/XcodeProjectConfigurator.kt index c62a7e63139..c1c56cc0933 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/xcode/XcodeProjectConfigurator.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/xcode/XcodeProjectConfigurator.kt @@ -14,6 +14,30 @@ class XcodeProjectConfigurator { private val mppDirName = "app" + fun templatePlist(varyingProperties: String = ""): String { + return """ + + + + CFBundleDevelopmentRegion + ${'$'}(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + ${'$'}(EXECUTABLE_NAME) + CFBundleIdentifier + ${'$'}(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${'$'}(PRODUCT_NAME) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 +${varyingProperties.trimIndent().prependIndent("\t")} + +""" + } + fun createSkeleton(rootDir: VirtualFile) { val iosDir = rootDir.createChildDirectory(this, "iosApp") val sourceDir = iosDir.createChildDirectory(this, "iosApp") @@ -85,81 +109,44 @@ class ViewController: UIViewController { } """.trimIndent() ) + testInfo.write( - """ - - - - - CFBundleDevelopmentRegion - ${'$'}(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - ${'$'}(EXECUTABLE_NAME) - CFBundleIdentifier - ${'$'}(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${'$'}(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - - """.trimIndent() + templatePlist( + """CFBundlePackageType +BNDL""" + ) ) + sourceInfo.write( - """ - - - - - 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 - - - - """.trimIndent() + templatePlist( + """CFBundlePackageType +APPL +LSRequiresIPhoneOS + +UILaunchStoryboardName +LaunchScreen +UIMainStoryboardFile +Main +UIRequiredDeviceCapabilities + + armv7 + +UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + +UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight +""" + ) ) + launchScreen.write( """ @@ -761,6 +748,7 @@ class ViewController: UIViewController { DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_BITCODE = NO; + INFOPLIST_FILE = "${'$'}(SRCROOT)/../$mppDirName/Info.plist"; INSTALL_PATH = "${'$'}(LOCAL_LIBRARY_DIR)/Frameworks"; KOTLIN_BUILD_TYPE = DEBUG; KOTLIN_TARGET = ""; @@ -792,6 +780,7 @@ class ViewController: UIViewController { DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_BITCODE = NO; + INFOPLIST_FILE = "${'$'}(SRCROOT)/../$mppDirName/Info.plist"; INSTALL_PATH = "${'$'}(LOCAL_LIBRARY_DIR)/Frameworks"; KOTLIN_BUILD_TYPE = RELEASE; KOTLIN_TARGET = "";