Skip to content

How to use library only for IOS? #775

Description

@Luxlorys

Hey guys, i created Turbo module using npx create-react-native-library with Kotlin & Obj-c but the thing is that i want to use this module only for IOS since i created library to manage some IOS native things.

Sorry if i'm not that descriptive.

Activity

  1. satya164 commented on Feb 23, 2025

    @satya164
    Member

    just delete the android folder and any code and scripts referencing android

  2. Luxlorys commented on Feb 23, 2025

    @Luxlorys
    Author

    i've tried to delete android folder, also removed references to android here
    package.json

    "codegenConfig": {
        "name": "RNAppleHealthKitSpec",
        "type": "modules",
        "jsSrcsDir": "src",
        "outputDir": {
          "ios": "ios/generated",
          "android": "android/generated"
        },
        "android": {
          "javaPackageName": "com.applehealthkit"
        },
        "includesGeneratedCode": true
      },
    

    still could not build example app for android, also android folder was created again after yarn install in root folder.
    i'd be really grateful if you check this and add more details what i need to delete (link to repo)

  3. Luxlorys commented on Feb 23, 2025

    @Luxlorys
    Author

    as a temporary solution to this error (same error 4 times for all methods i defined in spec file)

    e: file:///Users/andrei/dev/react-native-apple-health-kit/android/src/main/java/com/applehealthkit/AppleHealthKitModule.kt:7:1 Class 'AppleHealthKitModule' is not abstract and does not implement abstract base class member 'requestHealthKitPermissions'.

    i just created placeholders with rejects for all methods

    package com.applehealthkit
    
    import com.facebook.react.bridge.Promise
    import com.facebook.react.bridge.ReactApplicationContext
    import com.facebook.react.module.annotations.ReactModule
    
    @ReactModule(name = AppleHealthKitModule.NAME)
    class AppleHealthKitModule(reactContext: ReactApplicationContext) :
      NativeAppleHealthKitSpec(reactContext) {
    
      override fun getName(): String {
        return NAME
      }
    
      // Placeholder for requestHealthKitPermissions
      override fun requestHealthKitPermissions(promise: Promise) {
        promise.reject("Unsupported", "HealthKit is not supported on Android.")
      }
    
      // Placeholder for getSteps
      override fun getSteps(daysBefore: Double, promise: Promise) {
        promise.reject("Unsupported", "HealthKit is not supported on Android.")
      }
    
      // Placeholder for getHeartRate
      override fun getHeartRate(daysBefore: Double, promise: Promise) {
        promise.reject("Unsupported", "HealthKit is not supported on Android.")
      }
    
      // Placeholder for getMeasurement
      override fun getMeasurement(promise: Promise) {
        promise.reject("Unsupported", "HealthKit is not supported on Android.")
      }
    
      // Placeholder for getAppleMoveTime
      override fun getAppleMoveTime(daysBefore: Double, promise: Promise) {
        promise.reject("Unsupported", "HealthKit is not supported on Android.")
      }
    
      companion object {
        const val NAME = "AppleHealthKit"
      }
    }
    

    I hope there is a better solution

  4. Luxlorys commented on Feb 23, 2025

    @Luxlorys
    Author

    seems like i found the solution, could you (@satya164) verify it?

    Image
  5. atlj commented on Feb 24, 2025

    @atlj
    Collaborator

    FYI converting this into a discussion

  6. locked and limited conversation to collaborators on Feb 24, 2025
  7. converted this issue into a discussion #776 on Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions