Skip to content

Commit

Permalink
fix: WatchOS build for Xcode 15 (#3204)
Browse files Browse the repository at this point in the history
Fixed WatchOS build for Xcode 15
Co-authored-by: Andrew McKnight <andrew.mcknight@sentry.io>
  • Loading branch information
brustolin authored Aug 16, 2023
1 parent 7f14650 commit 3ea21f5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## Unreleased

### Fixes
### Fixed

- WatchOS build for Xcode 15 (#3204)
- Fix CPU usage collection for upcoming visualization in profiling flamecharts (#3214)

## 8.9.5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Sentry
import SwiftUI

@available(watchOSApplicationExtension 7.0, *)
struct ContentView: View {

@StateObject var viewModel = ContentViewModel()
Expand Down Expand Up @@ -89,6 +90,7 @@ class ContentViewModel: ObservableObject {
}
}

@available(watchOSApplicationExtension 7.0, *)
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import SwiftUI
import WatchKit

@available(watchOSApplicationExtension 7.0, *)
class HostingController: WKHostingController<ContentView> {
override var body: ContentView {
return ContentView()
Expand Down
26 changes: 14 additions & 12 deletions Samples/watchOS-Swift/watchOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 97JCY7859U;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -437,6 +438,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 97JCY7859U;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand All @@ -460,9 +462,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"watchOS-Swift WatchKit Extension/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "watchOS-Swift WatchKit Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -472,6 +472,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.watchOS-Swift.watchkitapp.watchkitextension";
PRODUCT_NAME = "${TARGET_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=watchos*]" = "match Development io.sentry.*";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -484,9 +486,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"watchOS-Swift WatchKit Extension/Preview Content\"";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = "watchOS-Swift WatchKit Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -496,6 +496,8 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.watchOS-Swift.watchkitapp.watchkitextension";
PRODUCT_NAME = "${TARGET_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=watchos*]" = "match Development io.sentry.*";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -509,12 +511,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 97JCY7859U;
IBSC_MODULE = watchOS_Swift_WatchKit_Extension;
INFOPLIST_FILE = "watchOS-Swift WatchKit App/Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.watchOS-Swift.watchkitapp";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=watchos*]" = "match Development io.sentry.*";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -528,12 +530,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 97JCY7859U;
IBSC_MODULE = watchOS_Swift_WatchKit_Extension;
INFOPLIST_FILE = "watchOS-Swift WatchKit App/Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.watchOS-Swift.watchkitapp";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=watchos*]" = "match Development io.sentry.*";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -545,25 +547,25 @@
7B82C4B324C98A96002CA6D1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.watchOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development io.sentry.*";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
7B82C4B424C98A96002CA6D1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.watchOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development io.sentry.*";
SWIFT_VERSION = 5.0;
};
name = Release;
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#import <sys/sysctl.h>
#if SENTRY_HAS_UIKIT
# import <UIKit/UIKit.h>
#elif TARGET_OS_WATCH
# import <WatchKit/WatchKit.h>
#endif

namespace {
Expand Down Expand Up @@ -180,7 +178,8 @@
sentry_getOSVersion(void)
{
#if TARGET_OS_WATCH
return WKInterfaceDevice.currentDevice.systemVersion;
// This function is only used for profiling, and profiling don't run for watchOS
return @"";
#elif SENTRY_HAS_UIKIT
return UIDevice.currentDevice.systemVersion;
#else
Expand Down
4 changes: 2 additions & 2 deletions Tests/SentryTests/Helper/SentryDeviceTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ - (void)testOSVersion
SENTRY_ASSERT_PREFIX(
osVersion, @"9.", @"10.", @"11.", @"12.", @"13.", @"14.", @"15.", @"16.", @"17.");
#elif TARGET_OS_WATCH
// TODO: create a watch UI test target to test this branch
SENTRY_ASSERT_PREFIX(osVersion, @"2.", @"3.", @"4.", @"5.", @"6.", @"7.", @"8.", @"9.");
#else
XCTFail(@"Unexpected OS.");
Expand Down Expand Up @@ -122,8 +123,7 @@ - (void)testOSName
// cannot.
SENTRY_ASSERT_EQUAL(osName, @"tvOS");
#elif TARGET_OS_WATCH
// TODO: create a watch UI test target to test this branch as it cannot run on the watch
// simulator
// TODO: create a watch UI test target to test this branch
SENTRY_ASSERT_EQUAL(osName, @"watchOS");
#else
XCTFail(@"Unexpected device OS");
Expand Down

0 comments on commit 3ea21f5

Please sign in to comment.