Skip to content

Improve the script that patches the Pods inside post_install hook #14240

@pinarol

Description

@pinarol

We have a post_install hook in the Podfile and have a piece of Script there that patches a couple of files from React Native.

        puts 'Patching RCTShadowView to fix nested group block - it could be removed after upgrade to 0.62'
        %x(patch "#{project_root}/Pods/React-Core/React/Views/RCTShadowView.m" < "#{project_root}/patches/react-native+0.61.5.patch")
        puts 'Patching RCTActionSheet to add possibility to disable action sheet buttons -
        it could be removed once PR with that functionality will be merged into RN'
        %x(patch "#{project_root}/Pods/React-RCTActionSheet/RCTActionSheetManager.m" < "#{project_root}/patches/react-native+0.61.5.patch")

Currently when it fails, it fails silently and it is hard to notice these kinds of issues. So, instead of using %x(...) can we experiment with replacing that line with system('patch ... < ...') || exit(1). system(...) returns the exit value of the shell so it can help us detecting when the patch fails. But, we should make sure it is not producing false positives and causing the termination of the process unnecessarily.

To Test:

Clear Pods folder
cd to Script folder and run bundle exec pod install
Check the logs to see that no errors are produced during patching
Open the patched file /Users/pinarolguc/Development/WordPress-iOS/Pods/React-RCTActionSheet/RCTActionSheetManager.m make sure this line exists:
NSArray<NSNumber *> *disabledButtonIndices = [RCTConvert NSArray:options[@"disabledButtonIndices"]];

run bundle exec pod install again and make sure it is not producing errors

clear Pods folder
run rake dependencies in the root folder(WordPress-iOS)
Check the logs again

run rake dependencies again and make sure it is not producing errors

bonus: open the gutenberg editor and see the mover buttons getting disabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolingBuild, Release, and Validation Tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions