From f241b1104335fb1fd70b0742c4a4419ce3349e8e Mon Sep 17 00:00:00 2001 From: Salvatore Testa Date: Sun, 31 May 2026 23:10:17 -0700 Subject: [PATCH] libpebble3: pure-Kotlin iOS location, drop LibPebbleSwift framework Reimplement IOSLocation in pure Kotlin/Native against platform.CoreLocation (a system framework auto-linked by Kotlin/Native) instead of a hand-built Swift framework. This means iOS consumers of libpebble3 no longer need a separate LibPebbleSwift framework. - Add util/IOSLocation.kt (CoreLocation-backed); wire it into IosSystemGeolocation. - Delete the libpebble-swift Xcode project, the libPebbleSwift cinterop/.def, the buildFrameworkLibPebbleSwift task and BuildSwiftFramework class, and the -framework LibPebbleSwift linkerOpts in libpebble3 and composeApp. Co-Authored-By: Claude Opus 4.8 (1M context) Entire-Checkpoint: 8c532c09afcb --- .gitignore | 2 - composeApp/build.gradle.kts | 7 - libpebble3/build.gradle.kts | 113 +----- .../LibPebbleSwift.xcodeproj/project.pbxproj | 377 ------------------ .../contents.xcworkspacedata | 7 - .../LibPebbleSwift/IOSLocation.h | 19 - .../LibPebbleSwift/IOSLocation.swift | 65 --- .../LibPebbleSwift/LibPebbleSwift.h | 17 - .../libpebblecommon/util/IOSLocation.kt | 59 +++ .../util/IosSystemGeolocation.kt | 2 +- .../nativeInterop/cinterop/libPebbleSwift.def | 3 - 11 files changed, 63 insertions(+), 608 deletions(-) delete mode 100644 libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.pbxproj delete mode 100644 libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.h delete mode 100644 libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.swift delete mode 100644 libpebble3/libpebble-swift/LibPebbleSwift/LibPebbleSwift.h create mode 100644 libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IOSLocation.kt delete mode 100644 libpebble3/src/nativeInterop/cinterop/libPebbleSwift.def diff --git a/.gitignore b/.gitignore index b1d36878c..f24743432 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,6 @@ **.DS_Store /.kotlin **/build/ -/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.xcworkspace/xcuserdata -/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/xcuserdata *.xcodeproj/* !*.xcodeproj/project.pbxproj !*.xcodeproj/xcshareddata/ diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index b07d570c8..fe0a8d577 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -102,12 +102,6 @@ kotlin { framework { baseName = "ComposeApp" linkerOpts("-framework", "Accelerate") - val osName = when (target.name) { - "iosArm64" -> "iphoneos" - "iosX64", "iosSimulatorArm64" -> "iphonesimulator" - else -> error("Unknown target ${target.name}") - } - val dir = project.file("../libpebble3/build/libpebble-swift/$osName") val xcodeExists = providers.exec { isIgnoreExitValue = true commandLine("which", "xcode-select") @@ -117,7 +111,6 @@ kotlin { commandLine("xcode-select", "-p") }.standardOutput.asText.get().trim() linkerOpts( - "-framework", "LibPebbleSwift", "-F"+dir.absolutePath, "-weak_framework", "CoreML", "-L$xcodeDir/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos" ) diff --git a/libpebble3/build.gradle.kts b/libpebble3/build.gradle.kts index b4973f0ff..74aeae7d8 100644 --- a/libpebble3/build.gradle.kts +++ b/libpebble3/build.gradle.kts @@ -55,11 +55,6 @@ android { } } -tasks.register("buildFrameworkLibPebbleSwift", BuildSwiftFramework::class) { - group = "build" - description = "Builds the Swift framework for libpebble-swift" -} - // Non-mac machines cannot build iOS targets, so disable them val enableIosTarget = System.getProperty("os.name").contains("mac", ignoreCase = true) @@ -83,49 +78,13 @@ kotlin { jvm() - val xcodeExists by lazy { // Define xcodeExists and xcodeDir here to be accessible by iOS targets - project.providers.exec { - isIgnoreExitValue = true - commandLine("which", "xcode-select") - }.result.get().exitValue == 0 - } - val xcodeDir by lazy { - if (xcodeExists) { - project.providers.exec { - commandLine("xcode-select", "-p") - }.standardOutput.asText.get().trim() - } else { - "" - } - } - listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { target -> - if (enableIosTarget) { - val osName = when (target.name) { - "iosX64" -> "iphonesimulator" - "iosArm64" -> "iphoneos" - "iosSimulatorArm64" -> "iphonesimulator" - else -> throw IllegalStateException("Unknown target: ${target.name}") - } - val dir = tasks.getByName("buildFrameworkLibPebbleSwift").outputs.files.singleFile.resolve(osName) - target.binaries.framework { - baseName = "libpebble3" - } - target.compilations.getByName("main") { - val libPebbleSwift by cinterops.creating { - compilerOpts("-framework", "LibPebbleSwift", "-F" + dir.absolutePath) - } - } - target.binaries.all { - linkerOpts("-framework", "LibPebbleSwift", "-F" + dir.absolutePath) - if (xcodeExists) { - linkerOpts("-L$xcodeDir/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$osName") - } - } + target.binaries.framework { + baseName = "libpebble3" } } @@ -223,6 +182,7 @@ tasks.withType>().all { dependsOn("kspCommonMainKotlinMetadata") } } + afterEvaluate { tasks.named("kspDebugKotlinAndroid") { dependsOn("kspCommonMainKotlinMetadata") @@ -241,24 +201,6 @@ afterEvaluate { tasks.named("kspKotlinIosSimulatorArm64") { dependsOn("kspCommonMainKotlinMetadata") } - tasks.named("cinteropLibPebbleSwiftIosArm64") { - dependsOn("buildFrameworkLibPebbleSwift") - } - tasks.named("cinteropLibPebbleSwiftIosX64") { - dependsOn("buildFrameworkLibPebbleSwift") - } - tasks.named("cinteropLibPebbleSwiftIosSimulatorArm64") { - dependsOn("buildFrameworkLibPebbleSwift") - } - tasks.named("compileKotlinIosArm64") { - dependsOn("buildFrameworkLibPebbleSwift") - } - tasks.named("compileKotlinIosX64") { - dependsOn("buildFrameworkLibPebbleSwift") - } - tasks.named("compileKotlinIosSimulatorArm64") { - dependsOn("buildFrameworkLibPebbleSwift") - } } } @@ -344,55 +286,6 @@ if (Os.isFamily(Os.FAMILY_MAC)) { } }*/ -abstract class BuildSwiftFramework : DefaultTask() { - @Inject - abstract fun getExecOperations(): ExecOperations - - @get:InputFiles - val inputFiles = project.objects.fileCollection().from(project.fileTree("libpebble-swift") { - include("LibPebbleSwift.xcodeproj/project.pbxproj") - include("LibPebbleSwift/*.swift") - include("LibPebbleSwift/*.h") - include("LibPebbleSwift/*.m") - }) - - @get:OutputDirectory - val outputDir = - project.objects.directoryProperty().convention(project.layout.buildDirectory.dir("libpebble-swift/")) - - @TaskAction - fun buildSwiftFramework() { - logging.captureStandardOutput(LogLevel.INFO) - logging.captureStandardError(LogLevel.ERROR) - getExecOperations().exec { - commandLine( - "xcodebuild", "-project", "LibPebbleSwift.xcodeproj", - "-scheme", "LibPebbleSwift", - "-configuration", "Release", - "-sdk", "iphoneos", - "CONFIGURATION_BUILD_DIR=${outputDir.get().asFile.resolve("iphoneos/").absolutePath}", - "ARCHS=arm64", - "SUPPORTS_MACCATALYST=NO", - ) - workingDir = project.file("libpebble-swift") - standardOutput = System.out - errorOutput = System.err - } - getExecOperations().exec { - commandLine( - "xcodebuild", "-project", "LibPebbleSwift.xcodeproj", - "-scheme", "LibPebbleSwift", - "-configuration", "Release", - "-sdk", "iphonesimulator", - "CONFIGURATION_BUILD_DIR=${outputDir.get().asFile.resolve("iphonesimulator/").absolutePath}", - ) - workingDir = project.file("libpebble-swift") - standardOutput = System.out - errorOutput = System.err - } - } -} - abstract class PlatformFatFramework : DefaultTask() { @get:Input abstract val platform: Property diff --git a/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.pbxproj b/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.pbxproj deleted file mode 100644 index 6e76838d2..000000000 --- a/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.pbxproj +++ /dev/null @@ -1,377 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 77; - objects = { - -/* Begin PBXFileReference section */ - 6768CD9F2E301E7F00EF6A7A /* LibPebbleSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LibPebbleSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ - 6768CDA42E301E7F00EF6A7A /* Exceptions for "LibPebbleSwift" folder in "LibPebbleSwift" target */ = { - isa = PBXFileSystemSynchronizedBuildFileExceptionSet; - publicHeaders = ( - IOSLocation.h, - LibPebbleSwift.h, - ); - target = 6768CD9E2E301E7F00EF6A7A /* LibPebbleSwift */; - }; -/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ - -/* Begin PBXFileSystemSynchronizedRootGroup section */ - 6768CDA12E301E7F00EF6A7A /* LibPebbleSwift */ = { - isa = PBXFileSystemSynchronizedRootGroup; - exceptions = ( - 6768CDA42E301E7F00EF6A7A /* Exceptions for "LibPebbleSwift" folder in "LibPebbleSwift" target */, - ); - path = LibPebbleSwift; - sourceTree = ""; - }; -/* End PBXFileSystemSynchronizedRootGroup section */ - -/* Begin PBXFrameworksBuildPhase section */ - 6768CD9C2E301E7F00EF6A7A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 6768CD952E301E7F00EF6A7A = { - isa = PBXGroup; - children = ( - 6768CDA12E301E7F00EF6A7A /* LibPebbleSwift */, - 6768CDA02E301E7F00EF6A7A /* Products */, - ); - sourceTree = ""; - }; - 6768CDA02E301E7F00EF6A7A /* Products */ = { - isa = PBXGroup; - children = ( - 6768CD9F2E301E7F00EF6A7A /* LibPebbleSwift.framework */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 6768CD9A2E301E7F00EF6A7A /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 6768CD9E2E301E7F00EF6A7A /* LibPebbleSwift */ = { - isa = PBXNativeTarget; - buildConfigurationList = 6768CDA52E301E7F00EF6A7A /* Build configuration list for PBXNativeTarget "LibPebbleSwift" */; - buildPhases = ( - 6768CD9A2E301E7F00EF6A7A /* Headers */, - 6768CD9B2E301E7F00EF6A7A /* Sources */, - 6768CD9C2E301E7F00EF6A7A /* Frameworks */, - 6768CD9D2E301E7F00EF6A7A /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - fileSystemSynchronizedGroups = ( - 6768CDA12E301E7F00EF6A7A /* LibPebbleSwift */, - ); - name = LibPebbleSwift; - packageProductDependencies = ( - ); - productName = "libpebble-swift"; - productReference = 6768CD9F2E301E7F00EF6A7A /* LibPebbleSwift.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 6768CD962E301E7F00EF6A7A /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastUpgradeCheck = 1620; - TargetAttributes = { - 6768CD9E2E301E7F00EF6A7A = { - CreatedOnToolsVersion = 16.2; - LastSwiftMigration = 1620; - }; - }; - }; - buildConfigurationList = 6768CD992E301E7F00EF6A7A /* Build configuration list for PBXProject "LibPebbleSwift" */; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 6768CD952E301E7F00EF6A7A; - minimizedProjectReferenceProxies = 1; - preferredProjectObjectVersion = 77; - productRefGroup = 6768CDA02E301E7F00EF6A7A /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 6768CD9E2E301E7F00EF6A7A /* LibPebbleSwift */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 6768CD9D2E301E7F00EF6A7A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 6768CD9B2E301E7F00EF6A7A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 6768CDA62E301E7F00EF6A7A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUILD_LIBRARY_FOR_DISTRIBUTION = YES; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_MODULE_VERIFIER = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - MACH_O_TYPE = staticlib; - MARKETING_VERSION = 1.0; - MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; - MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; - PRODUCT_BUNDLE_IDENTIFIER = coredevices.LibPebbleSwift; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_INSTALL_OBJC_HEADER = NO; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 6768CDA72E301E7F00EF6A7A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUILD_LIBRARY_FOR_DISTRIBUTION = YES; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_MODULE_VERIFIER = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - MACH_O_TYPE = staticlib; - MARKETING_VERSION = 1.0; - MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; - MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; - PRODUCT_BUNDLE_IDENTIFIER = coredevices.LibPebbleSwift; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_INSTALL_OBJC_HEADER = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 6768CDA82E301E7F00EF6A7A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - 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; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - 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 = 18.2; - LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 6768CDA92E301E7F00EF6A7A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - 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; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - 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 = 18.2; - LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 6768CD992E301E7F00EF6A7A /* Build configuration list for PBXProject "LibPebbleSwift" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6768CDA82E301E7F00EF6A7A /* Debug */, - 6768CDA92E301E7F00EF6A7A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 6768CDA52E301E7F00EF6A7A /* Build configuration list for PBXNativeTarget "LibPebbleSwift" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6768CDA62E301E7F00EF6A7A /* Debug */, - 6768CDA72E301E7F00EF6A7A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 6768CD962E301E7F00EF6A7A /* Project object */; -} diff --git a/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a62..000000000 --- a/libpebble3/libpebble-swift/LibPebbleSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.h b/libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.h deleted file mode 100644 index 3ef52b0e7..000000000 --- a/libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// IOSLocation.h -// LibPebbleSwift -// -// Created by crc32 on 22/07/2025. -// - -#include -#include - -@interface IOSLocation : NSObject -- (void) start; -- (void) stop; -- (CLLocation * _Nullable) lastLocation; -- (void) setHighAccuracy:(BOOL)highAccuracy; -- (IOSLocation* _Nonnull)initWithLocationCallback:(void (^ _Nonnull)(CLLocation * _Nullable))locationCallback - authorizationCallback:(void (^ _Nonnull)(BOOL))authorizationCallback - errorCallback:(void (^ _Nonnull)(NSError * _Nonnull))errorCallback; -@end diff --git a/libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.swift b/libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.swift deleted file mode 100644 index 62c14e8df..000000000 --- a/libpebble3/libpebble-swift/LibPebbleSwift/IOSLocation.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// IOSLocation.swift -// libpebble-swift -// -// Created by crc32 on 22/07/2025. -// - -import Foundation -import CoreLocation - -@objc(IOSLocation) public class IOSLocation: NSObject, CLLocationManagerDelegate { - - private let locationCallback: (CLLocation?) -> Void - private let authorizationCallback: (Bool) -> Void - private let errorCallback: (Error) -> Void - private let locationManager = CLLocationManager() - - @objc public init( - locationCallback: @escaping (CLLocation?) -> Void, - authorizationCallback: @escaping (Bool) -> Void, - errorCallback: @escaping (Error) -> Void - ) { - self.locationCallback = locationCallback - self.authorizationCallback = authorizationCallback - self.errorCallback = errorCallback - super.init() - self.locationManager.delegate = self - } - - @objc public func start() { - locationManager.requestWhenInUseAuthorization() - } - - @objc public func stop() { - locationManager.stopUpdatingLocation() - } - - @objc public func lastLocation() -> CLLocation? { - return locationManager.location - } - - @objc public func setHighAccuracy(_ highAccuracy: Bool) { - locationManager.desiredAccuracy = highAccuracy - ? kCLLocationAccuracyBestForNavigation - : kCLLocationAccuracyHundredMeters - } - - public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { - locationCallback(locations.last) - } - - public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { - switch status { - case .authorizedAlways, .authorizedWhenInUse: - locationManager.startUpdatingLocation() - authorizationCallback(true) - default: - authorizationCallback(false) - } - } - - public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { - self.errorCallback(error) - } -} diff --git a/libpebble3/libpebble-swift/LibPebbleSwift/LibPebbleSwift.h b/libpebble3/libpebble-swift/LibPebbleSwift/LibPebbleSwift.h deleted file mode 100644 index 85c2f2f16..000000000 --- a/libpebble3/libpebble-swift/LibPebbleSwift/LibPebbleSwift.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// libpebble_swift.h -// libpebble-swift -// -// Created by crc32 on 22/07/2025. -// - -#import - -//! Project version number for libpebble_swift. -FOUNDATION_EXPORT double libpebble_swiftVersionNumber; - -//! Project version string for libpebble_swift. -FOUNDATION_EXPORT const unsigned char libpebble_swiftVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import -#import diff --git a/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IOSLocation.kt b/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IOSLocation.kt new file mode 100644 index 000000000..1733a1794 --- /dev/null +++ b/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IOSLocation.kt @@ -0,0 +1,59 @@ +package io.rebble.libpebblecommon.util + +import platform.CoreLocation.CLLocation +import platform.CoreLocation.CLLocationManager +import platform.CoreLocation.CLLocationManagerDelegateProtocol +import platform.CoreLocation.kCLAuthorizationStatusAuthorizedAlways +import platform.CoreLocation.kCLAuthorizationStatusAuthorizedWhenInUse +import platform.CoreLocation.kCLLocationAccuracyBestForNavigation +import platform.CoreLocation.kCLLocationAccuracyHundredMeters +import platform.Foundation.NSError +import platform.darwin.NSObject + +class IOSLocation( + private val locationCallback: (CLLocation?) -> Unit, + private val authorizationCallback: (Boolean) -> Unit, + private val errorCallback: (NSError?) -> Unit, +) : NSObject(), CLLocationManagerDelegateProtocol { + private val locationManager = CLLocationManager() + + init { + locationManager.delegate = this + } + + fun start() { + locationManager.requestWhenInUseAuthorization() + } + + fun stop() { + locationManager.stopUpdatingLocation() + } + + fun lastLocation(): CLLocation? = locationManager.location + + fun setHighAccuracy(highAccuracy: Boolean) { + locationManager.setDesiredAccuracy( + if (highAccuracy) kCLLocationAccuracyBestForNavigation + else kCLLocationAccuracyHundredMeters + ) + } + + override fun locationManager(manager: CLLocationManager, didUpdateLocations: List<*>) { + locationCallback(didUpdateLocations.lastOrNull() as? CLLocation) + } + + override fun locationManagerDidChangeAuthorization(manager: CLLocationManager) { + when (manager.authorizationStatus) { + kCLAuthorizationStatusAuthorizedAlways, + kCLAuthorizationStatusAuthorizedWhenInUse -> { + manager.startUpdatingLocation() + authorizationCallback(true) + } + else -> authorizationCallback(false) + } + } + + override fun locationManager(manager: CLLocationManager, didFailWithError: NSError) { + errorCallback(didFailWithError) + } +} diff --git a/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IosSystemGeolocation.kt b/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IosSystemGeolocation.kt index 58df7061e..b13a35883 100644 --- a/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IosSystemGeolocation.kt +++ b/libpebble3/src/iosMain/kotlin/io/rebble/libpebblecommon/util/IosSystemGeolocation.kt @@ -1,6 +1,6 @@ package io.rebble.libpebblecommon.io.rebble.libpebblecommon.util -import LibPebbleSwift.IOSLocation +import io.rebble.libpebblecommon.util.IOSLocation import co.touchlab.kermit.Logger import io.rebble.libpebblecommon.util.GeolocationPositionResult import io.rebble.libpebblecommon.util.SystemGeolocation diff --git a/libpebble3/src/nativeInterop/cinterop/libPebbleSwift.def b/libpebble3/src/nativeInterop/cinterop/libPebbleSwift.def deleted file mode 100644 index 966a7bb7b..000000000 --- a/libpebble3/src/nativeInterop/cinterop/libPebbleSwift.def +++ /dev/null @@ -1,3 +0,0 @@ -language = Objective-C -modules = LibPebbleSwift -package = LibPebbleSwift \ No newline at end of file