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

Pod install fails when Nitro Module is added to RN application #465

Closed
3 of 5 tasks
akpekig opened this issue Jan 7, 2025 · 2 comments
Closed
3 of 5 tasks

Pod install fails when Nitro Module is added to RN application #465

akpekig opened this issue Jan 7, 2025 · 2 comments
Labels
nitro-core Issue is related to the Nitro Modules core runtime/C++ codebase no-repro No reproduceable example is added - hard to fix.

Comments

@akpekig
Copy link

akpekig commented Jan 7, 2025

What's happening?

Following documentation, I created a Nitro Module and added it to an RN application. Pod install fails with the following error:

[!] Unable to find a specification for `NitroModules` depended upon by `NitroExample`

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

The error is resolved with by removing the autolinking script and manually adding Nitro-generated files:

require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
  s.name         = "NitroExample"
  s.version      = package["version"]
  s.summary      = package["description"]
  s.homepage     = package["homepage"]
  s.license      = package["license"]
  s.authors      = package["author"]

  s.platforms    = { :ios => min_ios_version_supported, :visionos => 1.0 }
  s.source       = { :git => "https://github.com/mrousavy/nitro.git", :tag => "#{s.version}" }

  s.source_files = [
    # Implementation (Swift)
    "ios/**/*.{swift}",
    # Autolinking/Registration (Objective-C++)
    "ios/**/*.{m,mm}",
    # Implementation (C++ objects)
    "cpp/**/*.{hpp,cpp}",
+    # Generated cross-platform specs
+    "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
+    # Generated bridges for the cross-platform specs
+    "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
  ]

+  s.public_header_files = [
+    # Generated specs
+    "nitrogen/generated/shared/**/*.{h,hpp}",
+    # Swift to C++ bridging helpers
+    "nitrogen/generated/ios/NitroExample-Swift-Cxx-Bridge.hpp"
+  ]
+
+  s.private_header_files = [
+    # iOS specific specs
+    "nitrogen/generated/ios/c++/**/*.{h,hpp}",
+  ]
+
+  s.pod_target_xcconfig = {
+    # C++ compiler flags, mainly for folly.
+    "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES",
+    # Use C++ 20
+    "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
+    # Enables C++ <-> Swift interop (by default it's only C)
+   "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
+    # Enables stricter modular headers
+    "DEFINES_MODULE" => "YES",
+  }

-  load 'nitrogen/generated/ios/NitroExample+autolinking.rb'
-  add_nitrogen_files(s)

+ s.dependency 'NitroModules'
  s.dependency 'React-jsi'
  s.dependency 'React-callinvoker'
  install_modules_dependencies(s)
end

Reproduceable Code

require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

Pod::Spec.new do |s|
  s.name         = "NitroExample"
  s.version      = package["version"]
  s.summary      = package["description"]
  s.homepage     = package["homepage"]
  s.license      = package["license"]
  s.authors      = package["author"]

  s.platforms    = { :ios => min_ios_version_supported, :visionos => 1.0 }
  s.source       = { :git => "https://github.com/mrousavy/nitro.git", :tag => "#{s.version}" }

  s.source_files = [
    # Implementation (Swift)
    "ios/**/*.{swift}",
    # Autolinking/Registration (Objective-C++)
    "ios/**/*.{m,mm}",
    # Implementation (C++ objects)
    "cpp/**/*.{hpp,cpp}",
  ]

  load 'nitrogen/generated/ios/NitroExample+autolinking.rb'
  add_nitrogen_files(s)

  s.dependency 'React-jsi'
  s.dependency 'React-callinvoker'
  install_modules_dependencies(s)
end

Relevant log output

[Codegen] Done.
Updating local specs repositories

Analyzing dependencies
[NitroModules] 🔥 NitroExample is boosted by nitro!
[!] Unable to find a specification for `NitroModules` depended upon by `NitroExample`

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Device

Macbook Pro 2019 (macOS Sonoma 14.5)

Nitro Modules Version

0.20.1

Nitrogen Version

0.20.1

Can you reproduce this issue in the Nitro Example app here?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

@akpekig akpekig added the nitro-core Issue is related to the Nitro Modules core runtime/C++ codebase label Jan 7, 2025
@mrousavy
Copy link
Owner

mrousavy commented Jan 7, 2025

i'd need a repo for that to see what got generated

@mrousavy mrousavy added the no-repro No reproduceable example is added - hard to fix. label Jan 8, 2025
@mrousavy
Copy link
Owner

closing because no repro

@mrousavy mrousavy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nitro-core Issue is related to the Nitro Modules core runtime/C++ codebase no-repro No reproduceable example is added - hard to fix.
Projects
None yet
Development

No branches or pull requests

2 participants