diff --git a/.github/workflows/google-utilities.yml b/.github/workflows/google-utilities.yml index c0c4077..4da4041 100644 --- a/.github/workflows/google-utilities.yml +++ b/.github/workflows/google-utilities.yml @@ -80,9 +80,15 @@ jobs: run: | sudo xcode-select -s '/Applications/Xcode_16.2.app/Contents/Developer' xcodebuild -list - - name: Install Simulator - if: matrix.target == 'iOS' || matrix.target == 'tvOS' - run: xcodebuild -downloadPlatform ${{ matrix.target }} + - name: Install simulator SDKs + if: matrix.target != 'macOS' && matrix.target != 'catalyst' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3 + with: + timeout_minutes: 15 + max_attempts: 5 + retry_wait_seconds: 120 + continue_on_error: true + command: xcodebuild -downloadPlatform ${{ matrix.target }} - name: iOS Unit Tests run: scripts/third_party/travis/retry.sh scripts/build.sh GoogleUtilities-Package ${{ matrix.target }} spm diff --git a/GoogleUtilities/SwizzlerTestHelpers/GULRuntimeSnapshot.m b/GoogleUtilities/SwizzlerTestHelpers/GULRuntimeSnapshot.m index e358b25..05f82c6 100644 --- a/GoogleUtilities/SwizzlerTestHelpers/GULRuntimeSnapshot.m +++ b/GoogleUtilities/SwizzlerTestHelpers/GULRuntimeSnapshot.m @@ -58,29 +58,43 @@ - (NSString *)description { } - (void)capture { - int numberOfClasses = objc_getClassList(NULL, 0); - Class *classList = (Class *)malloc(numberOfClasses * sizeof(Class)); - numberOfClasses = objc_getClassList(classList, numberOfClasses); + int bufferLen = objc_getClassList(NULL, 0); + if (bufferLen <= 0) { + return; + } + Class *classList = (Class *)calloc(bufferLen, sizeof(Class)); + if (classList == NULL) { + return; + } + int numberOfClasses = objc_getClassList(classList, bufferLen); + int count = MIN(bufferLen, numberOfClasses); // If we should track specific classes, then there's no need to figure out all ObjC classes. if (_classes) { for (Class aClass in _classes) { NSString *classString = NSStringFromClass(aClass); - GULRuntimeClassSnapshot *classSnapshot = - [[GULRuntimeClassSnapshot alloc] initWithClass:aClass]; - _classSnapshots[classString] = classSnapshot; - [classSnapshot capture]; - _runningHash ^= [classSnapshot hash]; + if (classString) { + GULRuntimeClassSnapshot *classSnapshot = + [[GULRuntimeClassSnapshot alloc] initWithClass:aClass]; + _classSnapshots[classString] = classSnapshot; + [classSnapshot capture]; + _runningHash ^= [classSnapshot hash]; + } } } else { - for (int i = 0; i < numberOfClasses; i++) { + for (int i = 0; i < count; i++) { Class aClass = classList[i]; + if (aClass == Nil) { + continue; + } NSString *classString = NSStringFromClass(aClass); - GULRuntimeClassSnapshot *classSnapshot = - [[GULRuntimeClassSnapshot alloc] initWithClass:aClass]; - _classSnapshots[classString] = classSnapshot; - [classSnapshot capture]; - _runningHash ^= [classSnapshot hash]; + if (classString) { + GULRuntimeClassSnapshot *classSnapshot = + [[GULRuntimeClassSnapshot alloc] initWithClass:aClass]; + _classSnapshots[classString] = classSnapshot; + [classSnapshot capture]; + _runningHash ^= [classSnapshot hash]; + } } } free(classList);