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

Importing RNScreens in Xcode iOS Swift file fails to compile #2158

Closed
Brett-Best opened this issue May 24, 2024 · 2 comments · Fixed by #2160
Closed

Importing RNScreens in Xcode iOS Swift file fails to compile #2158

Brett-Best opened this issue May 24, 2024 · 2 comments · Fixed by #2160
Labels
Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS

Comments

@Brett-Best
Copy link
Contributor

Brett-Best commented May 24, 2024

Description

Attempting to import RNScreens in a swift file inside the main Xcode project where you'd define modules for example cause the build to fail.

I've attached a link to a new project I created using Expo.
The only customisation I made was to make CocoaPods use frameworks linking them statically.

The errors I'm getting are:

❌  (/Users/brettbest/Library/Developer/Xcode/DerivedData/Reproducer-favipxwwmbqszdfdwlhacyleizcj/Build/Products/Debug-iphonesimulator/RNScreens/RNScreens.framework/Headers/RNScreensTurboModule.h:1:10)

> 1 | #include <array>
    |          ^ 'array' file not found
  2 | #include <jsi/jsi.h>
  3 | 
  4 | #define JSI_HOST_FUNCTION(NAME)   \


❌  (/Users/brettbest/Library/Developer/Xcode/DerivedData/Reproducer-favipxwwmbqszdfdwlhacyleizcj/Build/Products/Debug-iphonesimulator/React-jsi/jsi.framework/Headers/decorator.h:10:10)

   8 | #pragma once
   9 | 
> 10 | #include <tuple>
     |          ^ 'tuple' file not found
  11 | 
  12 | #include <jsi/instrumentation.h>
  13 | #include <jsi/jsi.h>


❌  (ios/Reproducer/noop-file.swift:6:8)

  4 | //
  5 | 
> 6 | import RNScreens
    |        ^ could not build Objective-C module 'RNScreens'
  7 | 


❌  (/Users/brettbest/Library/Developer/Xcode/DerivedData/Reproducer-favipxwwmbqszdfdwlhacyleizcj/Build/Products/Debug-iphonesimulator/RNScreens/RNScreens.framework/Headers/RNScreensTurboModule.h:1:10)

> 1 | #include <array>
    |          ^ 'array' file not found
  2 | #include <jsi/jsi.h>
  3 | 
  4 | #define JSI_HOST_FUNCTION(NAME)   \


❌  (/Users/brettbest/Library/Developer/Xcode/DerivedData/Reproducer-favipxwwmbqszdfdwlhacyleizcj/Build/Products/Debug-iphonesimulator/React-jsi/jsi.framework/Headers/decorator.h:10:10)

   8 | #pragma once
   9 | 
> 10 | #include <tuple>
     |          ^ 'tuple' file not found
  11 | 
  12 | #include <jsi/instrumentation.h>
  13 | #include <jsi/jsi.h>


❌  (ios/Reproducer/noop-file.swift:6:8)

  4 | //
  5 | 
> 6 | import RNScreens
    |        ^ could not build Objective-C module 'RNScreens'
  7 | 


❌  (/Users/brettbest/Library/Developer/Xcode/DerivedData/Reproducer-favipxwwmbqszdfdwlhacyleizcj/Build/Products/Debug-iphonesimulator/RNScreens/RNScreens.framework/Headers/RNScreensTurboModule.h:1:10)

> 1 | #include <array>
    |          ^ 'array' file not found
  2 | #include <jsi/jsi.h>
  3 | 
  4 | #define JSI_HOST_FUNCTION(NAME)   \


❌  (/Users/brettbest/Library/Developer/Xcode/DerivedData/Reproducer-favipxwwmbqszdfdwlhacyleizcj/Build/Products/Debug-iphonesimulator/React-jsi/jsi.framework/Headers/decorator.h:10:10)

   8 | #pragma once
   9 | 
> 10 | #include <tuple>
     |          ^ 'tuple' file not found
  11 | 
  12 | #include <jsi/instrumentation.h>
  13 | #include <jsi/jsi.h>


❌  (ios/Reproducer/noop-file.swift:6:8)

  4 | //
  5 | 
> 6 | import RNScreens
    |        ^ could not build Objective-C module 'RNScreens'
  7 | 

Steps to reproduce

  1. Download the project linked, set Xcode 15.4 using xcode-select (haven't tested other Xcode versions)
  2. cd into it
  3. Run npx expo run:ios
  4. Observe the build errors

Snack or a link to a repository

https://www.icloud.com/iclouddrive/0f302pmEmM-cWmg6lRoATfeuw#RNScreens-Issue-Reproducer

Screens version

3.31.1

React Native version

0.74.1

Platforms

iOS

JavaScript runtime

Hermes

Workflow

None

Architecture

None

Build type

None

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added the Platform: iOS This issue is specific to iOS label May 24, 2024
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Missing repro This issue need minimum repro scenario label May 24, 2024
@Brett-Best
Copy link
Contributor Author

Brett-Best commented May 27, 2024

The underlying cause seems to be that RNScreensTurboModule.h is a C++ header which is exposed publicly..
I modified the pod spec to change it from a public header to a project header and that fixed the compilation issue.
s.project_header_files = "cpp/**/*.h"

kkafar pushed a commit that referenced this issue Jun 4, 2024
## Description

Fixes
#2158 by
making C++ headers project instead of public.
Original code sample (in the issue) can be updated to include this
change verifying the fix.

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this issue Oct 9, 2024
## Description

Fixes
software-mansion#2158 by
making C++ headers project instead of public.
Original code sample (in the issue) can be updated to include this
change verifying the fix.

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant