Skip to content

Instantly share code, notes, and snippets.

@chetstone
Created April 15, 2018 23:29
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chetstone/cf02d7a0c16e50933c5c96adb86fad2e to your computer and use it in GitHub Desktop.
Save chetstone/cf02d7a0c16e50933c5c96adb86fad2e to your computer and use it in GitHub Desktop.
Patching React-Native in a script run by npm/yarn postinstall
#!/bin/sh
# Fix RN version 33
yarn list react-native |grep react-native |grep 0.33
if [ $? -eq 0 ];
then
echo "Checking that ReactNative v 33 is patched"
cd node_modules/react-native
patch -N -p1 --dry-run --silent < ../../notes/rn33.3x.patch >/dev/null 2>&1
if [ $? -eq 0 ];
then
# apply the patch
patch -N -p1 < ../../notes/rn33.3x.patch
else
echo "Patch already applied"
fi
else
echo "React Native not version 33, skipping patch"
fi
diff -Naur --exclude='*.plist' react-native.orig/Libraries/Geolocation/RCTLocationObserver.m react-native/Libraries/Geolocation/RCTLocationObserver.m
--- react-native.orig/Libraries/Geolocation/RCTLocationObserver.m 2016-09-23 05:09:36.000000000 -0600
+++ react-native/Libraries/Geolocation/RCTLocationObserver.m 2018-04-15 16:36:14.000000000 -0600
@@ -160,7 +160,7 @@
- (void)timeout:(NSTimer *)timer
{
RCTLocationRequest *request = timer.userInfo;
- NSString *message = [NSString stringWithFormat: @"Unable to fetch location within %zds.", (NSInteger)(timer.timeInterval * 1000.0)];
+ NSString *message = [NSString stringWithFormat: @"Unable to fetch location within %zds.", (long)(timer.timeInterval * 1000.0)];
request.errorBlock(@[RCTPositionError(RCTPositionErrorTimeout, message)]);
[_pendingRequests removeObject:request];
diff -Naur --exclude='*.plist' react-native.orig/Libraries/Image/RCTImageCache.m react-native/Libraries/Image/RCTImageCache.m
--- react-native.orig/Libraries/Image/RCTImageCache.m 2016-09-23 05:09:36.000000000 -0600
+++ react-native/Libraries/Image/RCTImageCache.m 2018-04-15 16:32:27.000000000 -0600
@@ -26,7 +26,7 @@
RCTResizeMode resizeMode, NSString *responseDate)
{
return [NSString stringWithFormat:@"%@|%g|%g|%g|%zd|%@",
- imageTag, size.width, size.height, scale, resizeMode, responseDate];
+ imageTag, size.width, size.height, scale, (long)resizeMode, responseDate];
}
@implementation RCTImageCache
diff -Naur --exclude='*.plist' react-native.orig/Libraries/Text/RCTTextField.m react-native/Libraries/Text/RCTTextField.m
--- react-native.orig/Libraries/Text/RCTTextField.m 2016-09-23 05:09:36.000000000 -0600
+++ react-native/Libraries/Text/RCTTextField.m 2018-04-15 16:35:01.000000000 -0600
@@ -82,7 +82,7 @@
self.selectedTextRange = [self textRangeFromPosition:position toPosition:position];
}
} else if (eventLag > RCTTextUpdateLagWarningThreshold) {
- RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, eventLag);
+ RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, (long)eventLag);
}
}
diff -Naur --exclude='*.plist' react-native.orig/Libraries/Text/RCTTextView.m react-native/Libraries/Text/RCTTextView.m
--- react-native.orig/Libraries/Text/RCTTextView.m 2016-09-23 05:09:36.000000000 -0600
+++ react-native/Libraries/Text/RCTTextView.m 2018-04-15 16:34:19.000000000 -0600
@@ -475,7 +475,7 @@
[self updateContentSize]; //keep the text wrapping when the length of
//the textline has been extended longer than the length of textinputView
} else if (eventLag > RCTTextUpdateLagWarningThreshold) {
- RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, eventLag);
+ RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, (long)eventLag);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment