Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run project after installing library #778

Open
2 tasks done
Luxlorys opened this issue Feb 24, 2025 · 6 comments
Open
2 tasks done

Unable to run project after installing library #778

Luxlorys opened this issue Feb 24, 2025 · 6 comments
Assignees
Labels
bug Something isn't working needs-repro

Comments

@Luxlorys
Copy link

Description

I created library using create-react-native-library, removed android folder and scripts that referenced android, example build for both android and ios worked well, i pushed library to npm and installed to another project, dependencies and pods installed without any problem but could not build IOS buid

Image Image Image

link to package

link to repo

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

"react-native-builder-bob": {
    "source": "src",
    "output": "lib",
    "targets": [
      "codegen",
      [
        "commonjs",
        {
          "esm": true
        }
      ],
      [
        "module",
        {
          "esm": true
        }
      ],
      [
        "typescript",
        {
          "project": "tsconfig.build.json",
          "esm": true
        }
      ]
    ]
  },

Link to repro

https://github.com/Luxlorys/react-native-apple-health-kit

Environment

System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 122.22 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.13.0
    path: ~/.nvm/versions/node/v22.13.0/bin/node
  Yarn:
    version: 3.6.1
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v22.13.0/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/andrei/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.78.0
    wanted: 0.78.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
@Luxlorys Luxlorys added the bug Something isn't working label Feb 24, 2025
@Luxlorys
Copy link
Author

ummmm....i downgraded RN version in library from 0.78 to 0.75.3 and re-run codegen, now it's finally working, but the question is - is it the solution?

@Luxlorys
Copy link
Author

also in tsconfig.json file "moduleResolution": "Bundler" should be "moduleResolution": "bundler" though or you will get this error when downloading published library

Could not find a declaration file for module '@gromozeqa/react-native-apple-health-kit'. '/Users/andrei/dev/qwerty/node_modules/@gromozeqa/react-native-apple-health-kit/lib/commonjs/index.js' implicitly has an 'any' type.
  There are types at '/Users/andrei/dev/qwerty/node_modules/@gromozeqa/react-native-apple-health-kit/lib/typescript/module/src/index.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

@Zach-Dean-Attractions-io
Copy link

Zach-Dean-Attractions-io commented Mar 11, 2025

I had the same issue. In the podspec file: https://github.com/Luxlorys/react-native-apple-health-kit/blob/master/ReactNativeAppleHealthKit.podspec I had to wrap the s.private_header_files = "ios/**/*.h" command in an if statement to check if the new architecture was enabled or not. Try something like:

if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
    s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
    s.private_header_files = "ios/**/*.h"
  else
    s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
    s.exclude_files = "ios/**/*"
  end

@atlj
Copy link
Collaborator

atlj commented Mar 28, 2025

Hey I think I will need more details. The following setup worked for me:

  1. Created a new library (turbo module, same as yours)
  2. Used yalc to publish it locally
  3. Created a new app with npx @react-native-community/cli@latest init (The React Native version is 0.78.1
  4. Used yalc to fetch the locally published lib
  5. Installed pods and built the app

Everything worked fine. Can you setup a reproducible example of the app which you installed your library to? What React Native version does the app use? Is the new architecture enabled there?

@Luxlorys
Copy link
Author

3. Created a new app with npx @react-native-community/cli@latest init (The React Native version is 0.78.1

that's the problem, i tried to install the library to project with 0.75.3 RN (new arch enabled ofc)

Check repo here
And here is my library

For >0.76.0 RN your library will work fine, but my project uses 0.75.3, so i downgraded library RN to 0.75.3 and Spec file was totally different

To check it download my library with version 0.1.5, install pods and got to lib/ios/generated/RNAppleHealthKitSpec and open header file, you will see this block which causes an error for RN 0.75.3
`@interface NativeAppleHealthKitSpecBase : NSObject {
@Protected
facebook::react::EventEmitterCallback _eventEmitterCallback;
}

  • (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;`

But if you install my library with version 0.5.0, install pods and got to lib/ios/generated/RNAppleHealthKitSpec to you will see completely different spec file which no longer causes errors for older RN and still works for 0.76.0+

@satya164
Copy link
Member

Hey @Luxlorys can you check if you still have issues after disabling includeGeneratedCode? https://callstack.github.io/react-native-builder-bob/faq#how-to-opt-out-of-shipping-codegen-generated-code

May also need to bump react-native-builder-bob to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-repro
Projects
None yet
Development

No branches or pull requests

4 participants