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: catch code unsupported ios 14 and above #468

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties
ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = '1' if podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR'] == 'true'

platform :ios, '16.0'
platform :ios, '14.0'
install! 'cocoapods',
:deterministic_uuids => false

Expand Down Expand Up @@ -85,11 +85,11 @@ target 'xmtpreactnativesdkexample' do
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
project.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,6 @@ SPEC CHECKSUMS:
XMTPReactNative: 1ca02155e4583791c8c99a244206ecf8e057abd2
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2
PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd

COCOAPODS: 1.15.2
21 changes: 15 additions & 6 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1483,14 +1483,23 @@ public class XMTPModule: Module {

AsyncFunction("exportNativeLogs") { () -> String in
var logOutput = ""
let logStore = try OSLogStore(scope: .currentProcessIdentifier)
let position = logStore.position(timeIntervalSinceLatestBoot: -300) // Last 5 min of logs
let entries = try logStore.getEntries(at: position)
if #available(iOS 15.0, *) {
do {
let logStore = try OSLogStore(scope: .currentProcessIdentifier)
let position = logStore.position(timeIntervalSinceLatestBoot: -300) // Last 5 min of logs
let entries = try logStore.getEntries(at: position)

for entry in entries {
if let logEntry = entry as? OSLogEntryLog {
logOutput.append("\(logEntry.date): \(logEntry.composedMessage)\n")
for entry in entries {
if let logEntry = entry as? OSLogEntryLog {
logOutput.append("\(logEntry.date): \(logEntry.composedMessage)\n")
}
}
} catch {
logOutput = "Failed to fetch logs: \(error.localizedDescription)"
}
} else {
// Fallback for iOS 14
logOutput = "OSLogStore is only available on iOS 15 and above. Logging is not supported on this iOS version."
}

return logOutput
Expand Down
Loading