From d51ad29b3af71d705de7afb1aad89bd23737d0bb Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 10 Nov 2020 01:56:18 +0100 Subject: [PATCH] Setup iOS platform correctly --- EpcQrCode/build.gradle.kts | 56 ++++++++++--------- .../EpcQrCodeiOSApp.xcodeproj/project.pbxproj | 8 ++- .../EpcQrCodeiOSApp/ContentView.swift | 4 +- EpcQrCodeiOSApp/EpcQrCodeiOSApp/Info.plist | 2 +- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/EpcQrCode/build.gradle.kts b/EpcQrCode/build.gradle.kts index 791bc79..ab73da9 100644 --- a/EpcQrCode/build.gradle.kts +++ b/EpcQrCode/build.gradle.kts @@ -11,6 +11,15 @@ kotlin { kotlinOptions.jvmTarget = "1.8" } } + + ios { + binaries { + framework { + baseName = "EpcQrCode" + } + } + } + js { browser { testTask { @@ -21,6 +30,12 @@ kotlin { } } } + js("nodeJs") { + nodejs { + + } + } + val hostOs = System.getProperty("os.name") val isMingwX64 = hostOs.startsWith("Windows") val nativeTarget = when { @@ -30,26 +45,7 @@ kotlin { else -> throw GradleException("Host OS is not supported in Kotlin/Native.") } - - js("nodeJs") { - nodejs { - - } - } - iosArm64 { - binaries { - framework { - baseName = "EpcQrCode" - } - } - } - iosX64 { - binaries { - framework { - baseName = "EpcQrCode" - } - } - } + sourceSets { val commonMain by getting val commonTest by getting { @@ -58,32 +54,38 @@ kotlin { implementation(kotlin("test-annotations-common")) } } + val jvmMain by getting val jvmTest by getting { dependencies { implementation(kotlin("test-junit")) } } + + val iosMain by getting + val iosTest by getting + val jsMain by getting val jsTest by getting { dependencies { implementation(kotlin("test-js")) } } - val nativeMain by getting - val nativeTest by getting val nodeJsMain by getting val nodeJsTest by getting - val iosArm64Main by getting - val iosArm64Test by getting - val iosX64Main by getting - val iosX64Test by getting + + val nativeMain by getting + val nativeTest by getting + } } + val packForXcode by tasks.creating(Sync::class) { group = "build" val mode = System.getenv("CONFIGURATION") ?: "DEBUG" - val framework = kotlin.targets.getByName("iosArm64").binaries.getFramework(mode) + val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator" + val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64" + val framework = kotlin.targets.getByName(targetName).binaries.getFramework(mode) inputs.property("mode", mode) dependsOn(framework.linkTask) val targetDir = File(buildDir, "xcode-frameworks") diff --git a/EpcQrCodeiOSApp/EpcQrCodeiOSApp.xcodeproj/project.pbxproj b/EpcQrCodeiOSApp/EpcQrCodeiOSApp.xcodeproj/project.pbxproj index 85a3b5f..fa6e4d6 100644 --- a/EpcQrCodeiOSApp/EpcQrCodeiOSApp.xcodeproj/project.pbxproj +++ b/EpcQrCodeiOSApp/EpcQrCodeiOSApp.xcodeproj/project.pbxproj @@ -485,6 +485,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"EpcQrCodeiOSApp/Preview Content\""; + DEVELOPMENT_TEAM = 7WVYN7QA7Z; ENABLE_PREVIEWS = YES; FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../EpcQrCode/build/xcode-frameworks"; INFOPLIST_FILE = EpcQrCodeiOSApp/Info.plist; @@ -492,7 +493,8 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.EpcQrCodeiOSApp; + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = net.codinux.banking.epcqrcode.ios; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -505,6 +507,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"EpcQrCodeiOSApp/Preview Content\""; + DEVELOPMENT_TEAM = 7WVYN7QA7Z; ENABLE_PREVIEWS = YES; FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../EpcQrCode/build/xcode-frameworks"; INFOPLIST_FILE = EpcQrCodeiOSApp/Info.plist; @@ -512,7 +515,8 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.EpcQrCodeiOSApp; + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = net.codinux.banking.epcqrcode.ios; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/EpcQrCodeiOSApp/EpcQrCodeiOSApp/ContentView.swift b/EpcQrCodeiOSApp/EpcQrCodeiOSApp/ContentView.swift index dfe33f9..54e91a4 100644 --- a/EpcQrCodeiOSApp/EpcQrCodeiOSApp/ContentView.swift +++ b/EpcQrCodeiOSApp/EpcQrCodeiOSApp/ContentView.swift @@ -1,8 +1,10 @@ import SwiftUI +import EpcQrCode + struct ContentView: View { var body: some View { - Text("Hello, World!") + Text(MppTest().showMessage()) } } diff --git a/EpcQrCodeiOSApp/EpcQrCodeiOSApp/Info.plist b/EpcQrCodeiOSApp/EpcQrCodeiOSApp/Info.plist index 9742bf0..29061fc 100644 --- a/EpcQrCodeiOSApp/EpcQrCodeiOSApp/Info.plist +++ b/EpcQrCodeiOSApp/EpcQrCodeiOSApp/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0 + $(MARKETING_VERSION) CFBundleVersion 1 LSRequiresIPhoneOS