Commit 66d6ddff authored by Simon Morlat's avatar Simon Morlat
Browse files

Fix crash with tunnel on iOS 16

1 merge request!201Fix crash with tunnel on iOS 16
Showing with 23 additions and 2 deletions
......@@ -19,7 +19,6 @@
#pragma once
#include <memory>
#include <functional>
namespace bctoolbox {
......@@ -39,6 +38,7 @@ public:
void endBackgroundTask(unsigned long id);
bool isApplicationStateActive();
bool isApp();
int getOSMajorVersion() const;
static IOSUtils& getUtils();
IOSUtils(const IOSUtils&) = delete;
......
......@@ -139,7 +139,11 @@ if(ENABLE_SHARED)
)
endif()
if(APPLE)
target_link_libraries(bctoolbox PRIVATE "-framework Foundation" "-framework AVFoundation")
if (IOS)
target_link_libraries(bctoolbox PRIVATE "-framework UIKit" "-framework Foundation" "-framework AVFoundation")
else()
target_link_libraries(bctoolbox PRIVATE "-framework Foundation" "-framework AVFoundation")
endif()
target_include_directories(bctoolbox SYSTEM PRIVATE ${ICONV_INCLUDE_DIRS})
target_link_libraries(bctoolbox PRIVATE ${ICONV_LIBRARIES})
endif()
......
......@@ -19,6 +19,8 @@
#ifdef __APPLE__
#include <TargetConditionals.h>
#import <Foundation/Foundation.h>
#include <dlfcn.h>
......@@ -27,6 +29,11 @@
#include "bctoolbox/logging.h"
#include "ios_utils_stub.hh"
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#endif
namespace bctoolbox {
std::unique_ptr<IOSUtils> IOSUtils::sInstance = nullptr;
......@@ -104,6 +111,16 @@ bool IOSUtils::isApplicationStateActive() {
return mUtils->isApplicationStateActive();
}
int IOSUtils::getOSMajorVersion() const{
#if TARGET_OS_IPHONE
NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
return [[versionCompatibility objectAtIndex:0] intValue];
#else
bctbx_error("IOSUtils::getOSMajorVersion() not running on iOS");
return 0;
#endif
}
unsigned long IOSUtilsStub::beginBackgroundTask(const char *name, std::function<void()> cb) {
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment