Skip to content

Commit

Permalink
feat: Added support for arm64e (#3398)
Browse files Browse the repository at this point in the history
A developer may choose the arm64e architecture for their iOS app to benefit from enhanced security features.
Sentry was not compiling for this architecture due to issues with accessing machine context properties
  • Loading branch information
brustolin authored Oct 4, 2024
1 parent c7aec2a commit a930c80
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Added breadcrumb.origin private field (#4358)
- Custom redact modifier for SwiftUI (#4362)
- Add support for arm64e (#3398)
- Add mergeable libraries support to dynamic libraries (#4381)

### Improvements
Expand Down
42 changes: 38 additions & 4 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
D8AE48CF2C57E0BD0092A2A6 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE48C82C57DC2F0092A2A6 /* WebViewController.swift */; };
D8B56CF0273A8D97004DF238 /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; };
D8B56CF1273A8D97004DF238 /* Sentry.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 630853322440C44F00DDE4CE /* Sentry.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D8BC843E2B021C5200A662B7 /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4F33F7271EBD2500C8591E /* SwiftUIView.swift */; };
D8C33E1F29FBB1F70071B75A /* UIEventBreadcrumbsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8C33E1E29FBB1F70071B75A /* UIEventBreadcrumbsController.swift */; };
D8C33E2629FBB8D90071B75A /* UIEventBreadcrumbTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8C33E2529FBB8D90071B75A /* UIEventBreadcrumbTests.swift */; };
D8D7BB4A2750067900044146 /* UIAssert.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8D7BB492750067900044146 /* UIAssert.swift */; };
Expand Down Expand Up @@ -1146,6 +1147,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D8BC843E2B021C5200A662B7 /* SwiftUIView.swift in Sources */,
D8832B1A2AF5000F00C522B0 /* TopViewControllerInspector.swift in Sources */,
D8AE48CF2C57E0BD0092A2A6 /* WebViewController.swift in Sources */,
84BA71F22C8F73FD0045B828 /* DSNDisplayViewController.swift in Sources */,
Expand Down Expand Up @@ -1417,7 +1419,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.37.0-beta.1;
MARKETING_VERSION = "8.37.0-beta.1";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift";
Expand Down Expand Up @@ -1446,7 +1448,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.37.0-beta.1;
MARKETING_VERSION = "8.37.0-beta.1";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift";
Expand Down Expand Up @@ -1730,11 +1732,16 @@
84D4FE8528ECD1EA00EDAAFE /* Test */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
arm64e,
);
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "iOS13-Swift/iOS13-Swift.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "iOS13-Swift/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -1762,8 +1769,10 @@
84D4FE8628ECD1EA00EDAAFE /* Test */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -1774,6 +1783,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.Sentry.iOS13-SwiftTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1955,11 +1965,16 @@
84D4FE8D28ECD1ED00EDAAFE /* TestCI */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
arm64e,
);
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "iOS13-Swift/iOS13-Swift.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "iOS13-Swift/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -1987,8 +2002,10 @@
84D4FE8E28ECD1ED00EDAAFE /* TestCI */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -1999,6 +2016,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.Sentry.iOS13-SwiftTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -2009,11 +2027,16 @@
D8269A4A274C096000BD5BD5 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
arm64e,
);
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "iOS13-Swift/iOS13-Swift.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "iOS13-Swift/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -2041,11 +2064,16 @@
D8269A4B274C096000BD5BD5 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
arm64e,
);
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "iOS13-Swift/iOS13-Swift.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "iOS13-Swift/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -2095,7 +2123,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.37.0-beta.1;
MARKETING_VERSION = "8.37.0-beta.1";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match Development io.sentry.sample.iOS-Swift.Clip";
Expand Down Expand Up @@ -2130,7 +2158,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.37.0-beta.1;
MARKETING_VERSION = "8.37.0-beta.1";
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.sample.iOS-Swift.Clip";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "match AppStore io.sentry.sample.iOS-Swift.Clip";
Expand All @@ -2143,8 +2171,10 @@
D85DAA52274C244F004DF43C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -2155,6 +2185,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.Sentry.iOS13-SwiftTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -2165,8 +2196,10 @@
D85DAA53274C244F004DF43C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -2177,6 +2210,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.sentry.Sentry.iOS13-SwiftTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
13 changes: 10 additions & 3 deletions Samples/iOS-Swift/iOS13-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SentrySDK.start { options in
options.dsn = dsn
options.debug = true
options.tracesSampleRate = 1.0
if ProcessInfo.processInfo.arguments.contains("--io.sentry.profiling.enable") {
options.profilesSampleRate = 1
if #available(iOS 15.0, *) {
options.enableMetricKit = true
}
// Sampling 100% - In Production you probably want to adjust this
options.tracesSampleRate = 1.0
options.sessionTrackingIntervalMillis = 5_000
options.profilesSampleRate = 1.0
options.attachScreenshot = true
options.attachViewHierarchy = true
options.environment = "test-app"
options.enableTimeToFullDisplayTracing = true
options.initialScope = { scope in
scope.injectGitInformation()
return scope
Expand Down
5 changes: 5 additions & 0 deletions Samples/iOS-Swift/iOS13-SwiftTests/LaunchUITest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class LaunchUITests: XCTestCase {
XCTAssertTrue(app.staticTexts["SwiftUI!"].waitForExistence(timeout: timeout), "SwiftUI not loaded.")
}

func testNavigationTransaction() {
app.buttons["Test Navigation Transaction"].tap()
XCTAssertEqual(app.state, .runningForeground)
}

private func waitForExistenceOfMainScreen() {
XCTAssertTrue(app.buttons["captureMessage"].waitForExistence(timeout: timeout), "Home Screen doesn't exist.")
}
Expand Down
7 changes: 0 additions & 7 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5402,7 +5402,6 @@
GCC_WARN_SHADOW = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)";
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DCARTHAGE_$(CARTHAGE)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -5440,7 +5439,6 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-DCARTHAGE_$(CARTHAGE)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -5600,7 +5598,6 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DCARTHAGE_$(CARTHAGE)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -5727,7 +5724,6 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DCARTHAGE_$(CARTHAGE)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -5776,7 +5772,6 @@
baseConfigurationReference = D8199DCF29376FF40074249E /* SentrySwiftUI.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -6207,7 +6202,6 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-DCARTHAGE_$(CARTHAGE)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -6437,7 +6431,6 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DCARTHAGE_$(CARTHAGE)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down
2 changes: 2 additions & 0 deletions Sources/Configuration/Sentry.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ PRODUCT_MODULE_NAME = $(PRODUCT_MODULE_NAME_$(CONFIGURATION))
PRODUCT_NAME = $(PRODUCT_MODULE_NAME)
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.$(PRODUCT_MODULE_NAME)
MODULEMAP_FILE = $(SRCROOT)/Sources/Resources/$(PRODUCT_MODULE_NAME_$(CONFIGURATION)).modulemap
ARCHS = $(ARCHS_STANDARD) arm64e
ARCHS[sdk=*simulator] = $(ARCHS_STANDARD)
2 changes: 2 additions & 0 deletions Sources/Configuration/SentrySwiftUI.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ OTHER_LDFLAGS_Test = -framework Sentry
OTHER_LDFLAGS_TestCI = -framework Sentry
OTHER_LDFLAGS_Release = -framework Sentry
OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(CONFIGURATION))
ARCHS = $(ARCHS_STANDARD) arm64e
ARCHS[sdk=*simulator] = $(ARCHS_STANDARD)
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryBacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ namespace profiling {
}

void
enumerateBacktracesForAllThreads(const std::function<void(const Backtrace &)> &f,
const std::shared_ptr<ThreadMetadataCache> &cache)
enumerateBacktracesForAllThreads(
const std::function<void(const Backtrace &)> &f, ThreadMetadataCache *cache)
{
const auto pair = ThreadHandle::allExcludingCurrent();
for (const auto &thread : pair.first) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}

@implementation SentryProfiler {
std::shared_ptr<SamplingProfiler> _samplingProfiler;
std::unique_ptr<SamplingProfiler> _samplingProfiler;
}

+ (void)load
Expand Down Expand Up @@ -165,7 +165,7 @@ - (void)start

SentryProfilerState *const state = [[SentryProfilerState alloc] init];
self.state = state;
_samplingProfiler = std::make_shared<SamplingProfiler>(
_samplingProfiler = std::make_unique<SamplingProfiler>(
[state](auto &backtrace) {
Backtrace backtraceCopy = backtrace;
backtraceCopy.absoluteTimestamp
Expand Down
8 changes: 4 additions & 4 deletions Sources/Sentry/SentrySamplingProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace profiling {
mach_port_t port;
clock_serv_t clock;
mach_timespec_t delaySpec;
std::shared_ptr<ThreadMetadataCache> cache;
ThreadMetadataCache *cache;
std::function<void(const Backtrace &)> callback;
std::atomic_uint64_t &numSamples;
std::function<void()> onThreadStart;
Expand Down Expand Up @@ -77,7 +77,7 @@ namespace profiling {
SamplingProfiler::SamplingProfiler(
std::function<void(const Backtrace &)> callback, std::uint32_t samplingRateHz)
: callback_(std::move(callback))
, cache_(std::make_shared<ThreadMetadataCache>())
, cache_(std::make_unique<ThreadMetadataCache>())
, isInitialized_(false)
, isSampling_(false)
, port_(0)
Expand Down Expand Up @@ -139,8 +139,8 @@ namespace profiling {
SENTRY_ASYNC_SAFE_LOG_ERRNO_RETURN(pthread_attr_setschedparam(&attr, &param));
}

const auto params = new SamplingThreadParams { port_, clock_, delaySpec_, cache_, callback_,
std::ref(numSamples_), std::move(onThreadStart) };
const auto params = new SamplingThreadParams { port_, clock_, delaySpec_, cache_.get(),
callback_, std::ref(numSamples_), std::move(onThreadStart) };
if (SENTRY_ASYNC_SAFE_LOG_ERRNO_RETURN(
pthread_create(&thread_, &attr, samplingThreadMain, params))
!= 0) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentryBacktrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ namespace profiling {
* @param f The function to call for each entry.
* @param cache The cache used to look up thread metadata.
*/
void enumerateBacktracesForAllThreads(const std::function<void(const Backtrace &)> &f,
const std::shared_ptr<ThreadMetadataCache> &cache);
void enumerateBacktracesForAllThreads(
const std::function<void(const Backtrace &)> &f, ThreadMetadataCache *cache);

} // namespace profiling
} // namespace sentry
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/SentrySamplingProfiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace profiling {
* Samples the stacks on all threads at a specified interval, using the mach clock
* alarm API for scheduling.
*/
class SamplingProfiler : public std::enable_shared_from_this<SamplingProfiler> {
class SamplingProfiler {
public:
/**
* Creates a new sampling profiler that samples at the specified rate.
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace profiling {
private:
mach_timespec_t delaySpec_;
std::function<void(const Backtrace &)> callback_;
std::shared_ptr<ThreadMetadataCache> cache_;
std::unique_ptr<ThreadMetadataCache> cache_;
bool isInitialized_;
std::mutex isSamplingLock_;
bool isSampling_;
Expand Down
Loading

0 comments on commit a930c80

Please sign in to comment.