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.
This commit is contained in:
Kirill Shmakov
2019-04-17 18:54:45 +03:00
parent b70ff30dc3
commit e774f3fe77
2 changed files with 69 additions and 73 deletions
@@ -56,6 +56,7 @@ class KotlinGradleMobileMultiplatformModuleBuilder :
val androidMain = src.createKotlinSampleFileWriter(mainSourceName, jvmTargetName, languageName = "java") val androidMain = src.createKotlinSampleFileWriter(mainSourceName, jvmTargetName, languageName = "java")
val androidTest = src.createKotlinSampleFileWriter(mainTestName, languageName = "java", fileName = "SampleTestsAndroid.kt") 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 androidLocalProperties = rootDir.createChildData(this, "local.properties").bufferedWriter()
val androidRoot = src.findChild(mainSourceName)!! val androidRoot = src.findChild(mainSourceName)!!
val androidManifest = androidRoot.createChildData(this, "AndroidManifest.xml").bufferedWriter() val androidManifest = androidRoot.createChildData(this, "AndroidManifest.xml").bufferedWriter()
@@ -69,6 +70,8 @@ class KotlinGradleMobileMultiplatformModuleBuilder :
val nativeMain = src.createKotlinSampleFileWriter(nativeSourceName, nativeTargetName) val nativeMain = src.createKotlinSampleFileWriter(nativeSourceName, nativeTargetName)
val nativeTest = src.createKotlinSampleFileWriter(nativeTestName, fileName = "SampleTestsIOS.kt") val nativeTest = src.createKotlinSampleFileWriter(nativeTestName, fileName = "SampleTestsIOS.kt")
val xcodeConfigurator = XcodeProjectConfigurator()
try { try {
commonMain.write( commonMain.write(
""" """
@@ -269,14 +272,18 @@ sdk.dir=PleaseSpecifyAndroidSdkPathHere
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
""".trimIndent() """.trimIndent()
) )
appInfo.write(xcodeConfigurator.templatePlist("""<key>CFBundlePackageType</key>
<string>FMWK</string>"""))
} finally { } finally {
listOf( listOf(
commonMain, commonTest, androidMain, androidTest, nativeMain, nativeTest, commonMain, commonTest, androidMain, androidTest, nativeMain, nativeTest, appInfo,
androidLocalProperties, androidManifest, androidStrings, androidStyles, androidActivityMain androidLocalProperties, androidManifest, androidStrings, androidStyles, androidActivityMain
).forEach(BufferedWriter::close) ).forEach(BufferedWriter::close)
} }
XcodeProjectConfigurator().createSkeleton(rootDir) xcodeConfigurator.createSkeleton(rootDir)
} }
@@ -14,6 +14,30 @@ class XcodeProjectConfigurator {
private val mppDirName = "app" private val mppDirName = "app"
fun templatePlist(varyingProperties: String = ""): String {
return """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>${'$'}(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>${'$'}(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>${'$'}(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${'$'}(PRODUCT_NAME)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
${varyingProperties.trimIndent().prependIndent("\t")}
</dict>
</plist>"""
}
fun createSkeleton(rootDir: VirtualFile) { fun createSkeleton(rootDir: VirtualFile) {
val iosDir = rootDir.createChildDirectory(this, "iosApp") val iosDir = rootDir.createChildDirectory(this, "iosApp")
val sourceDir = iosDir.createChildDirectory(this, "iosApp") val sourceDir = iosDir.createChildDirectory(this, "iosApp")
@@ -85,81 +109,44 @@ class ViewController: UIViewController {
} }
""".trimIndent() """.trimIndent()
) )
testInfo.write( testInfo.write(
""" templatePlist(
<?xml version="1.0" encoding="UTF-8"?> """<key>CFBundlePackageType</key>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"> <string>BNDL</string>"""
<plist version="1.0"> )
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>${'$'}(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>${'$'}(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>${'$'}(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${'$'}(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
""".trimIndent()
) )
sourceInfo.write( sourceInfo.write(
""" templatePlist(
<?xml version="1.0" encoding="UTF-8"?> """<key>CFBundlePackageType</key>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"> <string>APPL</string>
<plist version="1.0"> <key>LSRequiresIPhoneOS</key>
<dict> <true/>
<key>CFBundleDevelopmentRegion</key> <key>UILaunchStoryboardName</key>
<string>${'$'}(DEVELOPMENT_LANGUAGE)</string> <string>LaunchScreen</string>
<key>CFBundleExecutable</key> <key>UIMainStoryboardFile</key>
<string>${'$'}(EXECUTABLE_NAME)</string> <string>Main</string>
<key>CFBundleIdentifier</key> <key>UIRequiredDeviceCapabilities</key>
<string>${'$'}(PRODUCT_BUNDLE_IDENTIFIER)</string> <array>
<key>CFBundleInfoDictionaryVersion</key> <string>armv7</string>
<string>6.0</string> </array>
<key>CFBundleName</key> <key>UISupportedInterfaceOrientations</key>
<string>${'$'}(PRODUCT_NAME)</string> <array>
<key>CFBundlePackageType</key> <string>UIInterfaceOrientationPortrait</string>
<string>APPL</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<key>CFBundleShortVersionString</key> <string>UIInterfaceOrientationLandscapeRight</string>
<string>1.0</string> </array>
<key>CFBundleVersion</key> <key>UISupportedInterfaceOrientations~ipad</key>
<string>1</string> <array>
<key>LSRequiresIPhoneOS</key> <string>UIInterfaceOrientationPortrait</string>
<true/> <string>UIInterfaceOrientationPortraitUpsideDown</string>
<key>UILaunchStoryboardName</key> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>LaunchScreen</string> <string>UIInterfaceOrientationLandscapeRight</string>
<key>UIMainStoryboardFile</key> </array>"""
<string>Main</string> )
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
""".trimIndent()
) )
launchScreen.write( launchScreen.write(
""" """
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
@@ -761,6 +748,7 @@ class ViewController: UIViewController {
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "${'$'}(SRCROOT)/../$mppDirName/Info.plist";
INSTALL_PATH = "${'$'}(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "${'$'}(LOCAL_LIBRARY_DIR)/Frameworks";
KOTLIN_BUILD_TYPE = DEBUG; KOTLIN_BUILD_TYPE = DEBUG;
KOTLIN_TARGET = ""; KOTLIN_TARGET = "";
@@ -792,6 +780,7 @@ class ViewController: UIViewController {
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "${'$'}(SRCROOT)/../$mppDirName/Info.plist";
INSTALL_PATH = "${'$'}(LOCAL_LIBRARY_DIR)/Frameworks"; INSTALL_PATH = "${'$'}(LOCAL_LIBRARY_DIR)/Frameworks";
KOTLIN_BUILD_TYPE = RELEASE; KOTLIN_BUILD_TYPE = RELEASE;
KOTLIN_TARGET = ""; KOTLIN_TARGET = "";