diff --git a/.gitmodules b/.gitmodules index 66f83468..0263ba87 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "libunwind-ndk"] path = libunwind-ndk url = https://github.com/ivanarh/libunwind-ndk.git +[submodule "bugsnag-cocoa"] + path = bugsnag-cocoa + url = https://github.com/clostra/bugsnag-cocoa diff --git a/bugsnag-cocoa b/bugsnag-cocoa new file mode 160000 index 00000000..c8d61553 --- /dev/null +++ b/bugsnag-cocoa @@ -0,0 +1 @@ +Subproject commit c8d615536e5e1da777f9b49b63bb84907096dd88 diff --git a/build.ios.sh b/build.ios.sh index cb1a01c0..3f1620c1 100755 --- a/build.ios.sh +++ b/build.ios.sh @@ -29,6 +29,16 @@ function build_ios { LIBUTP=libutp/$TRIPLE/libutp.a + cd bugsnag-cocoa + if [ ! -f iOS/$TRIPLE/libBugsnagStatic.a ]; then + xcodebuild -workspace iOS.xcworkspace -scheme BugsnagStatic -configuration Release \ + -arch $ARCH -sdk $SDK CONFIGURATION_BUILD_DIR=$TRIPLE TARGET_BUILD_DIR=$TRIPLE $ACTION + fi + cd .. + LIBBUGSNAG_CFLAGS=-Ibugsnag-cocoa/iOS/$TRIPLE/include + LIBBUGSNAG=bugsnag-cocoa/iOS/$TRIPLE/libBugsnagStatic.a + + FLAGS="$CFLAGS -g -Werror -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Werror=shadow -Wfatal-errors \ -fPIC -fblocks \ -fno-rtti -fno-exceptions -fno-common -fno-inline -fno-optimize-sibling-calls -funwind-tables -fno-omit-frame-pointer -fstack-protector-all \ @@ -44,7 +54,7 @@ function build_ios { rm libsodium.a || true clang $CFLAGS -c dht/dht.c -o dht_dht.o for file in bev_splice.c base64.c client.c dht.c http.c log.c lsd.c icmp_handler.c ios/Framework/NewNode.m hash_table.c network.c obfoo.c sha1.c timer.c utp_bufferevent.c; do - clang $CFLAGS $LIBUTP_CFLAGS $LIBEVENT_CFLAGS $LIBSODIUM_CFLAGS $LIBBLOCKSRUNTIME_CFLAGS -c $file + clang $CFLAGS $LIBUTP_CFLAGS $LIBEVENT_CFLAGS $LIBSODIUM_CFLAGS $LIBBLOCKSRUNTIME_CFLAGS $LIBBUGSNAG_CFLAGS -c $file done rm -rf objects || true @@ -61,6 +71,10 @@ function build_ios { cd objects/libevent ar x ../../Libevent/$TRIPLE/lib/libevent_pthreads.a cd ../.. + mkdir -p objects/libbugsnag + cd objects/libbugsnag + ar x ../../$LIBBUGSNAG + cd ../.. lipo $LIBSODIUM -thin $ARCH -o libsodium.a @@ -72,7 +86,7 @@ function build_ios { rm -rf $TRIPLE || true mkdir -p $TRIPLE - clang $CFLAGS -dynamiclib \ + clang++ $CFLAGS -dynamiclib \ -install_name @rpath/NewNode.framework/NewNode \ -Xlinker -rpath -Xlinker @executable_path/Frameworks \ -Xlinker -rpath -Xlinker @loader_path/Frameworks \ @@ -83,7 +97,7 @@ function build_ios { -Xlinker -no_deduplicate \ -Xlinker -objc_abi_version -Xlinker 2 \ -framework Foundation \ - *.o objects/libutp/*.o objects/libevent/*.o objects/libsodium/*.o \ + *.o objects/libutp/*.o objects/libevent/*.o objects/libbugsnag/*.o objects/libsodium/*.o \ -o $TRIPLE/libnewnode.dylib dsymutil $TRIPLE/libnewnode.dylib -o $TRIPLE/libnewnode.dylib.dSYM @@ -105,6 +119,7 @@ XCODEDIR=$(xcode-select -p) BASEDIR="${XCODEDIR}/Platforms/iPhoneSimulator.platform/Developer" SDK="${BASEDIR}/SDKs/iPhoneSimulator.sdk" IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"8.0.0"} +ACTION=build ARCH=x86_64 CFLAGS="-arch $ARCH -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN}" @@ -116,6 +131,7 @@ build_ios BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer" SDK="${BASEDIR}/SDKs/iPhoneOS.sdk" IOS_VERSION_MIN=${IOS_VERSION_MIN-"8.0.0"} +ACTION=archive ARCH=arm64 CFLAGS="-O3 -arch $ARCH -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN} -fembed-bitcode -flto" diff --git a/ios/Framework/NewNode.m b/ios/Framework/NewNode.m index 5a8cc77a..c8f0bb4d 100644 --- a/ios/Framework/NewNode.m +++ b/ios/Framework/NewNode.m @@ -1,10 +1,24 @@ #include "newnode.h" +#include "constants.h" +#define BSG_KSLogger_Level TRACE +#define BSG_LOG_LEVEL BSG_LOGLEVEL_DEBUG #include "NewNode-iOS.h" +#import @implementation NewNode + (void)initialize { + BugsnagConfiguration *config = BugsnagConfiguration.new; + config.apiKey = @"f5ce7103ec0ed93bee065269e8c2b676"; + config.shouldAutoCaptureSessions = YES; + config.appVersion = @(VERSION); + /* + NSURLSessionConfiguration *urlConfig = NSURLSessionConfiguration.defaultSessionConfiguration; + urlConfig.connectionProxyDictionary = NewNode.connectionProxyDictionary; + config.session = [NSURLSession sessionWithConfiguration:urlConfig]; + */ + [Bugsnag startBugsnagWithConfiguration:config]; newnode_init(); }