Problem When Compiling NitroView using CIFIlters
Build Failure: Generated Swift-to-Objective-C Header (NitroBarcodeCreator)
How were you trying to build the app?
I was trying to build the BarcodeCreatorExample iOS app using CocoaPods and Xcode after running npx nitrogen, yarn, and pod install in the example project.
Overview
The project fails to build due to errors originating from a generated Swift-to-Objective-C header produced by a third-party library integrated via CocoaPods.
We donβt have any context about the library itself (named NitroBarcodeCreator in the build output), but the failure occurs when compiling its generated header.
Affected File (Generated)
- File:
NitroBarcodeCreator-Swift.h(generated during build) - Example path (from DerivedData):
.../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/NitroBarcodeCreator.build/DerivedSources/NitroBarcodeCreator-Swift.h
Error Messages
Repeated compiler errors include:
Example line from generated header:
What Seems To Be Happening
- The generated header references Core Image types (e.g.,
CIFilter). - The Objective-C compilation unit that includes this generated header does not have Core Image headers available, causing
CIFilter(and related bridging constructs) to be unknown.
Environment
- Xcode: 26.1
- Platform: iOS Simulator (Debug)
- Integration: CocoaPods
- Affected artifact: Generated Swift header for a dependency (
NitroBarcodeCreatorper build paths)
Full build logs (trimmed)
# In the library repo
vittori@Davids-MacBook-Air ~ % cd Develop/react-native-barcode-creator
vittori@Davids-MacBook-Air react-native-barcode-creator % npx nitrogen
π§ Loading nitro.json config...
π Nitrogen 0.31.5 runs at ~/Develop/react-native-barcode-creator
π Nitrogen found 1 spec in ./src/specs
β³ Parsing HybridBarcodeCreatorView.nitro.ts...
βοΈ Generating specs for HybridObject "BarcodeCreatorView"...
shared: Generating C++ code...
ios: Generating Swift code...
android: Generating Kotlin code...
βοΈ Setting up build configs for autolinking...
Creating autolinking build setup for iOS...
Creating autolinking build setup for android...
π Generated 1/1 HybridObject in 0.6s!
π‘ Your code is in ./nitrogen/generated
βΌοΈ Added 22 files - you need to run `pod install`/sync gradle to update files!
# In the example app
vittori@Davids-MacBook-Air react-native-barcode-creator % cd ../BarcodeCreatorExample
vittori@Davids-MacBook-Air BarcodeCreatorExample % yarn && cd ios && pod install
[!] Invalid `Podfile` file:
[!] Invalid `NitroBarcodeCreator.podspec` file: cannot load such file -- nitrogen/generated/ios/NitroBarcodeCreator+autolinking.rb.
# from /Users/vittori/Develop/BarcodeCreatorExample/node_modules/react-native-barcode-creator/NitroBarcodeCreator.podspec:25
# -------------------------------------------
#
> load 'nitrogen/generated/ios/NitroBarcodeCreator+autolinking.rb'
# add_nitrogen_files(s)
# -------------------------------------------
# After fixing/generating autolinking files again
vittori@Davids-MacBook-Air BarcodeCreatorExample % yarn
β¨ Done in 16.57s.
vittori@Davids-MacBook-Air BarcodeCreatorExample % cd ios && pod install
[NitroModules] π₯ NitroBarcodeCreator is boosted by nitro!
[NitroModules] π₯ Your app is boosted by nitro modules!
[NitroModules] Found react-native 0.82.1 (82) in /Users/vittori/Develop/BarcodeCreatorExample/node_modules/react-native!
Auto-linking React Native modules for target `BarcodeCreatorExample`: NitroBarcodeCreator, NitroModules, and react-native-safe-area-context
[Codegen] Generated artifacts: /Users/vittori/Develop/BarcodeCreatorExample/ios/build/generated/iOS
[...]
Pod installation complete! There are 78 dependencies from the Podfile and 77 total pods installed.
Project dependencies
{
"name": "react-native-barcode-creator",
"version": "0.0.1",
"description": "react-native-barcode-creator",
"main": "lib/index",
"module": "lib/index",
"types": "lib/index.d.ts",
"react-native": "src/index",
"source": "src/index",
"files": [
"src",
"react-native.config.js",
"lib",
"nitrogen",
"android/build.gradle",
"android/gradle.properties",
"android/fix-prefab.gradle",
"android/CMakeLists.txt",
"android/src",
"ios/**/*.h",
"ios/**/*.m",
"ios/**/*.mm",
"ios/**/*.cpp",
"ios/**/*.swift",
"app.plugin.js",
"nitro.json",
"*.podspec",
"README.md"
],
"scripts": {
"postinstall": "tsc || exit 0;",
"typecheck": "tsc --noEmit",
"clean": "rm -rf android/build node_modules/**/android/build lib",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"typescript": "tsc",
"specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\""
},
"keywords": [
"react-native",
"nitro"
],
"repository": {
"type": "git",
"url": "git+https://github.com/mrousavy/nitro.git"
},
"author": "Marc Rousavy <[email protected]> (https://github.com/mrousavy)",
"license": "MIT",
"bugs": {
"url": "https://github.com/mrousavy/nitro/issues"
},
"homepage": "https://github.com/mrousavy/nitro#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@react-native/eslint-config": "0.82.0",
"@types/react": "^19.1.03",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"nitrogen": "*",
"prettier": "^3.3.3",
"react": "19.1.1",
"react-native": "0.82.0",
"react-native-nitro-modules": "*",
"typescript": "^5.8.3"
},
"peerDependencies": {
"react": "*",
"react-native": "*",
"react-native-nitro-modules": "*"
},
"eslintConfig": {
"root": true,
"extends": [
"@react-native",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": [
"warn",
{
"quoteProps": "consistent",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
]
}
},
"eslintIgnore": [
"node_modules/",
"lib/"
],
"prettier": {
"quoteProps": "consistent",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"semi": false
}
}
Nitro Modules Version
latest
Nitrogen Version
No response
Target platforms
iOS
Operating system
MacOS
Can you build the Nitro Modules Example app?
Yes, I can successfully build the Example app here.
Additional information
- [ ] I am using Expo
- [x] I am using nitrogen
- [x] I have read and followed the [Troubleshooting Guide](https://nitro.margelo.com/docs/troubleshooting).
- [ ] I created a reproduction PR to reproduce this issue here in the nitro repo. (See [Contributing](https://nitro.margelo.com/docs/contributing) for more information)
- [x] I searched for [similar issues in this repository](https://github.com/mrousavy/nitro/issues) and found none.
- Please format your code/blocks properly. This issue is impossible to read
- Is your Swift class
public? Try making it not public.
Thanks for the comment @mrousavy, I properly formatted the issue. And I did make the class not public and it fixed the original problem.
The only thing is that now it is blocked here:
Invariant Violation: View config getter callback for component `BarcodeCreatorView` must be a function (received `undefined`).
This is how I'm exporting the component:
index.ts
import { getHostComponent } from 'react-native-nitro-modules'
import type {
BarcodeCreatorProps,
BarcodeCreatorMethods,
} from './specs/HybridBarcodeCreatorView.nitro'
import ViewConfig from '../nitrogen/generated/shared/json/BarcodeCreatorViewConfig.json' with { type: 'json' }
export const BarcodeCreatorView = getHostComponent<
BarcodeCreatorProps,
BarcodeCreatorMethods
>('BarcodeCreatorView', () => ViewConfig)
HybridBarcodeCreatorView.nitro.ts
import type {
HybridView,
HybridViewMethods,
HybridViewProps,
} from 'react-native-nitro-modules'
export interface BarcodeCreatorProps extends HybridViewProps {
barcodeFormat: string
data: string
backgroundColor?: string
foregroundColor?: string
}
export interface BarcodeCreatorMethods extends HybridViewMethods {}
export type BarcodeCreatorView = HybridView<
BarcodeCreatorProps,
BarcodeCreatorMethods
>
do you think I'm doing something wrong in the setup ?
Generate your specs again, are you 100% sure the json file exists?
@mrousavy I generated the specs again and I also tried to pass the generated object directly to the getHostComponent function and it didn't help. It is blocked with that problem,
here is the repo with my problem, everything seems okay https://github.com/VittoriDavide/react-native-barcode-creator/tree/v2-rewrite
Did you try a require(...) instead of the import ViewConfig from ...?
@mrousavy Yes, Iβm seeing the same behavior. I also added a console log to the ViewConfig, and it prints the JSON correctly when I use it from my example application.