diff --git a/.github/workflows/cocoapods-lint.yml b/.github/workflows/cocoapods-lint.yml index 095b07107..9918e3723 100644 --- a/.github/workflows/cocoapods-lint.yml +++ b/.github/workflows/cocoapods-lint.yml @@ -29,6 +29,8 @@ jobs: config: "" - platform: watchOS config: "" + - platform: visionOS + config: "" steps: - name: Checkout Code uses: actions/checkout@v4 @@ -41,6 +43,20 @@ jobs: - name: Install CocoaPods run: sudo gem install cocoapods + - name: Use Latest Stable Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Install visionOS Platform + if: matrix.platform == 'visionOS' + shell: bash + run: | + # See https://github.com/actions/runner-images/issues/8144#issuecomment-1902072070 + defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES + defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES + xcodebuild -downloadPlatform visionOS + - name: Lint Podspec id: lint run: | diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 52ddbe762..ed6da015b 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -20,6 +20,7 @@ jobs: - watchOS - tvOS - mac-catalyst + - visionOS steps: - name: Checkout Code uses: actions/checkout@v4 @@ -30,7 +31,7 @@ jobs: xcode-version: latest-stable - name: Run Unit Tests - uses: bamx23/xcodebuild@node20 + uses: bamx23/xcodebuild@vision-os with: workspace: ".swiftpm/xcode/package.xcworkspace" scheme: "KSCrash-Package" diff --git a/KSCrash.podspec b/KSCrash.podspec index 1a2ad7c60..d2a332a07 100644 --- a/KSCrash.podspec +++ b/KSCrash.podspec @@ -10,6 +10,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.13' s.tvos.deployment_target = '11.0' s.watchos.deployment_target = '4.0' + s.visionos.deployment_target = '1.0' s.source = { :git => "https://github.com/kstenerud/KSCrash.git", :tag=>s.version.to_s } s.frameworks = 'Foundation' s.libraries = 'c++', 'z' diff --git a/Sources/KSCrashCore/include/KSSystemCapabilities.h b/Sources/KSCrashCore/include/KSSystemCapabilities.h index 0ba0afae9..c39e84b88 100644 --- a/Sources/KSCrashCore/include/KSSystemCapabilities.h +++ b/Sources/KSCrashCore/include/KSSystemCapabilities.h @@ -35,10 +35,16 @@ #define KSCRASH_HOST_ANDROID 1 #endif +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION +#define KSCRASH_HOST_VISION 1 +#else +#define KSCRASH_HOST_VISION 0 +#endif + #define KSCRASH_HOST_IOS (KSCRASH_HOST_APPLE && TARGET_OS_IOS) #define KSCRASH_HOST_TV (KSCRASH_HOST_APPLE && TARGET_OS_TV) #define KSCRASH_HOST_WATCH (KSCRASH_HOST_APPLE && TARGET_OS_WATCH) -#define KSCRASH_HOST_MAC (KSCRASH_HOST_APPLE && TARGET_OS_MAC && !(TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH)) +#define KSCRASH_HOST_MAC (KSCRASH_HOST_APPLE && TARGET_OS_MAC && !(TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_VISION)) #if KSCRASH_HOST_APPLE #define KSCRASH_CAN_GET_MAC_ADDRESS 1 @@ -66,13 +72,13 @@ #define KSCRASH_HAS_STRNSTR 0 #endif -#if KSCRASH_HOST_IOS || KSCRASH_HOST_TV || KSCRASH_HOST_WATCH +#if KSCRASH_HOST_IOS || KSCRASH_HOST_TV || KSCRASH_HOST_WATCH || KSCRASH_HOST_VISION #define KSCRASH_HAS_UIKIT 1 #else #define KSCRASH_HAS_UIKIT 0 #endif -#if KSCRASH_HOST_IOS || KSCRASH_HOST_TV +#if KSCRASH_HOST_IOS || KSCRASH_HOST_TV || KSCRASH_HOST_VISION #define KSCRASH_HAS_UIAPPLICATION 1 #else #define KSCRASH_HAS_UIAPPLICATION 0 @@ -90,13 +96,13 @@ #define KSCRASH_HAS_MESSAGEUI 0 #endif -#if KSCRASH_HOST_IOS || KSCRASH_HOST_TV +#if KSCRASH_HOST_IOS || KSCRASH_HOST_TV || KSCRASH_HOST_VISION #define KSCRASH_HAS_UIDEVICE 1 #else #define KSCRASH_HAS_UIDEVICE 0 #endif -#if KSCRASH_HOST_IOS || KSCRASH_HOST_MAC || KSCRASH_HOST_TV +#if KSCRASH_HOST_IOS || KSCRASH_HOST_MAC || KSCRASH_HOST_TV || KSCRASH_HOST_VISION #define KSCRASH_HAS_ALERTVIEW 1 #else #define KSCRASH_HAS_ALERTVIEW 0 @@ -114,32 +120,32 @@ #define KSCRASH_HAS_NSALERT 0 #endif -#if KSCRASH_HOST_IOS || KSCRASH_HOST_MAC +#if KSCRASH_HOST_IOS || KSCRASH_HOST_MAC || KSCRASH_HOST_VISION #define KSCRASH_HAS_MACH 1 #else #define KSCRASH_HAS_MACH 0 #endif // WatchOS signal is broken as of 3.1 -#if KSCRASH_HOST_ANDROID || KSCRASH_HOST_IOS || KSCRASH_HOST_MAC || KSCRASH_HOST_TV +#if KSCRASH_HOST_ANDROID || KSCRASH_HOST_IOS || KSCRASH_HOST_MAC || KSCRASH_HOST_TV || KSCRASH_HOST_VISION #define KSCRASH_HAS_SIGNAL 1 #else #define KSCRASH_HAS_SIGNAL 0 #endif -#if KSCRASH_HOST_ANDROID || KSCRASH_HOST_MAC || KSCRASH_HOST_IOS +#if KSCRASH_HOST_ANDROID || KSCRASH_HOST_MAC || KSCRASH_HOST_IOS || KSCRASH_HOST_VISION #define KSCRASH_HAS_SIGNAL_STACK 1 #else #define KSCRASH_HAS_SIGNAL_STACK 0 #endif -#if KSCRASH_HOST_MAC || KSCRASH_HOST_IOS || KSCRASH_HOST_TV +#if KSCRASH_HOST_MAC || KSCRASH_HOST_IOS || KSCRASH_HOST_TV || KSCRASH_HOST_VISION #define KSCRASH_HAS_THREADS_API 1 #else #define KSCRASH_HAS_THREADS_API 0 #endif -#if KSCRASH_HOST_MAC || KSCRASH_HOST_IOS || KSCRASH_HOST_TV +#if KSCRASH_HOST_MAC || KSCRASH_HOST_IOS || KSCRASH_HOST_TV || KSCRASH_HOST_VISION #define KSCRASH_HAS_REACHABILITY 1 #else #define KSCRASH_HAS_REACHABILITY 0 diff --git a/Sources/KSCrashFilters/KSCrashReportFilterAppleFmt.m b/Sources/KSCrashFilters/KSCrashReportFilterAppleFmt.m index cf57dca79..292cc418f 100644 --- a/Sources/KSCrashFilters/KSCrashReportFilterAppleFmt.m +++ b/Sources/KSCrashFilters/KSCrashReportFilterAppleFmt.m @@ -26,11 +26,12 @@ #import "KSCrashReportFilterAppleFmt.h" - +#import "KSSystemCapabilities.h" #import #import #include +#include #import "KSCrashReportFields.h" #import "KSJSONCodecObjC.h" @@ -264,12 +265,28 @@ - (NSString*) CPUType:(NSString*) CPUArch isSystemInfoHeader:(BOOL) isSystemInfo - (NSString*) CPUArchForMajor:(cpu_type_t) majorCode minor:(cpu_subtype_t) minorCode { -#ifdef __APPLE__ +#if KSCRASH_HOST_APPLE // In Apple platforms we can use this function to get the name of a particular architecture - const NXArchInfo* info = NXGetArchInfoFromCpuType(majorCode, minorCode); - if (info && info->name) { - return [[NSString alloc] initWithUTF8String: info->name]; +#if !KSCRASH_HOST_VISION + if(@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 8.0, *)) +#endif + { + const char *archName = macho_arch_name_for_cpu_type(majorCode, minorCode); + if(archName) + { + return [[NSString alloc] initWithUTF8String:archName]; + } } +#if !KSCRASH_HOST_VISION + else + { + const NXArchInfo* info = NXGetArchInfoFromCpuType(majorCode, minorCode); + if (info && info->name) + { + return [[NSString alloc] initWithUTF8String:info->name]; + } + } +#endif #endif switch(majorCode) diff --git a/Sources/KSCrashRecordingCore/KSCPU.c b/Sources/KSCrashRecordingCore/KSCPU.c index f67c45bbf..1a787b76f 100644 --- a/Sources/KSCrashRecordingCore/KSCPU.c +++ b/Sources/KSCrashRecordingCore/KSCPU.c @@ -31,6 +31,7 @@ #include #include +#include //#define KSLogger_LocalLevel TRACE #include "KSLogger.h" @@ -38,8 +39,19 @@ const char* kscpu_currentArch(void) { - const NXArchInfo* archInfo = NXGetLocalArchInfo(); - return archInfo == NULL ? NULL : archInfo->name; +#if !KSCRASH_HOST_VISION + if(__builtin_available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 8.0, *)) +#endif + { + return macho_arch_name_for_mach_header(NULL); + } +#if !KSCRASH_HOST_VISION + else + { + const NXArchInfo* archInfo = NXGetLocalArchInfo(); + return archInfo == NULL ? NULL : archInfo->name; + } +#endif } #if KSCRASH_HAS_THREADS_API