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

[autolinking] Patch react podspec for swift integration #15299

Merged
merged 9 commits into from Nov 28, 2021

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Nov 25, 2021

Why

there are tons of mixing swift and objc issues in expo-modules-core. e.g.

  • include of non-modular header inside framework module when prebuild expo-modules-core
  • sometimes swift functions cannot be loaded if there are react types.

the root cause is that clang doesn't generate submodules correctly. although clang can transform #import <React/RCTBridge.h> to @import React.RCTBridge;, clang cannot do it right as React.RCTBridge submodule doesn't exist. as swift only know modules, this will cause lots of problems when we use react types in swift.

How

  • patch React-Core.podspec with custom modulemap for clang to generate submodules correctly. (details in code comment)
  • replace original CocoaPods PodTarget monkey patch with Sandbox. this new approach can patch podspec on the fly.

Test Plan

  • CI passed
  • to further check what's the difference for the change, you can enable BUILD_LIBRARY_FOR_DISTRIBUTION for expo-modules-core pod project and check the swiftinterface for ExpoModulesCore.
    e.g. /Users/kudo/Library/Developer/Xcode/DerivedData/BareExpo-brnnteedtepltiasryrqyexlvweu/Build/Products/Debug-iphonesimulator/ExpoModulesCore/ExpoModulesCore.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
@_inheritsConvenienceInitializers @objc final public class ViewModuleWrapper : ExpoModulesCore.RCTViewManager {

before: it's ExpoModulesCore.RCTViewManager

@_inheritsConvenienceInitializers @objc final public class ViewModuleWrapper : React.RCTViewManager {

after: it's React.RCTViewManager

Checklist

  • Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
  • This diff will work correctly for expo build (eg: updated @expo/xdl).
  • This diff will work correctly for expo prebuild & EAS Build (eg: updated a module plugin).

@Kudo Kudo requested a review from tsapeta as a code owner November 25, 2021 03:19
@expo-bot expo-bot added the bot: passed checks ExpoBot has nothing to complain about label Nov 25, 2021
@Kudo
Copy link
Contributor Author

Kudo commented Nov 28, 2021

there was an issue to have a different checksum on CI. the module_map is an absolute path and my path is different to CI. so i've add further patch sandbox.rb to keep original the checksum. the CI is green now, i'm going to merge this and working on the react delegate pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants