react-native-nitro-geolocation 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +598 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +341 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +76 -5
  5. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +164 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +228 -0
  7. package/ios/LocationManager.swift +529 -0
  8. package/ios/NitroGeolocation.swift +96 -2
  9. package/nitrogen/generated/.gitattributes +1 -0
  10. package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +62 -0
  11. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  12. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +77 -0
  13. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +79 -0
  14. package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +77 -0
  15. package/nitrogen/generated/android/c++/JGeolocationError.hpp +69 -0
  16. package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +77 -0
  17. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +59 -0
  18. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +69 -0
  20. package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +62 -0
  21. package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +69 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +22 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +81 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +81 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +81 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +47 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +41 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +47 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +32 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +87 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +22 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +38 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/nitrogeolocationOnLoad.kt +35 -0
  34. package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +81 -0
  35. package/nitrogen/generated/android/nitrogeolocation+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +50 -0
  37. package/nitrogen/generated/android/nitrogeolocationOnLoad.hpp +25 -0
  38. package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +60 -0
  39. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +56 -0
  40. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +252 -0
  41. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +67 -0
  42. package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +25 -0
  44. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +125 -0
  46. package/nitrogen/generated/ios/swift/AuthorizationLevelInternal.swift +44 -0
  47. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  48. package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +47 -0
  49. package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +47 -0
  50. package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +149 -0
  51. package/nitrogen/generated/ios/swift/GeolocationError.swift +79 -0
  52. package/nitrogen/generated/ios/swift/GeolocationOptions.swift +185 -0
  53. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +46 -0
  54. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +54 -0
  55. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +236 -0
  56. package/nitrogen/generated/ios/swift/LocationProviderInternal.swift +44 -0
  57. package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +104 -0
  58. package/nitrogen/generated/shared/c++/AuthorizationLevelInternal.hpp +80 -0
  59. package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +91 -0
  60. package/nitrogen/generated/shared/c++/GeolocationError.hpp +83 -0
  61. package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +91 -0
  62. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +72 -0
  63. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +26 -0
  64. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +79 -0
  65. package/nitrogen/generated/shared/c++/LocationProviderInternal.hpp +80 -0
  66. package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +84 -0
  67. package/package.json +34 -10
  68. package/src/NitroGeolocation.nitro.ts +38 -3
  69. package/src/NitroGeolocationModule.ts +5 -0
  70. package/src/clearWatch.ts +13 -0
  71. package/src/getCurrentPosition.ts +14 -0
  72. package/src/index.tsx +32 -7
  73. package/src/requestAuthorization.ts +9 -0
  74. package/src/setRNConfiguration.ts +22 -0
  75. package/src/stopObserving.ts +12 -0
  76. package/src/types.ts +43 -0
  77. package/src/watchPosition.ts +26 -0
  78. package/nitro.json +0 -17
  79. package/turbo.json +0 -42
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// HybridNitroGeolocationSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.*
14
+
15
+ /**
16
+ * A Kotlin class representing the NitroGeolocation HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of NitroGeolocation.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridNitroGeolocationSpec: HybridObject() {
27
+ @DoNotStrip
28
+ private var mHybridData: HybridData = initHybrid()
29
+
30
+ init {
31
+ super.updateNative(mHybridData)
32
+ }
33
+
34
+ override fun updateNative(hybridData: HybridData) {
35
+ mHybridData = hybridData
36
+ super.updateNative(hybridData)
37
+ }
38
+
39
+ // Properties
40
+
41
+
42
+ // Methods
43
+ @DoNotStrip
44
+ @Keep
45
+ abstract fun setRNConfiguration(config: RNConfigurationInternal): Unit
46
+
47
+ abstract fun requestAuthorization(success: (() -> Unit)?, error: ((error: GeolocationError) -> Unit)?): Unit
48
+
49
+ @DoNotStrip
50
+ @Keep
51
+ private fun requestAuthorization_cxx(success: Func_void?, error: Func_void_GeolocationError?): Unit {
52
+ val __result = requestAuthorization(success?.let { it }, error?.let { it })
53
+ return __result
54
+ }
55
+
56
+ abstract fun getCurrentPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: GeolocationError) -> Unit)?, options: GeolocationOptions?): Unit
57
+
58
+ @DoNotStrip
59
+ @Keep
60
+ private fun getCurrentPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_GeolocationError?, options: GeolocationOptions?): Unit {
61
+ val __result = getCurrentPosition(success, error?.let { it }, options)
62
+ return __result
63
+ }
64
+
65
+ abstract fun watchPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: GeolocationError) -> Unit)?, options: GeolocationOptions?): Double
66
+
67
+ @DoNotStrip
68
+ @Keep
69
+ private fun watchPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_GeolocationError?, options: GeolocationOptions?): Double {
70
+ val __result = watchPosition(success, error?.let { it }, options)
71
+ return __result
72
+ }
73
+
74
+ @DoNotStrip
75
+ @Keep
76
+ abstract fun clearWatch(watchId: Double): Unit
77
+
78
+ @DoNotStrip
79
+ @Keep
80
+ abstract fun stopObserving(): Unit
81
+
82
+ private external fun initHybrid(): HybridData
83
+
84
+ companion object {
85
+ private const val TAG = "HybridNitroGeolocationSpec"
86
+ }
87
+ }
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// LocationProviderInternal.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "LocationProviderInternal".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class LocationProviderInternal(@DoNotStrip @Keep val value: Int) {
19
+ AUTO(0),
20
+ PLAYSERVICES(1),
21
+ ANDROID_PLATFORM(2);
22
+ }
@@ -0,0 +1,38 @@
1
+ ///
2
+ /// RNConfigurationInternal.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "RNConfigurationInternal".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class RNConfigurationInternal
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val skipPermissionRequests: Boolean,
27
+ @DoNotStrip
28
+ @Keep
29
+ val authorizationLevel: AuthorizationLevelInternal?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val enableBackgroundLocationUpdates: Boolean?,
33
+ @DoNotStrip
34
+ @Keep
35
+ val locationProvider: LocationProviderInternal?
36
+ ) {
37
+ /* main constructor */
38
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// nitrogeolocationOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import android.util.Log
11
+
12
+ internal class nitrogeolocationOnLoad {
13
+ companion object {
14
+ private const val TAG = "nitrogeolocationOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "nitrogeolocation".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading nitrogeolocation C++ library...")
25
+ System.loadLibrary("nitrogeolocation")
26
+ Log.i(TAG, "Successfully loaded nitrogeolocation C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load nitrogeolocation C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ #
2
+ # nitrogeolocation+autolinking.cmake
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 2025 Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # This is a CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/nitrogeolocation+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_NITROGEOLOCATION_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ nitrogeolocation PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/nitrogeolocationOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ nitrogeolocation PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ nitrogeolocation
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ nitrogeolocation
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ nitrogeolocation
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// nitrogeolocation+autolinking.gradle
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /// This is a Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/nitrogeolocation+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 nitrogeolocation is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,50 @@
1
+ ///
2
+ /// nitrogeolocationOnLoad.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #ifndef BUILDING_NITROGEOLOCATION_WITH_GENERATED_CMAKE_PROJECT
9
+ #error nitrogeolocationOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "nitrogeolocationOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridNitroGeolocationSpec.hpp"
19
+ #include "JFunc_void.hpp"
20
+ #include "JFunc_void_GeolocationError.hpp"
21
+ #include "JFunc_void_GeolocationResponse.hpp"
22
+ #include <NitroModules/DefaultConstructableObject.hpp>
23
+
24
+ namespace margelo::nitro::nitrogeolocation {
25
+
26
+ int initialize(JavaVM* vm) {
27
+ using namespace margelo::nitro;
28
+ using namespace margelo::nitro::nitrogeolocation;
29
+ using namespace facebook;
30
+
31
+ return facebook::jni::initialize(vm, [] {
32
+ // Register native JNI methods
33
+ margelo::nitro::nitrogeolocation::JHybridNitroGeolocationSpec::registerNatives();
34
+ margelo::nitro::nitrogeolocation::JFunc_void_cxx::registerNatives();
35
+ margelo::nitro::nitrogeolocation::JFunc_void_GeolocationError_cxx::registerNatives();
36
+ margelo::nitro::nitrogeolocation::JFunc_void_GeolocationResponse_cxx::registerNatives();
37
+
38
+ // Register Nitro Hybrid Objects
39
+ HybridObjectRegistry::registerHybridObjectConstructor(
40
+ "NitroGeolocation",
41
+ []() -> std::shared_ptr<HybridObject> {
42
+ static DefaultConstructableObject<JHybridNitroGeolocationSpec::javaobject> object("com/margelo/nitro/nitrogeolocation/NitroGeolocation");
43
+ auto instance = object.create();
44
+ return instance->cthis()->shared();
45
+ }
46
+ );
47
+ });
48
+ }
49
+
50
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// nitrogeolocationOnLoad.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include <jni.h>
9
+ #include <NitroModules/NitroDefines.hpp>
10
+
11
+ namespace margelo::nitro::nitrogeolocation {
12
+
13
+ /**
14
+ * Initializes the native (C++) part of nitrogeolocation, and autolinks all Hybrid Objects.
15
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
16
+ * Example:
17
+ * ```cpp (cpp-adapter.cpp)
18
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
+ * return margelo::nitro::nitrogeolocation::initialize(vm);
20
+ * }
21
+ * ```
22
+ */
23
+ int initialize(JavaVM* vm);
24
+
25
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,60 @@
1
+ #
2
+ # NitroGeolocation+autolinking.rb
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 2025 Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # This is a Ruby script that adds all files generated by Nitrogen
9
+ # to the given podspec.
10
+ #
11
+ # To use it, add this to your .podspec:
12
+ # ```ruby
13
+ # Pod::Spec.new do |spec|
14
+ # # ...
15
+ #
16
+ # # Add all files generated by Nitrogen
17
+ # load 'nitrogen/generated/ios/NitroGeolocation+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 NitroGeolocation is boosted by nitro!"
24
+
25
+ spec.dependency "NitroModules"
26
+
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
+ spec.source_files = current_source_files + [
29
+ # Generated cross-platform specs
30
+ "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
+ # Generated bridges for the cross-platform specs
32
+ "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
+ ]
34
+
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
+ spec.public_header_files = current_public_header_files + [
37
+ # Generated specs
38
+ "nitrogen/generated/shared/**/*.{h,hpp}",
39
+ # Swift to C++ bridging helpers
40
+ "nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp"
41
+ ]
42
+
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
+ spec.private_header_files = current_private_header_files + [
45
+ # iOS specific specs
46
+ "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
+ # Views are framework-specific and should be private
48
+ "nitrogen/generated/shared/**/views/**/*"
49
+ ]
50
+
51
+ current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
+ spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
+ # Use C++ 20
54
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
+ # Enables C++ <-> Swift interop (by default it's only C)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ })
60
+ end
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// NitroGeolocation-Swift-Cxx-Bridge.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "NitroGeolocation-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridNitroGeolocationSpecSwift.hpp"
12
+ #include "NitroGeolocation-Swift-Cxx-Umbrella.hpp"
13
+
14
+ namespace margelo::nitro::nitrogeolocation::bridge::swift {
15
+
16
+ // pragma MARK: std::function<void()>
17
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
18
+ auto swiftClosure = NitroGeolocation::Func_void::fromUnsafe(swiftClosureWrapper);
19
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
20
+ swiftClosure.call();
21
+ };
22
+ }
23
+
24
+ // pragma MARK: std::function<void(const GeolocationError& /* error */)>
25
+ Func_void_GeolocationError create_Func_void_GeolocationError(void* NON_NULL swiftClosureWrapper) noexcept {
26
+ auto swiftClosure = NitroGeolocation::Func_void_GeolocationError::fromUnsafe(swiftClosureWrapper);
27
+ return [swiftClosure = std::move(swiftClosure)](const GeolocationError& error) mutable -> void {
28
+ swiftClosure.call(error);
29
+ };
30
+ }
31
+
32
+ // pragma MARK: std::function<void(const GeolocationResponse& /* position */)>
33
+ Func_void_GeolocationResponse create_Func_void_GeolocationResponse(void* NON_NULL swiftClosureWrapper) noexcept {
34
+ auto swiftClosure = NitroGeolocation::Func_void_GeolocationResponse::fromUnsafe(swiftClosureWrapper);
35
+ return [swiftClosure = std::move(swiftClosure)](const GeolocationResponse& position) mutable -> void {
36
+ swiftClosure.call(position);
37
+ };
38
+ }
39
+
40
+ // pragma MARK: std::shared_ptr<HybridNitroGeolocationSpec>
41
+ std::shared_ptr<HybridNitroGeolocationSpec> create_std__shared_ptr_HybridNitroGeolocationSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
42
+ NitroGeolocation::HybridNitroGeolocationSpec_cxx swiftPart = NitroGeolocation::HybridNitroGeolocationSpec_cxx::fromUnsafe(swiftUnsafePointer);
43
+ return std::make_shared<margelo::nitro::nitrogeolocation::HybridNitroGeolocationSpecSwift>(swiftPart);
44
+ }
45
+ void* NON_NULL get_std__shared_ptr_HybridNitroGeolocationSpec_(std__shared_ptr_HybridNitroGeolocationSpec_ cppType) noexcept {
46
+ std::shared_ptr<margelo::nitro::nitrogeolocation::HybridNitroGeolocationSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrogeolocation::HybridNitroGeolocationSpecSwift>(cppType);
47
+ #ifdef NITRO_DEBUG
48
+ if (swiftWrapper == nullptr) [[unlikely]] {
49
+ throw std::runtime_error("Class \"HybridNitroGeolocationSpec\" is not implemented in Swift!");
50
+ }
51
+ #endif
52
+ NitroGeolocation::HybridNitroGeolocationSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
53
+ return swiftPart.toUnsafe();
54
+ }
55
+
56
+ } // namespace margelo::nitro::nitrogeolocation::bridge::swift