Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: WatchOS build for Xcode 15 #3204

Merged
merged 8 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

### Fixed

- WatchOS build for Xcode 15 (#3204)

## 8.9.4

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>
Comment on lines -21 to -22
Copy link
Contributor Author

@brustolin brustolin Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This don't make sense.
Apple own header have errors inside, maybe this will be solved until Xcode 15 release, but we don't even use this, so there is no harm in removing it and save a few bits.

#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