jpudysz / react-native-unistyles

Level up your React Native StyleSheet
https://unistyl.es
MIT License
1.65k stars 45 forks source link

[V3] Can't build app on EAS with USE_FRAMEWORKS #371

Open rainerllera opened 1 day ago

rainerllera commented 1 day ago

Description

Heya! I'm migrating from Unistyles 2 to v3 beta.

When building an app on EAS with V3 + NitroModules etc, the build can't complete.

My app uses USE_FRAMEWORKS because it is required by react-native-firebase, which is a commonly used library.

First issues were related to react-native-nitro-modules, which has had a couple of related issues (see 218 and 219).

Here's an example of the nitro errors I was getting:

❌  (ios/Pods/RCT-Folly/folly/portability/Config.h:20:10)

  18 | 
  19 | #ifndef FOLLY_NO_CONFIG
> 20 | #include <folly/folly-config.h>
     |          ^ 'folly/folly-config.h' file not found
  21 | #endif
  22 | 
  23 | #if __has_include(<features.h>)

❌  (node_modules/react-native-nitro-modules/cpp/core/ArrayBuffer.hpp:11:10)

   9 | 
  10 | #include "OwningReference.hpp"
> 11 | #include <jsi/jsi.h>
     |          ^ could not build module 'jsi'
  12 | #include <thread>
  13 | 
  14 | namespace margelo::nitro {
...
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸   EmitSwiftModule normal arm64 (in target 'NitroModules' from project 'Pods')
▸   SwiftEmitModule normal arm64 Emitting\ module\ for\ NitroModules (in target 'NitroModules' from project 'Pods')
...
▸ (3 failures)
** ARCHIVE FAILED **

I was able to avoid the errors when compiling the nitro modules pod by using this patch.

After that, similar issues have come, but this time when compiling Unistyles:

❌  (node_modules/react-native/React/Base/RCTBridge+Inspector.h:11:9)

   9 | 
  10 | #ifdef __cplusplus
> 11 | #import <jsinspector-modern/ReactCdp.h>
     |         ^ 'jsinspector-modern/ReactCdp.h' file not found
  12 | #endif
  13 | 
  14 | @interface RCTBridge (Inspector)

❌  (node_modules/react-native-unistyles/ios/Unistyles.h:4:9)

  2 | 
  3 | #import "jsi/jsi.h"
> 4 | #import <React/RCTUtils.h>
    |         ^ could not build module 'React'
  5 |
... 
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸   EmitSwiftModule normal arm64 (in target 'Unistyles' from project 'Pods')
▸   SwiftEmitModule normal arm64 Emitting\ module\ for\ Unistyles (in target 'Unistyles' from project 'Pods')
...
▸ (3 failures)
** ARCHIVE FAILED **

After doing some digging, I found out the expo team had some similar issues earlier this year with their expo-dev-client and expo-dev-launcher packages. I think the way they solved it was to handle resolutions in their podspecs considering whether USE_FRAMEWORKS was present or not. Please see 28209, 27414)

They fixed them in this PR

I don't really know much about how all of this works, but thought it may be worth having a look. I think a lot of people like me are kinda forced to set:

"expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static",

          },

in our projects by other libraries, so it would be awesome if unistyles 3/nitro could support this! Unfortunately I don't have access to an apple pc rn so can't debug with a local build.

Apologies for not providing a minimal repro yet, I haven't reproduced outside of my own app. I'll try to provide a minimal one for it soon. as I suspect that a newly created expo app with just the above configuration "useFrameworks": "static" should trigger the errors.

Steps to Reproduce

TBD

Snack or Repository Link (Optional)

No response

Unistyles Version

3.0.0.beta1

React Native Version

0.76.3

Platforms

iOS

Expo

Yes

ice-cap0 commented 14 hours ago

getting the same error

mrousavy commented 13 hours ago

@jpudysz i'll fix this in Nitro, dont worry