diff --git a/Example/testHotUpdate/ios/Podfile.lock b/Example/testHotUpdate/ios/Podfile.lock index a89c746..ceb1cb3 100644 --- a/Example/testHotUpdate/ios/Podfile.lock +++ b/Example/testHotUpdate/ios/Podfile.lock @@ -337,7 +337,7 @@ SPEC CHECKSUMS: React-jsi: 32285a21b1b24c36060493ed3057a34677d58d09 React-jsiexecutor: 8909917ff7d8f21a57e443a866fd8d4560e50c65 React-jsinspector: 111d7d342b07a904c400592e02a2b958f1098b60 - react-native-update: dd1ae7615b2281c9f2cd842ab672593074999549 + react-native-update: 5efc26c6af746154a6b7f7c4c073b9ff3f418322 React-RCTActionSheet: 89b037c0fb7d2671607cb645760164e7e0c013f6 React-RCTAnimation: e3cefa93c38c004c318f7ec04b883eb14b8b8235 React-RCTBlob: d26ac0e313fbf14e7203473fd593ccaaeee8329e diff --git a/ios/RCTHotUpdate/RCTHotUpdate.m b/ios/RCTHotUpdate/RCTHotUpdate.m index 6cb0728..c9be3e2 100644 --- a/ios/RCTHotUpdate/RCTHotUpdate.m +++ b/ios/RCTHotUpdate/RCTHotUpdate.m @@ -470,9 +470,14 @@ RCT_EXPORT_METHOD(markSuccess) #if DEBUG return @"0"; #else - // To be replaced by scripts/generateiOSBuildTime.sh - NSString *pushy_build_time = 1570370091 - return pushy_build_time; + static NSString *buildTime; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSString *buildTimePath = [[NSBundle mainBundle] pathForResource:@"pushy_build_time" ofType:@"txt"]; + buildTime = [[NSString stringWithContentsOfFile:buildTimePath encoding:NSUTF8StringEncoding error:nil] + stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; + }); + return buildTime; #endif } diff --git a/ios/pushy_build_time.txt b/ios/pushy_build_time.txt new file mode 100644 index 0000000..22b9a64 --- /dev/null +++ b/ios/pushy_build_time.txt @@ -0,0 +1 @@ +1570371472 diff --git a/react-native-update.podspec b/react-native-update.podspec index fed95a8..d6371e1 100644 --- a/react-native-update.podspec +++ b/react-native-update.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.libraries = 'bz2', 'z' s.vendored_libraries = 'RCTHotUpdate/libRCTHotUpdate.a' s.pod_target_xcconfig = { 'USER_HEADER_SEARCH_PATHS' => '"$(SRCROOT)/../node_modules/react-native-update/ios"' } - + s.resource = 'ios/pushy_build_time.txt' s.script_phase = { :name => 'Generate build time', :script => '../../node_modules/react-native-update/scripts/generateiOSBuildTime.sh', :execution_position => :before_compile } s.dependency 'React' diff --git a/scripts/generateiOSBuildTime.sh b/scripts/generateiOSBuildTime.sh index b069190..4914aed 100755 --- a/scripts/generateiOSBuildTime.sh +++ b/scripts/generateiOSBuildTime.sh @@ -1,9 +1,5 @@ #!/bin/bash set -x -# DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH -# date +%s > "$DEST/pushy_build_time.txt" -OLD_TEXT="NSString \*pushy_build_time" -NEW_TEXT=" NSString \*pushy_build_time = @\"$(date +%s)\";" -TARGET_FILE="../../node_modules/react-native-update/ios/RCTHotUpdate/RCTHotUpdate.m" -sed -i '' -e "s/.*$OLD_TEXT.*/$NEW_TEXT/" "$TARGET_FILE" \ No newline at end of file +DEST="../../node_modules/react-native-update/ios" +date +%s > "$DEST/pushy_build_time.txt" \ No newline at end of file