From 1a3e637598ccdebbfea100fca83d83eef555f155 Mon Sep 17 00:00:00 2001 From: YoloMao Date: Thu, 1 Feb 2024 17:56:13 +0800 Subject: [PATCH] feat: watchOS/tvOS/visionOS support (#3) * feat: watchOS/tvOS/visionOS support * ci: update ci * feat: release 1.2.0 * ci: update ci * ci: update ci * Revert "ci: update ci" This reverts commit 7d05d504ce25e29483d77f44cb6285b0dea22bab. * ci: update ci * ci: update ci * ci: update ci --- .github/workflows/cocoapods.yml | 2 +- .github/workflows/pod_lint.yml | 25 +++ .github/workflows/spm.yml | 108 +++++++++++++ GrowingUtils.podspec | 4 +- Package.swift | 8 +- Package@swift-5.9.swift | 77 +++++++++ .../GrowingULViewControllerLifecycle.m | 4 + .../GrowingULViewControllerLifecycle.h | 5 +- .../UIApplication+GrowingUtilsTrackerCore.m | 22 ++- ...UIViewController+GrowingUtilsTrackerCore.m | 4 +- .../Extension/GrowingULApplication.m | 22 +-- .../Lifecycle/GrowingULAppLifecycle.m | 57 +++++-- .../include/GrowingTargetConditionals.h | 151 ++++++++++++++++++ .../include/GrowingULAppLifecycle.h | 10 +- .../include/GrowingULApplication.h | 4 +- .../UIApplication+GrowingUtilsTrackerCore.h | 4 +- ...UIViewController+GrowingUtilsTrackerCore.h | 4 +- 17 files changed, 465 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/pod_lint.yml create mode 100644 .github/workflows/spm.yml create mode 100644 Package@swift-5.9.swift create mode 100644 Sources/TrackerCore/include/GrowingTargetConditionals.h diff --git a/.github/workflows/cocoapods.yml b/.github/workflows/cocoapods.yml index 9abc507..ec6afc5 100644 --- a/.github/workflows/cocoapods.yml +++ b/.github/workflows/cocoapods.yml @@ -1,4 +1,4 @@ -name: Cocoapods +name: Cocoapods Trunk Push on: release: types: [published] diff --git a/.github/workflows/pod_lint.yml b/.github/workflows/pod_lint.yml new file mode 100644 index 0000000..fbfc897 --- /dev/null +++ b/.github/workflows/pod_lint.yml @@ -0,0 +1,25 @@ +name: Pod Lint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: macos-13 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Pod Lint + run: pod lib lint GrowingUtils.podspec --allow-warnings --verbose \ No newline at end of file diff --git a/.github/workflows/spm.yml b/.github/workflows/spm.yml new file mode 100644 index 0000000..ee28af2 --- /dev/null +++ b/.github/workflows/spm.yml @@ -0,0 +1,108 @@ +name: SPM + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build-iOS: + runs-on: macos-13 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build + run: | + set -euo pipefail + xcodebuild build -scheme GrowingUtils-Package -destination 'platform=iOS Simulator,name=iPhone 15 Pro Max' \ + | xcbeautify --renderer github-actions + + build-catalyst: + runs-on: macos-13 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build + run: | + set -euo pipefail + xcodebuild build -scheme GrowingUtils-Package -destination 'platform=macOS,variant=Mac Catalyst' \ + | xcbeautify --renderer github-actions + + build-macOS: + runs-on: macos-13 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build + run: | + set -euo pipefail + xcodebuild build -scheme GrowingUtils-Package -destination 'platform=macOS' \ + | xcbeautify --renderer github-actions + + build-watchOS: + runs-on: macos-13 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build + run: | + set -euo pipefail + xcodebuild build -scheme GrowingUtils-Package -destination 'platform=watchOS Simulator,name=Apple Watch Ultra 2 (49mm)' \ + | xcbeautify --renderer github-actions + + build-tvOS: + runs-on: macos-13 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build + run: | + set -euo pipefail + xcodebuild build -scheme GrowingUtils-Package -destination 'platform=tvOS Simulator,name=Apple TV' \ + | xcbeautify --renderer github-actions + + build-visionOS: + runs-on: macos-14 + + steps: + - name: Force Xcode 15 + run: sudo xcode-select -switch /Applications/Xcode_15.2.app + + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Build + run: | + set -euo pipefail + xcodebuild build -scheme GrowingUtils-Package -destination 'platform=visionOS Simulator,name=Apple Vision Pro' \ + | xcbeautify --renderer github-actions \ No newline at end of file diff --git a/GrowingUtils.podspec b/GrowingUtils.podspec index b79357b..d40b096 100644 --- a/GrowingUtils.podspec +++ b/GrowingUtils.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GrowingUtils' - s.version = '1.1.0' + s.version = '1.2.0' s.summary = 'iOS SDK of GrowingIO.' s.description = <<-DESC GrowingAnalytics具备自动采集基本的用户行为事件,比如访问和行为数据等。目前支持代码埋点、无埋点、可视化圈选、热图等功能。 @@ -11,6 +11,8 @@ GrowingAnalytics具备自动采集基本的用户行为事件,比如访问和 s.source = { :git => 'https://github.com/growingio/growingio-sdk-ios-utilities.git', :tag => s.version.to_s } s.ios.deployment_target = '10.0' s.osx.deployment_target = '10.12' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '7.0' s.requires_arc = true s.default_subspec = "TrackerCore" diff --git a/Package.swift b/Package.swift index 193b53c..db1a1c7 100644 --- a/Package.swift +++ b/Package.swift @@ -24,7 +24,13 @@ import PackageDescription let package = Package( name: "GrowingUtils", - platforms: [.iOS(.v10), .macCatalyst(.v13), .macOS(.v10_12)], + platforms: [ + .iOS(.v10), + .macCatalyst(.v13), + .macOS(.v10_12), + .tvOS(.v10), + .watchOS(.v7) + ], products: [ .library( name: "GrowingUtilsTrackerCore", diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift new file mode 100644 index 0000000..cf9977e --- /dev/null +++ b/Package@swift-5.9.swift @@ -0,0 +1,77 @@ +// swift-tools-version:5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +// +// Package.swift +// GrowingAnalytics +// +// Created by YoloMao on 2024/2/1. +// Copyright (C) 2024 Beijing Yishu Technology Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import PackageDescription + +let package = Package( + name: "GrowingUtils", + platforms: [ + .iOS(.v12), + .macCatalyst(.v13), + .macOS(.v10_14), + .tvOS(.v12), + .watchOS(.v7), + .visionOS(.v1) + ], + products: [ + .library( + name: "GrowingUtilsTrackerCore", + targets: ["GrowingUtilsTrackerCore_Wrapper"] + ), + .library( + name: "GrowingUtilsAutotrackerCore", + targets: ["GrowingUtilsAutotrackerCore_Wrapper"] + ), + ], + dependencies: [], + targets: [ + .target( + name: "GrowingUtilsTrackerCore_Wrapper", + dependencies: [.target(name: "GrowingUtilsTrackerCore", + condition: .when(platforms: [.iOS, .macCatalyst, .macOS]))], + path: "SwiftPM-Wrap/TrackerCore-Wrapper" + ), + .target( + name: "GrowingUtilsAutotrackerCore_Wrapper", + dependencies: [.target(name: "GrowingUtilsAutotrackerCore", + condition: .when(platforms: [.iOS, .macCatalyst]))], + path: "SwiftPM-Wrap/AutotrackerCore-Wrapper" + ), + .target( + name: "GrowingUtilsTrackerCore", + dependencies: [], + path: "Sources/TrackerCore", + resources: [.copy("Resources/PrivacyInfo.xcprivacy")], + cSettings: [ + .headerSearchPath("include"), + ] + ), + .target( + name: "GrowingUtilsAutotrackerCore", + dependencies: ["GrowingUtilsTrackerCore"], + path: "Sources/AutotrackerCore", + cSettings: [ + .headerSearchPath("include"), + ] + ), + ] +) diff --git a/Sources/AutotrackerCore/Lifecycle/GrowingULViewControllerLifecycle.m b/Sources/AutotrackerCore/Lifecycle/GrowingULViewControllerLifecycle.m index 3ec96a8..eae7226 100644 --- a/Sources/AutotrackerCore/Lifecycle/GrowingULViewControllerLifecycle.m +++ b/Sources/AutotrackerCore/Lifecycle/GrowingULViewControllerLifecycle.m @@ -17,6 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#import "GrowingTargetConditionals.h" + +#if Growing_USE_UIKIT #import "GrowingULViewControllerLifecycle.h" #import "GrowingULTimeUtil.h" #import "GrowingULSwizzle.h" @@ -266,3 +269,4 @@ - (void)dispatchViewControllerDidDisappear:(UIViewController *)controller { } @end +#endif diff --git a/Sources/AutotrackerCore/include/GrowingULViewControllerLifecycle.h b/Sources/AutotrackerCore/include/GrowingULViewControllerLifecycle.h index 7d8bb6a..b26896c 100644 --- a/Sources/AutotrackerCore/include/GrowingULViewControllerLifecycle.h +++ b/Sources/AutotrackerCore/include/GrowingULViewControllerLifecycle.h @@ -17,9 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import -#import +#import "GrowingTargetConditionals.h" +#if Growing_USE_UIKIT @protocol GrowingULViewControllerLifecycleDelegate @optional @@ -56,3 +56,4 @@ - (void)removeViewControllerLifecycleDelegate:(id)delegate; @end +#endif diff --git a/Sources/TrackerCore/Category/UIApplication+GrowingUtilsTrackerCore.m b/Sources/TrackerCore/Category/UIApplication+GrowingUtilsTrackerCore.m index 4dfceed..5b4ea5f 100644 --- a/Sources/TrackerCore/Category/UIApplication+GrowingUtilsTrackerCore.m +++ b/Sources/TrackerCore/Category/UIApplication+GrowingUtilsTrackerCore.m @@ -17,7 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if __has_include() +#import "GrowingTargetConditionals.h" + +#if Growing_USE_UIKIT #import "UIApplication+GrowingUtilsTrackerCore.h" #import "UIViewController+GrowingUtilsTrackerCore.h" #import "GrowingULApplication.h" @@ -29,7 +31,11 @@ - (nullable UIWindow *)growingul_keyWindow { return nil; } - if (@available(iOS 13.0, *)) { +#if Growing_OS_VISION + if (1) { // if (@available(visionOS 1.0, *)) { +#else + if (@available(iOS 13.0, macCatalyst 13.1, tvOS 13.0, *)) { +#endif for (UIScene *scene in self.connectedScenes) { if (scene.activationState != UISceneActivationStateForegroundActive) { continue; @@ -71,11 +77,15 @@ - (nullable UIViewController *)growingul_topViewController { } - (CGFloat)growingul_statusBarHeight { - if (@available(iOS 13.0, *)) { - return self.growingul_keyWindow.windowScene.statusBarManager.statusBarFrame.size.height; + CGFloat statusBarHeight = 0.0f; +#if Growing_OS_IOS || Growing_OS_MACCATALYST + if (@available(iOS 13.0, macCatalyst 13.1, *)) { + statusBarHeight = self.growingul_keyWindow.windowScene.statusBarManager.statusBarFrame.size.height; + } else { + statusBarHeight = self.statusBarFrame.size.height; } - - return self.statusBarFrame.size.height; +#endif + return statusBarHeight; } @end diff --git a/Sources/TrackerCore/Category/UIViewController+GrowingUtilsTrackerCore.m b/Sources/TrackerCore/Category/UIViewController+GrowingUtilsTrackerCore.m index e02ffa7..f4c382e 100644 --- a/Sources/TrackerCore/Category/UIViewController+GrowingUtilsTrackerCore.m +++ b/Sources/TrackerCore/Category/UIViewController+GrowingUtilsTrackerCore.m @@ -17,7 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if __has_include() +#import "GrowingTargetConditionals.h" + +#if Growing_USE_UIKIT #import "UIViewController+GrowingUtilsTrackerCore.h" @implementation UIViewController (GrowingUtilsTrackerCore) diff --git a/Sources/TrackerCore/Extension/GrowingULApplication.m b/Sources/TrackerCore/Extension/GrowingULApplication.m index 23c3943..12dfc29 100644 --- a/Sources/TrackerCore/Extension/GrowingULApplication.m +++ b/Sources/TrackerCore/Extension/GrowingULApplication.m @@ -24,13 +24,15 @@ @implementation GrowingULApplication + (nullable id)sharedApplication { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" -#if TARGET_OS_OSX - Class class = NSClassFromString(@"NSApplication"); -#elif TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_TV - Class class = NSClassFromString(@"UIApplication"); -#elif TARGET_OS_WATCH - Class class = NSClassFromString(@"WKApplication"); + Class class; +#if Growing_USE_APPKIT + class = NSClassFromString(@"NSApplication"); +#elif Growing_USE_UIKIT + class = NSClassFromString(@"UIApplication"); +#elif Growing_USE_WATCHKIT + class = NSClassFromString(@"WKApplication"); #endif + SEL selector = NSSelectorFromString(@"sharedApplication"); if(!class || ![class respondsToSelector:selector]) { return nil; @@ -40,10 +42,10 @@ + (nullable id)sharedApplication { } + (BOOL)isAppExtension { -#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH - return [[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]; -#elif TARGET_OS_OSX - return NO; +#if Growing_OS_IOS || Growing_OS_TV || Growing_OS_WATCH + return [[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]; +#else + return NO; #endif } diff --git a/Sources/TrackerCore/Lifecycle/GrowingULAppLifecycle.m b/Sources/TrackerCore/Lifecycle/GrowingULAppLifecycle.m index 3ed4e1c..f14edd5 100644 --- a/Sources/TrackerCore/Lifecycle/GrowingULAppLifecycle.m +++ b/Sources/TrackerCore/Lifecycle/GrowingULAppLifecycle.m @@ -60,7 +60,7 @@ + (void)setup { - (void)setupAppStateNotification { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if Growing_USE_UIKIT for (NSString *name in @[ UIApplicationDidFinishLaunchingNotification, UIApplicationWillTerminateNotification]) { @@ -85,14 +85,14 @@ - (void)setupAppStateNotification { object:[GrowingULApplication sharedApplication]]; } } -#elif TARGET_OS_OSX +#elif Growing_USE_APPKIT for (NSString *name in @[ NSApplicationDidFinishLaunchingNotification, NSApplicationWillTerminateNotification]) { [nc addObserver:self selector:@selector(handleProcessLifecycleNotification:) name:name - object:[NSApplication sharedApplication]]; + object:[GrowingULApplication sharedApplication]]; } for (NSString *name in @[ @@ -101,12 +101,33 @@ - (void)setupAppStateNotification { [nc addObserver:self selector:@selector(handleUILifecycleNotification:) name:name - object:[NSApplication sharedApplication]]; + object:[GrowingULApplication sharedApplication]]; + } +#elif Growing_USE_WATCHKIT + if (@available (watchOS 7.0, *)) { + for (NSString *name in @[ + WKApplicationDidFinishLaunchingNotification]) { + [nc addObserver:self + selector:@selector(handleProcessLifecycleNotification:) + name:name + object:[GrowingULApplication sharedApplication]]; + } + + for (NSString *name in @[ + WKApplicationDidBecomeActiveNotification, + WKApplicationWillEnterForegroundNotification, + WKApplicationWillResignActiveNotification, + WKApplicationDidEnterBackgroundNotification]) { + [nc addObserver:self + selector:@selector(handleUILifecycleNotification:) + name:name + object:[GrowingULApplication sharedApplication]]; + } } #endif } -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if Growing_USE_UIKIT - (void)addSceneNotification { if (@available(iOS 13, *)) { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; @@ -143,25 +164,31 @@ - (void)dealloc { - (void)handleProcessLifecycleNotification:(NSNotification *)notification { NSString *name = notification.name; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if Growing_USE_UIKIT if ([name isEqualToString:UIApplicationDidFinishLaunchingNotification]) { [self dispatchApplicationDidFinishLaunching:notification.userInfo]; } else if ([name isEqualToString:UIApplicationWillTerminateNotification]) { [self dispatchApplicationWillTerminate]; } -#elif TARGET_OS_OSX +#elif Growing_USE_APPKIT if ([name isEqualToString:NSApplicationDidFinishLaunchingNotification]) { [self dispatchApplicationDidFinishLaunching:notification.userInfo]; } else if ([name isEqualToString:NSApplicationWillTerminateNotification]) { [self dispatchApplicationWillTerminate]; } +#elif Growing_USE_WATCHKIT + if (@available (watchOS 7.0, *)) { + if ([name isEqualToString:WKApplicationDidFinishLaunchingNotification]) { + [self dispatchApplicationDidFinishLaunching:notification.userInfo]; + } + } #endif } - (void)handleUILifecycleNotification:(NSNotification *)notification { NSString *name = notification.name; -#if TARGET_OS_IOS || TARGET_OS_MACCATALYST +#if Growing_USE_UIKIT if ([name isEqualToString:UIApplicationDidBecomeActiveNotification]) { [self dispatchApplicationDidBecomeActive]; } else if ([name isEqualToString:UIApplicationWillEnterForegroundNotification]) { @@ -171,12 +198,24 @@ - (void)handleUILifecycleNotification:(NSNotification *)notification { } else if ([name isEqualToString:UIApplicationDidEnterBackgroundNotification]) { [self dispatchApplicationDidEnterBackground]; } -#elif TARGET_OS_OSX +#elif Growing_USE_APPKIT if ([name isEqualToString:NSApplicationDidBecomeActiveNotification]) { [self dispatchApplicationDidBecomeActive]; } else if ([name isEqualToString:NSApplicationWillResignActiveNotification]) { [self dispatchApplicationWillResignActive]; } +#elif Growing_USE_WATCHKIT + if (@available (watchOS 7.0, *)) { + if ([name isEqualToString:WKApplicationDidBecomeActiveNotification]) { + [self dispatchApplicationDidBecomeActive]; + } else if ([name isEqualToString:WKApplicationWillEnterForegroundNotification]) { + [self dispatchApplicationWillEnterForeground]; + } else if ([name isEqualToString:WKApplicationWillResignActiveNotification]) { + [self dispatchApplicationWillResignActive]; + } else if ([name isEqualToString:WKApplicationDidEnterBackgroundNotification]) { + [self dispatchApplicationDidEnterBackground]; + } + } #endif } diff --git a/Sources/TrackerCore/include/GrowingTargetConditionals.h b/Sources/TrackerCore/include/GrowingTargetConditionals.h new file mode 100644 index 0000000..5e8f20a --- /dev/null +++ b/Sources/TrackerCore/include/GrowingTargetConditionals.h @@ -0,0 +1,151 @@ +// +// GrowingTargetConditionals.h +// GrowingAnalytics +// +// Created by YoloMao on 2024/2/1. +// Copyright (C) 2024 Beijing Yishu Technology Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +/* + * ATTENTION: The IOS/MACCATALYST conditionals are NOT mutually exclusive in earlier versions. + * + * before iOS SDK 14.2: + * +----------------------------------------------------------------+ + * | TARGET_OS_MAC | + * | +---+ +-----------------------------------------------------+ | + * | | | | TARGET_OS_IPHONE | | + * | |OSX| | +-----+ +----+ +-------+ +--------+ +-------------+ | | + * | | | | | IOS | | TV | | WATCH | | BRIDGE | | MACCATALYST | | | + * | | | | +-----+ +----+ +-------+ +--------+ +-------------+ | | + * | +---+ +-----------------------------------------------------+ | + * +----------------------------------------------------------------+ + + * after iOS SDK 14.2: + * +---------------------------------------------------------------------------+ + * | TARGET_OS_MAC | + * | +-----+ +-------------------------------------------------+ +-----------+ | + * | | | | TARGET_OS_IPHONE | | | | + * | | | | +-----------------+ +----+ +-------+ +--------+ | | | | + * | | | | | IOS | | | | | | | | | | | + * | | OSX | | | +-------------+ | | TV | | WATCH | | BRIDGE | | | DRIVERKIT | | + * | | | | | | MACCATALYST | | | | | | | | | | | | + * | | | | | +-------------+ | | | | | | | | | | | + * | | | | +-----------------+ +----+ +-------+ +--------+ | | | | + * | +-----+ +-------------------------------------------------+ +-----------+ | + * +---------------------------------------------------------------------------+ + + * after iOS SDK 17.2: + * +--------------------------------------------------------------------------------------+ + * | TARGET_OS_MAC | + * | +-----+ +------------------------------------------------------------+ +-----------+ | + * | | | | TARGET_OS_IPHONE | | | | + * | | | | +-----------------+ +----+ +-------+ +--------+ +--------+ | | | | + * | | | | | IOS | | | | | | | | | | | | | + * | | OSX | | | +-------------+ | | TV | | WATCH | | BRIDGE | | VISION | | | DRIVERKIT | | + * | | | | | | MACCATALYST | | | | | | | | | | | | | | + * | | | | | +-------------+ | | | | | | | | | | | | | + * | | | | +-----------------+ +----+ +-------+ +--------+ +--------+ | | | | + * | +-----+ +------------------------------------------------------------+ +-----------+ | + * +--------------------------------------------------------------------------------------+ + */ + +#ifndef Growing_OS_IOS +#if defined(TARGET_OS_IOS) && TARGET_OS_IOS + #define Growing_OS_IOS 1 +#else + #define Growing_OS_IOS 0 +#endif +#endif + +#ifndef Growing_OS_OSX +#if defined(TARGET_OS_OSX) && TARGET_OS_OSX + #define Growing_OS_OSX 1 +#else + #define Growing_OS_OSX 0 +#endif +#endif + +#ifndef Growing_OS_MACCATALYST +#if defined(TARGET_OS_MACCATALYST) && TARGET_OS_MACCATALYST + #define Growing_OS_MACCATALYST 1 +#else + #define Growing_OS_MACCATALYST 0 +#endif +#endif + +#ifndef Growing_OS_TV +#if defined(TARGET_OS_TV) && TARGET_OS_TV + #define Growing_OS_TV 1 +#else + #define Growing_OS_TV 0 +#endif +#endif + +#ifndef Growing_OS_WATCH +#if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH + #define Growing_OS_WATCH 1 +#else + #define Growing_OS_WATCH 0 +#endif +#endif + +#ifndef Growing_OS_VISION +#if defined(TARGET_OS_VISION) && TARGET_OS_VISION + #define Growing_OS_VISION 1 +#else + #define Growing_OS_VISION 0 +#endif +#endif + +#ifndef Growing_OS_PURE_IOS +#if Growing_OS_IOS && !Growing_OS_MACCATALYST + #define Growing_OS_PURE_IOS 1 +#else + #define Growing_OS_PURE_IOS 0 +#endif +#endif + +#ifndef Growing_USE_APPKIT +#if Growing_OS_OSX + #define Growing_USE_APPKIT 1 +#else + #define Growing_USE_APPKIT 0 +#endif +#endif + +#ifndef Growing_USE_UIKIT +#if Growing_OS_IOS || Growing_OS_MACCATALYST || Growing_OS_TV || Growing_OS_VISION + #define Growing_USE_UIKIT 1 +#else + #define Growing_USE_UIKIT 0 +#endif +#endif + +#ifndef Growing_USE_WATCHKIT +#if Growing_OS_WATCH + #define Growing_USE_WATCHKIT 1 +#else + #define Growing_USE_WATCHKIT 0 +#endif +#endif + +#if Growing_USE_APPKIT + #import +#elif Growing_USE_UIKIT + #import +#elif Growing_USE_WATCHKIT + #import +#endif diff --git a/Sources/TrackerCore/include/GrowingULAppLifecycle.h b/Sources/TrackerCore/include/GrowingULAppLifecycle.h index e0b5dee..bafacaf 100644 --- a/Sources/TrackerCore/include/GrowingULAppLifecycle.h +++ b/Sources/TrackerCore/include/GrowingULAppLifecycle.h @@ -17,15 +17,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import - -#if __has_include() -#import -#endif - -#if __has_include() -#import -#endif +#import "GrowingTargetConditionals.h" @protocol GrowingULAppLifecycleDelegate diff --git a/Sources/TrackerCore/include/GrowingULApplication.h b/Sources/TrackerCore/include/GrowingULApplication.h index 3a61629..feb420b 100644 --- a/Sources/TrackerCore/include/GrowingULApplication.h +++ b/Sources/TrackerCore/include/GrowingULApplication.h @@ -17,9 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import +#import "GrowingTargetConditionals.h" -#if __has_include() +#if Growing_USE_UIKIT #import "UIApplication+GrowingUtilsTrackerCore.h" #import "UIViewController+GrowingUtilsTrackerCore.h" #endif diff --git a/Sources/TrackerCore/include/UIApplication+GrowingUtilsTrackerCore.h b/Sources/TrackerCore/include/UIApplication+GrowingUtilsTrackerCore.h index 9d11ef4..ca7698c 100644 --- a/Sources/TrackerCore/include/UIApplication+GrowingUtilsTrackerCore.h +++ b/Sources/TrackerCore/include/UIApplication+GrowingUtilsTrackerCore.h @@ -17,9 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if __has_include() -#import +#import "GrowingTargetConditionals.h" +#if Growing_USE_UIKIT @interface UIApplication (GrowingUtilsTrackerCore) - (nullable UIWindow *)growingul_keyWindow; diff --git a/Sources/TrackerCore/include/UIViewController+GrowingUtilsTrackerCore.h b/Sources/TrackerCore/include/UIViewController+GrowingUtilsTrackerCore.h index 4009663..3833387 100644 --- a/Sources/TrackerCore/include/UIViewController+GrowingUtilsTrackerCore.h +++ b/Sources/TrackerCore/include/UIViewController+GrowingUtilsTrackerCore.h @@ -17,9 +17,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if __has_include() -#import +#import "GrowingTargetConditionals.h" +#if Growing_USE_UIKIT @interface UIViewController (GrowingUtilsTrackerCore) - (nullable UIViewController *)growingul_topViewController;