diff --git a/apple/overtls.xcodeproj/project.pbxproj b/apple/overtls.xcodeproj/project.pbxproj deleted file mode 100644 index 3f8a556..0000000 --- a/apple/overtls.xcodeproj/project.pbxproj +++ /dev/null @@ -1,398 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 55; - objects = { - -/* Begin PBXBuildFile section */ - B648A35929F43D110045B334 /* OverTlsWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = B648A35829F43D110045B334 /* OverTlsWrapper.m */; }; - B648A35B29F43DDB0045B334 /* OverTlsWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = B648A35A29F43DDB0045B334 /* OverTlsWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; - B692ACC929F7EA4C006BF04D /* libovertls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B692ACC829F7EA4C006BF04D /* libovertls.a */; }; - B6DE654429F4255A00468184 /* overtls.h in Headers */ = {isa = PBXBuildFile; fileRef = B6DE654329F4255A00468184 /* overtls.h */; settings = {ATTRIBUTES = (Public, ); }; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - B648A35829F43D110045B334 /* OverTlsWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OverTlsWrapper.m; sourceTree = ""; }; - B648A35A29F43DDB0045B334 /* OverTlsWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OverTlsWrapper.h; sourceTree = ""; }; - B692ACC829F7EA4C006BF04D /* libovertls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libovertls.a; path = ../target/libovertls.a; sourceTree = ""; }; - B6DE654029F4255A00468184 /* overtls.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = overtls.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - B6DE654329F4255A00468184 /* overtls.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = overtls.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - B6DE653D29F4255A00468184 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - B692ACC929F7EA4C006BF04D /* libovertls.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - B692ACC729F7EA4C006BF04D /* Frameworks */ = { - isa = PBXGroup; - children = ( - B692ACC829F7EA4C006BF04D /* libovertls.a */, - ); - name = Frameworks; - sourceTree = ""; - }; - B6DE653629F4255A00468184 = { - isa = PBXGroup; - children = ( - B6DE654229F4255A00468184 /* overtls */, - B6DE654129F4255A00468184 /* Products */, - B692ACC729F7EA4C006BF04D /* Frameworks */, - ); - sourceTree = ""; - }; - B6DE654129F4255A00468184 /* Products */ = { - isa = PBXGroup; - children = ( - B6DE654029F4255A00468184 /* overtls.framework */, - ); - name = Products; - sourceTree = ""; - }; - B6DE654229F4255A00468184 /* overtls */ = { - isa = PBXGroup; - children = ( - B6DE654329F4255A00468184 /* overtls.h */, - B648A35829F43D110045B334 /* OverTlsWrapper.m */, - B648A35A29F43DDB0045B334 /* OverTlsWrapper.h */, - ); - path = overtls; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - B6DE653B29F4255A00468184 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - B648A35B29F43DDB0045B334 /* OverTlsWrapper.h in Headers */, - B6DE654429F4255A00468184 /* overtls.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - B6DE653F29F4255A00468184 /* overtls */ = { - isa = PBXNativeTarget; - buildConfigurationList = B6DE654729F4255A00468184 /* Build configuration list for PBXNativeTarget "overtls" */; - buildPhases = ( - B692ACB329F7E203006BF04D /* Run Script */, - B6DE653B29F4255A00468184 /* Headers */, - B6DE653C29F4255A00468184 /* Sources */, - B6DE653D29F4255A00468184 /* Frameworks */, - B6DE653E29F4255A00468184 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = overtls; - productName = overtls; - productReference = B6DE654029F4255A00468184 /* overtls.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - B6DE653729F4255A00468184 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastUpgradeCheck = 1430; - TargetAttributes = { - B6DE653F29F4255A00468184 = { - CreatedOnToolsVersion = 13.2.1; - }; - }; - }; - buildConfigurationList = B6DE653A29F4255A00468184 /* Build configuration list for PBXProject "overtls" */; - compatibilityVersion = "Xcode 13.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = B6DE653629F4255A00468184; - productRefGroup = B6DE654129F4255A00468184 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - B6DE653F29F4255A00468184 /* overtls */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - B6DE653E29F4255A00468184 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - B692ACB329F7E203006BF04D /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/bash; - shellScript = "set -e\nPATH=\"$PATH:${HOME}/.cargo/bin\"\nRUST_PROJ=${PROJECT_DIR}/..\ncd \"${RUST_PROJ}\"\ncargo build --release --target aarch64-apple-ios\ncargo build --release --target x86_64-apple-ios\nlipo -create target/aarch64-apple-ios/release/libovertls.a target/x86_64-apple-ios/release/libovertls.a -output target/libovertls.a\ncbindgen --config cbindgen.toml -l C -o target/overtls-ffi.h\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - B6DE653C29F4255A00468184 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - B648A35929F43D110045B334 /* OverTlsWrapper.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - B6DE654529F4255A00468184 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - B6DE654629F4255A00468184 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - B6DE654829F4255A00468184 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = NO; - ENABLE_MODULE_VERIFIER = YES; - GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = ""; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - LIBRARY_SEARCH_PATHS = ( - ../target, - "$(PROJECT_DIR)/../target", - ); - MARKETING_VERSION = 1.0; - MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; - MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; - PRODUCT_BUNDLE_IDENTIFIER = com.ssrlive.overtls; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ../target; - }; - name = Debug; - }; - B6DE654929F4255A00468184 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = NO; - ENABLE_MODULE_VERIFIER = YES; - GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = ""; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - LIBRARY_SEARCH_PATHS = ( - ../target, - "$(PROJECT_DIR)/../target", - ); - MARKETING_VERSION = 1.0; - MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; - MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; - PRODUCT_BUNDLE_IDENTIFIER = com.ssrlive.overtls; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ../target; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - B6DE653A29F4255A00468184 /* Build configuration list for PBXProject "overtls" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B6DE654529F4255A00468184 /* Debug */, - B6DE654629F4255A00468184 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - B6DE654729F4255A00468184 /* Build configuration list for PBXNativeTarget "overtls" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - B6DE654829F4255A00468184 /* Debug */, - B6DE654929F4255A00468184 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = B6DE653729F4255A00468184 /* Project object */; -} diff --git a/apple/overtls/OverTlsWrapper.h b/apple/overtls/OverTlsWrapper.h deleted file mode 100644 index bb83a42..0000000 --- a/apple/overtls/OverTlsWrapper.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// OverTlsWrapper.h -// overtls -// -// Created by ssrlive on 2023/4/23. -// - -#ifndef OverTlsWrapper_h -#define OverTlsWrapper_h - -@interface OverTlsWrapper : NSObject - -+ (void) startWithConfig:(NSString*)filePath handler:(void (*)(int port, void *ctx))handler context:(void*)ctx; -+ (void) shutdown; -+ (void) setLogCallback:(void (*)(int verbosity, const char*, void*))cb context:(void*)ctx; - -@end - -#endif /* OverTlsWrapper_h */ diff --git a/apple/overtls/OverTlsWrapper.m b/apple/overtls/OverTlsWrapper.m deleted file mode 100644 index 754fdcf..0000000 --- a/apple/overtls/OverTlsWrapper.m +++ /dev/null @@ -1,30 +0,0 @@ -// -// OverTlsWrapper.m -// overtls -// -// Created by ssrlive on 2023/4/23. -// - -#import - -#import "OverTlsWrapper.h" -#include "overtls-ffi.h" - -@implementation OverTlsWrapper - -+ (void)startWithConfig:(NSString *)filePath - handler:(void (*)(int port, void *ctx))handler - context:(void *)ctx { - over_tls_client_run(filePath.UTF8String, Trace, handler, ctx); -} - -+ (void)shutdown { - over_tls_client_stop(); -} - -+ (void) setLogCallback:(void (*)(int verbosity, const char*, void*))cb context:(void*)ctx { - typedef void (*p_cb)(enum ArgVerbosity, const char*, void*); - overtls_set_log_callback((p_cb)cb, ctx); -} - -@end diff --git a/apple/overtls/overtls.h b/apple/overtls/overtls.h deleted file mode 100644 index ff58f90..0000000 --- a/apple/overtls/overtls.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// overtls.h -// overtls -// -// Created by overtls on 2023/4/22. -// - -#import - -//! Project version number for overtls. -FOUNDATION_EXPORT double overtlsVersionNumber; - -//! Project version string for overtls. -FOUNDATION_EXPORT const unsigned char overtlsVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - -#import diff --git a/apple/readme.md b/apple/readme.md index 12391b9..edb1327 100644 --- a/apple/readme.md +++ b/apple/readme.md @@ -6,14 +6,16 @@ - Install iOS target support: `rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios` - Install `cbindgen` tool: `cargo install cbindgen` -### Building iOS framework -Due to an unknown reason at present, compiling Rust code from Xcode fails, so you have to manually compile it. +### Building iOS xcframework Please run the following command in zsh (or bash): ```bash +# go to the root of the overtls project cd overtls -cargo build --release --target aarch64-apple-ios -cargo build --release --target x86_64-apple-ios -lipo -create target/aarch64-apple-ios/release/libovertls.a target/x86_64-apple-ios/release/libovertls.a -output target/libovertls.a -cbindgen --config cbindgen.toml -l C -o target/overtls-ffi.h +# Build the iOS xcframework +./build-apple.sh + +# Or build debug version +./build-apple-debug.sh + ``` diff --git a/build-apple-debug.sh b/build-apple-debug.sh new file mode 100755 index 0000000..6914327 --- /dev/null +++ b/build-apple-debug.sh @@ -0,0 +1,28 @@ +#! /bin/sh + +echo "Setting up the rust environment..." +rustup target add aarch64-apple-ios +cargo install cbindgen + +cargo update + +echo "Building..." +cargo build --target aarch64-apple-ios + +echo "Generating includes..." +mkdir -p target/include/ +cbindgen --config cbindgen.toml -l C -o target/include/overtls.h +cat > target/include/module.modulemap <