From e7cd41438d975ec710431da1c557aaa32dc93ac8 Mon Sep 17 00:00:00 2001 From: Oscar Bonilla <6f6231@gmail.com> Date: Wed, 12 Jan 2022 10:21:09 -0800 Subject: [PATCH 1/2] Unify Xcode version in a single place It was too easy to bump it in a GitHub action workflow and then forget to bump it in the other workflows. Signed-off-by: Oscar Bonilla <6f6231@gmail.com> --- .github/workflows/PR.yml | 12 ++++++------ .github/workflows/master.yml | 12 ++++++------ .github/workflows/release.yml | 12 ++++++------ bp/src/BPConstants.h | 2 +- scripts/bpversion.sh | 2 ++ xcode-version | 1 + 6 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 xcode-version diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 03a469a1..c9b6eb08 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -10,8 +10,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.1 - run: sudo xcode-select -s /Applications/Xcode_13.1.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh instance_tests1 - name: Capture xcresult files @@ -29,8 +29,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.1 - run: sudo xcode-select -s /Applications/Xcode_13.1.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh instance_tests2 - name: Capture xcresult files @@ -48,8 +48,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.1 - run: sudo xcode-select -s /Applications/Xcode_13.1.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh runner_tests - name: Capture xcresult files diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 609f9a49..d64b9faa 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -15,8 +15,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.0 - run: sudo xcode-select -s /Applications/Xcode_13.0.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh instance_tests1 - name: Capture xcresult files @@ -34,8 +34,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.0 - run: sudo xcode-select -s /Applications/Xcode_13.0.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh instance_tests2 - name: Capture xcresult files @@ -53,8 +53,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.0 - run: sudo xcode-select -s /Applications/Xcode_13.0.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh runner_tests - name: Capture xcresult files diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3369c4f..5c9cca89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,8 +13,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.0 - run: sudo xcode-select -s /Applications/Xcode_13.0.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh instance_tests1 - name: Capture xcresult files @@ -32,8 +32,8 @@ jobs: steps: # actions/checkout@v2 but we use the SHA1 because tags can be re-written in git - uses: actions/checkout@722adc63f1aa60a57ec37892e133b1d319cae598 - - name: Select Xcode 13.0 - run: sudo xcode-select -s /Applications/Xcode_13.0.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh instance_tests2 - name: Capture xcresult files @@ -54,8 +54,8 @@ jobs: - name: Report event trigger data run: | echo "Event ${{ github.event_name }}, ref: ${{ github.ref }}" - - name: Select Xcode 13.0 - run: sudo xcode-select -s /Applications/Xcode_13.0.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode_$(cat xcode-version).app - name: Run Bluepill tests run: ./scripts/bluepill.sh runner_tests - name: Capture xcresult files diff --git a/bp/src/BPConstants.h b/bp/src/BPConstants.h index 32e2d6ad..974192b9 100644 --- a/bp/src/BPConstants.h +++ b/bp/src/BPConstants.h @@ -8,9 +8,9 @@ // WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #import +#import "BPVersion.h" #pragma mark - Version Constants -#define BP_DEFAULT_XCODE_VERSION "13.1" #define BP_DEFAULT_RUNTIME "iOS 15.0" #define BP_DEFAULT_BASE_SDK "15.0" diff --git a/scripts/bpversion.sh b/scripts/bpversion.sh index 8424e28b..4d60d1a2 100755 --- a/scripts/bpversion.sh +++ b/scripts/bpversion.sh @@ -9,3 +9,5 @@ test -z "$VERSION" && VERSION=$(cat "$REPO_ROOT/VERSION") echo "#define BP_VERSION \"$VERSION\"" > "$OUT_FILE" XCODE_VERSION=$(xcodebuild -version | awk 'BEGIN {OFS="";} /Xcode/ {version=$2} /Build version/ {build=$3} END {print version, " (", build, ")";}') echo "#define XCODE_VERSION \"$XCODE_VERSION\"" >> "$OUT_FILE" +BP_DEFAULT_XCODE_VERSION=$(cat $REPO_ROOT/xcode-version) +echo "#define BP_DEFAULT_XCODE_VERSION \"$BP_DEFAULT_XCODE_VERSION\"" >> "$OUT_FILE" diff --git a/xcode-version b/xcode-version new file mode 100644 index 00000000..cdb4ac40 --- /dev/null +++ b/xcode-version @@ -0,0 +1 @@ +13.1 From de86dd9527a2c5b5683ba454afa923796daac94c Mon Sep 17 00:00:00 2001 From: Oscar Bonilla <6f6231@gmail.com> Date: Wed, 12 Jan 2022 13:39:36 -0800 Subject: [PATCH 2/2] Fix build Signed-off-by: Oscar Bonilla <6f6231@gmail.com> --- .../BPSampleApp.xcodeproj/project.pbxproj | 8 +++++--- .../xcschemes/BPSampleApp.xcscheme | 2 +- bluepill/bluepill.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/bluepill.xcscheme | 2 +- bp/bp.xcodeproj/project.pbxproj | 6 +++++- .../xcshareddata/xcschemes/bp.xcscheme | 2 +- .../xcshareddata/xcschemes/bplib.xcscheme | 2 +- bp/src/BPConfiguration.m | 13 ++----------- bp/src/BPConstants.h | 1 - bp/src/BPTMDRunnerConnection.m | 18 +++++++++--------- bp/src/BPUtils.h | 5 +++++ bp/src/BPUtils.m | 13 +++++++++++++ scripts/bpversion.sh | 2 -- 13 files changed, 44 insertions(+), 32 deletions(-) diff --git a/BPSampleApp/BPSampleApp.xcodeproj/project.pbxproj b/BPSampleApp/BPSampleApp.xcodeproj/project.pbxproj index be65cc0a..f806af4f 100644 --- a/BPSampleApp/BPSampleApp.xcodeproj/project.pbxproj +++ b/BPSampleApp/BPSampleApp.xcodeproj/project.pbxproj @@ -443,7 +443,7 @@ BAB24F261DB5D45E00867756 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1310; ORGANIZATIONNAME = LinkedIn; TargetAttributes = { BA4BCFC51DC47EC700592FA4 = { @@ -823,6 +823,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -880,6 +881,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1001,7 +1003,7 @@ buildSettings = { DEVELOPMENT_TEAM = 57Y47U492U; INFOPLIST_FILE = BPSampleAppUITests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 10.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = LI.BPSampleAppUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1014,7 +1016,7 @@ buildSettings = { DEVELOPMENT_TEAM = 57Y47U492U; INFOPLIST_FILE = BPSampleAppUITests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 10.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = LI.BPSampleAppUITests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/BPSampleApp/BPSampleApp.xcodeproj/xcshareddata/xcschemes/BPSampleApp.xcscheme b/BPSampleApp/BPSampleApp.xcodeproj/xcshareddata/xcschemes/BPSampleApp.xcscheme index 6028fa6b..0c8aa80d 100644 --- a/BPSampleApp/BPSampleApp.xcodeproj/xcshareddata/xcschemes/BPSampleApp.xcscheme +++ b/BPSampleApp/BPSampleApp.xcodeproj/xcshareddata/xcschemes/BPSampleApp.xcscheme @@ -1,6 +1,6 @@ 11.3 - if (![[[BPUtils getXcodeRuntimeVersion] substringToIndex:4] isEqualToString:@BP_DEFAULT_XCODE_VERSION]) { + if (![BPUtils sameMajorandMinor:[BPUtils getXcodeRuntimeVersion] withVersion:[BPUtils getXcodeBuildtimeVersion]]) { BP_SET_ERROR(errPtr, @"ERROR: Bluepill runtime version %s and compile time version %s are mismatched\n", - [[[BPUtils getXcodeRuntimeVersion] substringToIndex:4] UTF8String], [@BP_DEFAULT_XCODE_VERSION UTF8String]); + [[[BPUtils getXcodeRuntimeVersion] substringToIndex:4] UTF8String], [BPUtils getXcodeBuildtimeVersion]); return NO; } } diff --git a/bp/src/BPConstants.h b/bp/src/BPConstants.h index 974192b9..2b291577 100644 --- a/bp/src/BPConstants.h +++ b/bp/src/BPConstants.h @@ -8,7 +8,6 @@ // WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #import -#import "BPVersion.h" #pragma mark - Version Constants #define BP_DEFAULT_RUNTIME "iOS 15.0" diff --git a/bp/src/BPTMDRunnerConnection.m b/bp/src/BPTMDRunnerConnection.m index 978c6720..b58f777d 100644 --- a/bp/src/BPTMDRunnerConnection.m +++ b/bp/src/BPTMDRunnerConnection.m @@ -87,13 +87,13 @@ - (void)connect { dispatch_async(self.queue, ^{ DTXConnection *connection = connectToTestManager(self.context.runner.device); - + [connection registerDisconnectHandler:^{ // This is called when the task is abruptly terminated (e.g. if the test times out) [self stopVideoRecording:YES]; [BPUtils printInfo:INFO withString:@"DTXConnection disconnected."]; }]; - + [connection xct_handleProxyRequestForInterface:@protocol(XCTMessagingChannel_RunnerToIDE) peerInterface:@protocol(XCTMessagingChannel_IDEToRunner) @@ -183,24 +183,24 @@ - (void)stopVideoRecording:(BOOL)forced } return; } - + if (forced) { [BPUtils printInfo:ERROR withString: @"Found dangling video recording task. Stopping it."]; } - + if (![task isRunning]) { [BPUtils printInfo:ERROR withString:@"Video task exists but it was already terminated with status %d", [task terminationStatus]]; } - + [BPUtils printInfo:INFO withString:@"Stopping recording video."]; [BPUtils printInfo:DEBUGINFO withString:@"Stopping video recording task with pid %d and command: %@", [task processIdentifier], [BPUtils getCommandStringForTask:task]]; [task interrupt]; [task waitUntilExit]; - + if ([task terminationStatus] != 0) { [BPUtils printInfo:ERROR withString:@"Video task was interrupted, but exited with non-zero status %d", [task terminationStatus]]; } - + NSString *filePath = [[task arguments].lastObject componentsSeparatedByString:@" "].lastObject; if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) { [BPUtils printInfo:ERROR withString:@"Video recording file missing, expected at path %@!", filePath]; @@ -344,7 +344,7 @@ - (id)_XCT_testSuite:(NSString *)tests didStartAt:(NSString *)time { - (id)_XCT_testSuite:(NSString *)arg1 didFinishAt:(NSString *)time runCount:(NSNumber *)count withFailures:(NSNumber *)failureCount unexpected:(NSNumber *)unexpectedCount testDuration:(NSNumber *)testDuration totalDuration:(NSNumber *)totalTime { [BPUtils printInfo:DEBUGINFO withString: @"BPTestBundleConnection_XCT_testSuite: %@, didFinishAt: %@, runCount: %@, withFailures: %@, unexpectedCount: %@, testDuration: %@, totalDuration: %@", arg1, time, count, failureCount, unexpectedCount, testDuration, totalTime]; - + if ([self shouldRecordVideo]) { [self stopVideoRecording:YES]; } @@ -405,7 +405,7 @@ - (id)_XCT_launchProcessWithPath:(NSString *)path bundleID:(NSString *)bundleID return nil; } [BPUtils printInfo:DEBUGINFO withString:@"BPTestBundleConnection Launching app: %@ with options %@", bundleID, options]; - + self.appProcessPID = [self.simulator.device launchApplicationWithID:bundleID options:options error:&error]; self.bundleID = bundleID; if (error) { diff --git a/bp/src/BPUtils.h b/bp/src/BPUtils.h index 209f3428..351010c4 100644 --- a/bp/src/BPUtils.h +++ b/bp/src/BPUtils.h @@ -150,6 +150,11 @@ typedef NS_ENUM(int, BPKind) { + (NSString *)getXcodeRuntimeVersion; ++ (NSString *)getXcodeBuildtimeVersion; + ++ (bool)sameMajorandMinor:(NSString * _Nonnull)version1 withVersion:(NSString * _Nonnull)version2; + + typedef BOOL (^BPRunBlock)(void); /*! diff --git a/bp/src/BPUtils.m b/bp/src/BPUtils.m index 3b8bf87b..0299ec7c 100644 --- a/bp/src/BPUtils.m +++ b/bp/src/BPUtils.m @@ -282,6 +282,19 @@ + (NSString *)getXcodeRuntimeVersion { return runTimeVersion; } ++ (NSString *)getXcodeBuildtimeVersion { + return [NSString stringWithUTF8String:XCODE_VERSION]; +} + +// Compare major and minor version version Eg. 11.2 ~ 11.2.1 but 11.2 <> 11.3 ++ (bool)sameMajorandMinor:(NSString * _Nonnull)version1 withVersion:(NSString * _Nonnull)version2 { + NSArray *v1parts = [version1 componentsSeparatedByString:@" "]; + NSArray *v2parts = [version2 componentsSeparatedByString:@" "]; + NSArray *v1versionParts = [[v1parts objectAtIndex:0] componentsSeparatedByString:@"."]; + NSArray *v2versionParts = [[v2parts objectAtIndex:0] componentsSeparatedByString:@"."]; + return [v1versionParts[0] isEqualToString:v2versionParts[0]] && [v1versionParts[1] isEqualToString:v2versionParts[1]]; +} + + (void)saveDebuggingDiagnostics:(NSString *)outputDirectory { BOOL isDir = false; NSFileManager *fm = [NSFileManager defaultManager]; diff --git a/scripts/bpversion.sh b/scripts/bpversion.sh index 4d60d1a2..8424e28b 100755 --- a/scripts/bpversion.sh +++ b/scripts/bpversion.sh @@ -9,5 +9,3 @@ test -z "$VERSION" && VERSION=$(cat "$REPO_ROOT/VERSION") echo "#define BP_VERSION \"$VERSION\"" > "$OUT_FILE" XCODE_VERSION=$(xcodebuild -version | awk 'BEGIN {OFS="";} /Xcode/ {version=$2} /Build version/ {build=$3} END {print version, " (", build, ")";}') echo "#define XCODE_VERSION \"$XCODE_VERSION\"" >> "$OUT_FILE" -BP_DEFAULT_XCODE_VERSION=$(cat $REPO_ROOT/xcode-version) -echo "#define BP_DEFAULT_XCODE_VERSION \"$BP_DEFAULT_XCODE_VERSION\"" >> "$OUT_FILE"