-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Fix pod install for swift libs using new arch #38121
Fix pod install for swift libs using new arch #38121
Conversation
@@ -139,7 +139,7 @@ def use_react_native! ( | |||
pod 'Yoga', :path => "#{prefix}/ReactCommon/yoga", :modular_headers => true | |||
|
|||
pod 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec" | |||
pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec" | |||
pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec", :modular_headers => true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding "DEFINES_MODULE" => "YES"
to s.pod_target_xcconfig
in packages/react-native/third-party-podspecs/glog.podspec
I still get the following error:
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `MyNativeView` depends upon `glog`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, glog is a different beast as it is a c++ library we don't own and that does not actually support Cocoapods. So we are doing some black magic to make it work.
Base commit: 0bd6b28 |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in a4a0655. |
Summary: This fixes a bug that started with React Native 0.72.0 when using the new architecture and installing a native lib that has Swift code (in my case, `datadog/mobile-react-native`). Running `pod install` errors with the following output (`DatadogSDKReactNative` is the pod containing the Swift code): ``` [...] Analyzing dependencies Downloading dependencies Installing DatadogSDKReactNative 1.8.0-rc0 [!] The following Swift pods cannot yet be integrated as static libraries: The Swift pod `DatadogSDKReactNative` depends upon `React-Fabric`, `React-graphics`, `React-utils`, and `React-debug`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies. ``` Indeed, this pods were added as dependencies in `packages/react-native/scripts/cocoapods/new_architecture.rb` but do not define modules contrary to the other pods in the list. This PR is solving a problem that already occured in the past and was solved here: #33743 It's a new implementation for the PR initially opened here: #38039 ## Changelog: [IOS] [FIXED] - Fix pod install for libraries using Swift code when the new architecture is enabled Pull Request resolved: #38121 Test Plan: 1. Clone [this](https://github.com/louiszawadzki/react-native) repo 2. From `main`, add a Swift file to the `MyNativeView` native module in the RN tester app (see inspiration from [this commit](fortmarek@26958fc)) 3. Try to run `RCT_NEW_ARCH_ENABLED=1 USE_HERMES=0 bundle exec pod install` inside the `packages/rn-tester` 4. Observe errors 5. Apply [the commit](7b7c3ff) from this PR 6. Both pod install and the subsequent build should succeed. 7. Revert the changes and repeat steps 2 to 6 with `RCT_NEW_ARCH_ENABLED=1 USE_HERMES=1 bundle exec pod install` Reviewed By: cortinico Differential Revision: D47127854 Pulled By: cipolleschi fbshipit-source-id: bf7f65e0d126195a76a0fafbe2f3172f00d5adc1 # Conflicts: # packages/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec
Summary: This fixes a bug that started with React Native 0.72.0 when using the new architecture and installing a native lib that has Swift code (in my case, `datadog/mobile-react-native`). Running `pod install` errors with the following output (`DatadogSDKReactNative` is the pod containing the Swift code): ``` [...] Analyzing dependencies Downloading dependencies Installing DatadogSDKReactNative 1.8.0-rc0 [!] The following Swift pods cannot yet be integrated as static libraries: The Swift pod `DatadogSDKReactNative` depends upon `React-Fabric`, `React-graphics`, `React-utils`, and `React-debug`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies. ``` Indeed, this pods were added as dependencies in `packages/react-native/scripts/cocoapods/new_architecture.rb` but do not define modules contrary to the other pods in the list. This PR is solving a problem that already occured in the past and was solved here: facebook#33743 It's a new implementation for the PR initially opened here: facebook#38039 ## Changelog: [IOS] [FIXED] - Fix pod install for libraries using Swift code when the new architecture is enabled Pull Request resolved: facebook#38121 Test Plan: 1. Clone [this](https://github.com/louiszawadzki/react-native) repo 2. From `main`, add a Swift file to the `MyNativeView` native module in the RN tester app (see inspiration from [this commit](fortmarek@26958fc)) 3. Try to run `RCT_NEW_ARCH_ENABLED=1 USE_HERMES=0 bundle exec pod install` inside the `packages/rn-tester` 4. Observe errors 5. Apply [the commit](facebook@7b7c3ff) from this PR 6. Both pod install and the subsequent build should succeed. 7. Revert the changes and repeat steps 2 to 6 with `RCT_NEW_ARCH_ENABLED=1 USE_HERMES=1 bundle exec pod install` Reviewed By: cortinico Differential Revision: D47127854 Pulled By: cipolleschi fbshipit-source-id: bf7f65e0d126195a76a0fafbe2f3172f00d5adc1 # Conflicts: # packages/react-native/ReactCommon/react/renderer/debug/React-rendererdebug.podspec
posting an update here so it's easier to catch up once @cipolleschi is back: this commit only works on Xcode >=14.3, and breaks for both new and old arch for anything lower (see #38294). To discuss the general situation and approach, there's now this react-native-community/discussions-and-proposals#687 - but I'm writing a comment here because we need to decide two things:
|
This reverts commit 7a4ae79.
Summary:
This fixes a bug that started with React Native 0.72.0 when using the new architecture and installing a native lib that has Swift code (in my case,
@datadog/mobile-react-native
).Running
pod install
errors with the following output (DatadogSDKReactNative
is the pod containing the Swift code):Indeed, this pods were added as dependencies in
packages/react-native/scripts/cocoapods/new_architecture.rb
but do not define modules contrary to the other pods in the list.This PR is solving a problem that already occured in the past and was solved here: #33743
It's a new implementation for the PR initially opened here: #38039
Changelog:
[IOS] [FIXED] - Fix pod install for libraries using Swift code when the new architecture is enabled
Test Plan:
main
, add a Swift file to theMyNativeView
native module in the RN tester app (see inspiration from this commit)RCT_NEW_ARCH_ENABLED=1 USE_HERMES=0 bundle exec pod install
inside thepackages/rn-tester
RCT_NEW_ARCH_ENABLED=1 USE_HERMES=1 bundle exec pod install