From 15c839536f42927faf8dd038dec3b1eed2d0b545 Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Sun, 6 Oct 2024 09:49:31 -0300 Subject: [PATCH] fuse-ios migration --- .github/workflows/ios17.yml | 32 + .github/workflows/ios18.yml | 32 + .gitignore | 5 +- echo/.npmignore | 8 + echo/ios/echo.xcodeproj/project.pbxproj | 323 +++++++ echo/ios/echo/EchoPlugin.h | 30 + echo/ios/echo/EchoPlugin.m | 124 +++ echo/package-lock.json | 3 +- echo/package.json | 8 +- ios/.gitignore | 6 + ios/.gitmodules | 3 + ios/BTFuse.podspec.template | 21 + .../contents.xcworkspacedata | 26 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + ios/BTFuse/BTFuse.docc/BTFuse.md | 13 + ios/BTFuse/BTFuse.xcodeproj/project.pbxproj | 900 ++++++++++++++++++ .../xcshareddata/xcschemes/BTFuse.xcscheme | 57 ++ .../xcschemes/BTFuseTests.xcscheme | 54 ++ .../xcshareddata/xcschemes/openssl.xcscheme | 66 ++ ios/BTFuse/BTFuse/BTFuse.h | 44 + ios/BTFuse/BTFuse/BTFuseAPIClient.h | 72 ++ .../BTFuse/BTFuseAPIClientInputStream.h | 35 + .../BTFuse/BTFuseAPIClientOutputStream.h | 32 + ios/BTFuse/BTFuse/BTFuseAPIPacket.h | 62 ++ ios/BTFuse/BTFuse/BTFuseAPIResponse.h | 66 ++ ios/BTFuse/BTFuse/BTFuseAPIResponseFactory.h | 34 + ios/BTFuse/BTFuse/BTFuseAPIRouter.h | 36 + ios/BTFuse/BTFuse/BTFuseAPIServer.h | 37 + ios/BTFuse/BTFuse/BTFuseAPIServerHeaders.h | 41 + ios/BTFuse/BTFuse/BTFuseContext.h | 57 ++ ios/BTFuse/BTFuse/BTFuseContextDelegate.h | 34 + ios/BTFuse/BTFuse/BTFuseError.h | 35 + ios/BTFuse/BTFuse/BTFuseIDGenerator.h | 28 + ios/BTFuse/BTFuse/BTFuseJSONSerializer.h | 30 + ios/BTFuse/BTFuse/BTFuseKeyFactory.h | 33 + ios/BTFuse/BTFuse/BTFuseKeyPair.h | 39 + ios/BTFuse/BTFuse/BTFuseLocalization.h | 34 + ios/BTFuse/BTFuse/BTFuseLogger.h | 42 + ios/BTFuse/BTFuse/BTFuseLoggerLevel.h | 31 + ios/BTFuse/BTFuse/BTFuseNWErrorFactory.h | 31 + ios/BTFuse/BTFuse/BTFusePlugin.h | 49 + ios/BTFuse/BTFuse/BTFuseSchemeHandler.h | 34 + ios/BTFuse/BTFuse/BTFuseStreamReader.h | 48 + ios/BTFuse/BTFuse/BTFuseViewController.h | 58 ++ .../BTFuse/BTFuseWebviewNavigationDelegate.h | 33 + ios/BTFuse/BTFuse/BTFuseWebviewUIDelegation.h | 28 + ios/BTFuse/BTFuse/plugins/BTFuseRuntime.h | 38 + .../BTFuseTestTools.docc/BTFuseTestTools.md | 13 + .../BTFuseTestTools.xcodeproj/project.pbxproj | 436 +++++++++ .../xcschemes/BTFuseTestTools.xcscheme | 66 ++ .../BTFuseTestTools/BTFuseTestTools.h | 30 + .../include/BTFuseTestAPIClient.h | 61 ++ .../include/BTFuseTestAPIResponse.h | 27 + .../include/BTFuseTestAPIResponseFactory.h | 28 + .../BTFuseTestTools/include/BTFuseTestUtils.h | 23 + .../include/BTFuseTestViewController.h | 38 + .../BTFuseTestTools/src/BTFuseTestAPIClient.m | 151 +++ .../src/BTFuseTestAPIResponse.m | 23 + .../src/BTFuseTestAPIResponseFactory.m | 27 + .../src/BTFuseTestViewController.m | 47 + .../BTFuseTestTools/PrivacyInfo.xcprivacy | 19 + ios/BTFuse/BTFuseTests/BTFuseAPITests.m | 118 +++ .../BTFuseTests/BTFuseJSONSerializerTests.m | 41 + ios/BTFuse/BTFuseTests/BTFuseTests.m | 69 ++ ios/BTFuse/PrivacyInfo.xcprivacy | 8 + ios/BTFuse/configs/BTFuse.debug.xcconfig | 17 + ios/BTFuse/configs/BTFuse.release.xcconfig | 17 + ios/BTFuse/configs/version.xcconfig | 3 + ios/BTFuse/en.lproj/Localizable.strings | 19 + ios/BTFuse/src/BTFuseAPIClient.m | 241 +++++ ios/BTFuse/src/BTFuseAPIClientInputStream.m | 211 ++++ ios/BTFuse/src/BTFuseAPIClientOutputStream.m | 109 +++ ios/BTFuse/src/BTFuseAPIPacket.m | 123 +++ ios/BTFuse/src/BTFuseAPIResponse.m | 303 ++++++ ios/BTFuse/src/BTFuseAPIResponseFactory.m | 34 + ios/BTFuse/src/BTFuseAPIRouter.m | 73 ++ ios/BTFuse/src/BTFuseAPIServer.m | 199 ++++ ios/BTFuse/src/BTFuseAPIServerHeaders.m | 71 ++ ios/BTFuse/src/BTFuseContext.m | 131 +++ ios/BTFuse/src/BTFuseError.m | 65 ++ ios/BTFuse/src/BTFuseIDGenerator.m | 34 + ios/BTFuse/src/BTFuseJSONSerializer.m | 33 + ios/BTFuse/src/BTFuseKeyFactory.m | 94 ++ ios/BTFuse/src/BTFuseKeyPair.m | 199 ++++ ios/BTFuse/src/BTFuseLocalization.m | 38 + ios/BTFuse/src/BTFuseLogger.m | 132 +++ ios/BTFuse/src/BTFuseLoggerLevel.m | 36 + ios/BTFuse/src/BTFuseNWErrorFactory.m | 58 ++ ios/BTFuse/src/BTFusePlugin.m | 71 ++ ios/BTFuse/src/BTFuseSchemeHandler.m | 130 +++ ios/BTFuse/src/BTFuseStreamReader.m | 76 ++ ios/BTFuse/src/BTFuseViewController.m | 184 ++++ .../src/BTFuseWebviewNavigationDelegate.m | 163 ++++ ios/BTFuse/src/BTFuseWebviewUIDelegation.m | 140 +++ ios/BTFuse/src/plugins/BTFuseRuntime.m | 118 +++ ios/BTFuseTestTools.podspec.template | 21 + ios/LICENSE | 202 ++++ ios/NOTICE | 7 + ios/Overview.docc/Overview.md | 20 + ios/Podfile | 14 + ios/Podfile.lock | 16 + ios/README.md | 23 + ios/VERSION | 1 + ios/build.sh | 152 +++ ios/makeRelease.sh | 58 ++ ios/podPublish.sh | 26 + ios/test.sh | 82 ++ js/.npmignore | 1 + js/.npmrc | 1 - test-app/.gitignore | 4 +- test-app/.npmrc | 3 + test-app/ios/en.lproj/Localizable.strings | 19 + test-app/ios/scripts/build.sh | 54 ++ .../ios/testapp.xcodeproj/project.pbxproj | 465 +++++++++ .../xcshareddata/xcschemes/testapp.xcscheme | 77 ++ test-app/ios/testapp/AppDelegate.h | 23 + test-app/ios/testapp/AppDelegate.m | 49 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + .../ios/testapp/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 + .../ios/testapp/Base.lproj/Main.storyboard | 24 + test-app/ios/testapp/Info.plist | 25 + test-app/ios/testapp/SceneDelegate.h | 24 + test-app/ios/testapp/SceneDelegate.m | 66 ++ test-app/ios/testapp/ViewController.h | 23 + test-app/ios/testapp/ViewController.m | 45 + test-app/ios/testapp/main.m | 27 + 128 files changed, 8804 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ios17.yml create mode 100644 .github/workflows/ios18.yml create mode 100644 echo/.npmignore create mode 100644 echo/ios/echo.xcodeproj/project.pbxproj create mode 100644 echo/ios/echo/EchoPlugin.h create mode 100644 echo/ios/echo/EchoPlugin.m create mode 100644 ios/.gitignore create mode 100644 ios/.gitmodules create mode 100644 ios/BTFuse.podspec.template create mode 100644 ios/BTFuse.xcworkspace/contents.xcworkspacedata create mode 100644 ios/BTFuse.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 ios/BTFuse/BTFuse.docc/BTFuse.md create mode 100644 ios/BTFuse/BTFuse.xcodeproj/project.pbxproj create mode 100644 ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuse.xcscheme create mode 100644 ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuseTests.xcscheme create mode 100644 ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/openssl.xcscheme create mode 100644 ios/BTFuse/BTFuse/BTFuse.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIClient.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIClientInputStream.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIClientOutputStream.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIPacket.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIResponse.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIResponseFactory.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIRouter.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIServer.h create mode 100644 ios/BTFuse/BTFuse/BTFuseAPIServerHeaders.h create mode 100644 ios/BTFuse/BTFuse/BTFuseContext.h create mode 100644 ios/BTFuse/BTFuse/BTFuseContextDelegate.h create mode 100644 ios/BTFuse/BTFuse/BTFuseError.h create mode 100644 ios/BTFuse/BTFuse/BTFuseIDGenerator.h create mode 100644 ios/BTFuse/BTFuse/BTFuseJSONSerializer.h create mode 100644 ios/BTFuse/BTFuse/BTFuseKeyFactory.h create mode 100644 ios/BTFuse/BTFuse/BTFuseKeyPair.h create mode 100644 ios/BTFuse/BTFuse/BTFuseLocalization.h create mode 100644 ios/BTFuse/BTFuse/BTFuseLogger.h create mode 100644 ios/BTFuse/BTFuse/BTFuseLoggerLevel.h create mode 100644 ios/BTFuse/BTFuse/BTFuseNWErrorFactory.h create mode 100644 ios/BTFuse/BTFuse/BTFusePlugin.h create mode 100644 ios/BTFuse/BTFuse/BTFuseSchemeHandler.h create mode 100644 ios/BTFuse/BTFuse/BTFuseStreamReader.h create mode 100644 ios/BTFuse/BTFuse/BTFuseViewController.h create mode 100644 ios/BTFuse/BTFuse/BTFuseWebviewNavigationDelegate.h create mode 100644 ios/BTFuse/BTFuse/BTFuseWebviewUIDelegation.h create mode 100644 ios/BTFuse/BTFuse/plugins/BTFuseRuntime.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools.docc/BTFuseTestTools.md create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/project.pbxproj create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/xcshareddata/xcschemes/BTFuseTestTools.xcscheme create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/BTFuseTestTools.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIClient.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponse.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponseFactory.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestUtils.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestViewController.h create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIClient.m create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponse.m create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponseFactory.m create mode 100644 ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestViewController.m create mode 100644 ios/BTFuse/BTFuseTestTools/PrivacyInfo.xcprivacy create mode 100644 ios/BTFuse/BTFuseTests/BTFuseAPITests.m create mode 100644 ios/BTFuse/BTFuseTests/BTFuseJSONSerializerTests.m create mode 100644 ios/BTFuse/BTFuseTests/BTFuseTests.m create mode 100644 ios/BTFuse/PrivacyInfo.xcprivacy create mode 100644 ios/BTFuse/configs/BTFuse.debug.xcconfig create mode 100644 ios/BTFuse/configs/BTFuse.release.xcconfig create mode 100644 ios/BTFuse/configs/version.xcconfig create mode 100644 ios/BTFuse/en.lproj/Localizable.strings create mode 100644 ios/BTFuse/src/BTFuseAPIClient.m create mode 100644 ios/BTFuse/src/BTFuseAPIClientInputStream.m create mode 100644 ios/BTFuse/src/BTFuseAPIClientOutputStream.m create mode 100644 ios/BTFuse/src/BTFuseAPIPacket.m create mode 100644 ios/BTFuse/src/BTFuseAPIResponse.m create mode 100644 ios/BTFuse/src/BTFuseAPIResponseFactory.m create mode 100644 ios/BTFuse/src/BTFuseAPIRouter.m create mode 100644 ios/BTFuse/src/BTFuseAPIServer.m create mode 100644 ios/BTFuse/src/BTFuseAPIServerHeaders.m create mode 100644 ios/BTFuse/src/BTFuseContext.m create mode 100644 ios/BTFuse/src/BTFuseError.m create mode 100644 ios/BTFuse/src/BTFuseIDGenerator.m create mode 100644 ios/BTFuse/src/BTFuseJSONSerializer.m create mode 100644 ios/BTFuse/src/BTFuseKeyFactory.m create mode 100644 ios/BTFuse/src/BTFuseKeyPair.m create mode 100644 ios/BTFuse/src/BTFuseLocalization.m create mode 100644 ios/BTFuse/src/BTFuseLogger.m create mode 100644 ios/BTFuse/src/BTFuseLoggerLevel.m create mode 100644 ios/BTFuse/src/BTFuseNWErrorFactory.m create mode 100644 ios/BTFuse/src/BTFusePlugin.m create mode 100644 ios/BTFuse/src/BTFuseSchemeHandler.m create mode 100644 ios/BTFuse/src/BTFuseStreamReader.m create mode 100644 ios/BTFuse/src/BTFuseViewController.m create mode 100644 ios/BTFuse/src/BTFuseWebviewNavigationDelegate.m create mode 100644 ios/BTFuse/src/BTFuseWebviewUIDelegation.m create mode 100644 ios/BTFuse/src/plugins/BTFuseRuntime.m create mode 100644 ios/BTFuseTestTools.podspec.template create mode 100644 ios/LICENSE create mode 100644 ios/NOTICE create mode 100644 ios/Overview.docc/Overview.md create mode 100644 ios/Podfile create mode 100644 ios/Podfile.lock create mode 100644 ios/README.md create mode 100644 ios/VERSION create mode 100755 ios/build.sh create mode 100755 ios/makeRelease.sh create mode 100755 ios/podPublish.sh create mode 100755 ios/test.sh create mode 100644 test-app/.npmrc create mode 100644 test-app/ios/en.lproj/Localizable.strings create mode 100755 test-app/ios/scripts/build.sh create mode 100644 test-app/ios/testapp.xcodeproj/project.pbxproj create mode 100644 test-app/ios/testapp.xcodeproj/xcshareddata/xcschemes/testapp.xcscheme create mode 100644 test-app/ios/testapp/AppDelegate.h create mode 100644 test-app/ios/testapp/AppDelegate.m create mode 100644 test-app/ios/testapp/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 test-app/ios/testapp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 test-app/ios/testapp/Assets.xcassets/Contents.json create mode 100644 test-app/ios/testapp/Base.lproj/LaunchScreen.storyboard create mode 100644 test-app/ios/testapp/Base.lproj/Main.storyboard create mode 100644 test-app/ios/testapp/Info.plist create mode 100644 test-app/ios/testapp/SceneDelegate.h create mode 100644 test-app/ios/testapp/SceneDelegate.m create mode 100644 test-app/ios/testapp/ViewController.h create mode 100644 test-app/ios/testapp/ViewController.m create mode 100644 test-app/ios/testapp/main.m diff --git a/.github/workflows/ios17.yml b/.github/workflows/ios17.yml new file mode 100644 index 0000000..dd34b15 --- /dev/null +++ b/.github/workflows/ios17.yml @@ -0,0 +1,32 @@ + +name: iOS 17 + +on: + push: + paths: + - 'ios/**' + pull_request: + paths: + - 'ios/**' + +jobs: + build: + name: Test iOS 17 + runs-on: macos-14 + + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: 15.4 + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: True + - name: Install CocoaPods + run: gem install cocoapods -v 1.15.2 + - name: Pod Install + run: pod install --repo-update + - name: Build + run: ./build.sh + - name: Test iOS 17.5 + run: ./test.sh "Fuse iOS 17.5" "17.5" "iPhone 15" diff --git a/.github/workflows/ios18.yml b/.github/workflows/ios18.yml new file mode 100644 index 0000000..d908867 --- /dev/null +++ b/.github/workflows/ios18.yml @@ -0,0 +1,32 @@ + +name: iOS 18 + +on: + push: + paths: + - 'ios/**' + pull_request: + paths: + - 'ios/**' + +jobs: + build: + name: Test iOS 18 + runs-on: macos-14 + + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '16.0' + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: True + - name: Install CocoaPods + run: gem install cocoapods -v 1.15.2 + - name: Pod Install + run: pod install --repo-update + - name: Build + run: ./build.sh + - name: Test iOS 18.0 + run: ./test.sh "Fuse iOS 18.0" "18.0" "iPhone 15" diff --git a/.gitignore b/.gitignore index a49a362..549a8e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .DS_Store -/fuse-* +*.docc-build +*.profraw +xcuserdata +.gradle diff --git a/echo/.npmignore b/echo/.npmignore new file mode 100644 index 0000000..8e961f2 --- /dev/null +++ b/echo/.npmignore @@ -0,0 +1,8 @@ +tsconfig.json +jest.config.ts +*.tgz +spec +src +/android +/ios +/dist diff --git a/echo/ios/echo.xcodeproj/project.pbxproj b/echo/ios/echo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e381e4d --- /dev/null +++ b/echo/ios/echo.xcodeproj/project.pbxproj @@ -0,0 +1,323 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 94552C572ACA131600DAE0F4 /* EchoPlugin.h in Sources */ = {isa = PBXBuildFile; fileRef = 94A886CF2A7169030098530D /* EchoPlugin.h */; }; + 94552C582ACA131600DAE0F4 /* EchoPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A886D02A7169030098530D /* EchoPlugin.m */; }; + 945A05962AE582F90042C88A /* BTFuse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 945A05952AE582F90042C88A /* BTFuse.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 94552C442ACA0FBD00DAE0F4 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 94552C462ACA0FBD00DAE0F4 /* libecho.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libecho.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 945A05952AE582F90042C88A /* BTFuse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BTFuse.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 94A886CF2A7169030098530D /* EchoPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EchoPlugin.h; sourceTree = ""; }; + 94A886D02A7169030098530D /* EchoPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EchoPlugin.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 94552C432ACA0FBD00DAE0F4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 945A05962AE582F90042C88A /* BTFuse.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 94A886C32A7169030098530D = { + isa = PBXGroup; + children = ( + 94A886CE2A7169030098530D /* echo */, + 94A886CD2A7169030098530D /* Products */, + 94A886D82A71691C0098530D /* Frameworks */, + ); + sourceTree = ""; + }; + 94A886CD2A7169030098530D /* Products */ = { + isa = PBXGroup; + children = ( + 94552C462ACA0FBD00DAE0F4 /* libecho.a */, + ); + name = Products; + sourceTree = ""; + }; + 94A886CE2A7169030098530D /* echo */ = { + isa = PBXGroup; + children = ( + 94A886CF2A7169030098530D /* EchoPlugin.h */, + 94A886D02A7169030098530D /* EchoPlugin.m */, + ); + path = echo; + sourceTree = ""; + }; + 94A886D82A71691C0098530D /* Frameworks */ = { + isa = PBXGroup; + children = ( + 945A05952AE582F90042C88A /* BTFuse.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 94552C452ACA0FBD00DAE0F4 /* echo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 94552C4C2ACA0FBD00DAE0F4 /* Build configuration list for PBXNativeTarget "echo" */; + buildPhases = ( + 94552C422ACA0FBD00DAE0F4 /* Sources */, + 94552C432ACA0FBD00DAE0F4 /* Frameworks */, + 94552C442ACA0FBD00DAE0F4 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = echo; + productName = echo; + productReference = 94552C462ACA0FBD00DAE0F4 /* libecho.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 94A886C42A7169030098530D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1510; + TargetAttributes = { + 94552C452ACA0FBD00DAE0F4 = { + CreatedOnToolsVersion = 15.0; + }; + }; + }; + buildConfigurationList = 94A886C72A7169030098530D /* Build configuration list for PBXProject "echo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 94A886C32A7169030098530D; + productRefGroup = 94A886CD2A7169030098530D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 94552C452ACA0FBD00DAE0F4 /* echo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 94552C422ACA0FBD00DAE0F4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 94552C572ACA131600DAE0F4 /* EchoPlugin.h in Sources */, + 94552C582ACA131600DAE0F4 /* EchoPlugin.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 94552C4D2ACA0FBD00DAE0F4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = AF37P8XHYY; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 94552C4E2ACA0FBD00DAE0F4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = AF37P8XHYY; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; + 94A886D32A7169030098530D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + 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 = 15.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 94A886D42A7169030098530D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + 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 = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 94552C4C2ACA0FBD00DAE0F4 /* Build configuration list for PBXNativeTarget "echo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94552C4D2ACA0FBD00DAE0F4 /* Debug */, + 94552C4E2ACA0FBD00DAE0F4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 94A886C72A7169030098530D /* Build configuration list for PBXProject "echo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94A886D32A7169030098530D /* Debug */, + 94A886D42A7169030098530D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 94A886C42A7169030098530D /* Project object */; +} diff --git a/echo/ios/echo/EchoPlugin.h b/echo/ios/echo/EchoPlugin.h new file mode 100644 index 0000000..a709bd6 --- /dev/null +++ b/echo/ios/echo/EchoPlugin.h @@ -0,0 +1,30 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef EchoPlugin_h +#define EchoPlugin_h + +#import +#import + +@interface EchoPlugin : BTFusePlugin + +- (NSString*) getID; + +@end + +#endif diff --git a/echo/ios/echo/EchoPlugin.m b/echo/ios/echo/EchoPlugin.m new file mode 100644 index 0000000..9ede8e5 --- /dev/null +++ b/echo/ios/echo/EchoPlugin.m @@ -0,0 +1,124 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import "EchoPlugin.h" +#import + +@implementation EchoPlugin + +- (NSString*) getID { + return @"echo"; +} + +- (void) initHandles { + __weak EchoPlugin* weakSelf = self; + + [self attachHandler:@"/echo" callback:^void(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + NSData* message = [packet readAsBinary]; + [weakSelf doEcho: message withResponse:response]; + }]; + + [self attachHandler:@"/echoWithReader" callback:^void(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + BTFuseStreamReader* reader = [[BTFuseStreamReader alloc] init: [[packet getClient] getInputStream]]; + + NSMutableData* data = [[NSMutableData alloc] init]; + + const int BUFFER_SIZE = 8; + + uint8_t buffer[BUFFER_SIZE]; + uint64_t bytesRead = 0; + bool didError = false; + while ((bytesRead = [reader read: buffer maxBytes: BUFFER_SIZE])) { + if (bytesRead == -1) { + didError = true; + break; + } + + [data appendBytes: buffer length: bytesRead]; + } + + [response sendData: data]; + }]; + + [self attachHandler:@"/big" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + NSString* bundlePath = [[NSBundle mainBundle] resourcePath]; + NSString* assetPath = [bundlePath stringByAppendingPathComponent:@"/assets/largeFile.txt"]; + + NSFileManager* fileManager = [NSFileManager defaultManager]; + NSDictionary* fileAttributes = [fileManager attributesOfItemAtPath:assetPath error:nil]; + + NSNumber* fileSizeNumber = [fileAttributes objectForKey:NSFileSize]; + + [response setStatus: BTFuseAPIResponseStatusOk]; + [response setContentType:@"text/plain"]; + [response setContentLength: [fileSizeNumber unsignedIntegerValue]]; + [response didFinishHeaders]; + + NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:assetPath]; + [inputStream open]; + + NSUInteger bufferSize = 256 * 1024; // Adjust this according to your needs + uint8_t buffer[bufferSize]; + NSInteger bytesRead = 0; + + while ([inputStream hasBytesAvailable]) { + bytesRead = [inputStream read:buffer maxLength:bufferSize]; + if (bytesRead > 0) { + NSData* data = [NSData dataWithBytes:buffer length:bytesRead]; + + [response pushData:data]; + } + } + + [inputStream close]; + + [response didFinish]; + }]; + + [self attachHandler:@"/subscribe" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + NSString* callbackID = [packet readAsString]; + + __block int num = 0; + dispatch_async(dispatch_get_main_queue(), ^{ + [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:true block:^(NSTimer * _Nonnull timer) { + num++; + + [[self getContext] execCallback:callbackID withData:[[NSString alloc] initWithFormat:@"%d", num]]; + }]; + }); + + [response didFinishHeaders]; + [response didFinish]; + }]; + + [self attachHandler:@"/threadtest" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ + [self doEcho: [packet readAsBinary] withResponse:response]; + }); + }]; +} + +- (void) doEcho:(NSData*)data withResponse:(BTFuseAPIResponse*) response { + [response setStatus: BTFuseAPIResponseStatusOk]; + [response setContentType:@"text/plain"]; + [response setContentLength: [data length]]; + [response didFinishHeaders]; + [response pushData:data]; + [response didFinish]; +} + +@end diff --git a/echo/package-lock.json b/echo/package-lock.json index ba49758..d12dbbd 100644 --- a/echo/package-lock.json +++ b/echo/package-lock.json @@ -7,7 +7,6 @@ "": { "name": "echo", "version": "1.0.0", - "hasInstallScript": true, "license": "Apache-2.0", "devDependencies": { "@btfuse/core": "file:../js/dist/fuse.tgz", @@ -17,7 +16,7 @@ "node_modules/@btfuse/core": { "version": "0.8.0", "resolved": "file:../js/dist/fuse.tgz", - "integrity": "sha512-NAimFhZcJavV0/21oLmL27ttYjXR4CnvIlLZJCBLSwUoNoljsXAdnshTkoEVYxrLskuCWryChOTqg4X0vUSAjw==", + "integrity": "sha512-nGVROxkXqa6NvMzVhNR73H56ayN/xdDBnDZQMysuwRMFRsgMfpKAvcYnCnNNjfrtBKV8I6Aw8jZGnVbdjEtVMw==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/echo/package.json b/echo/package.json index 929a331..4973b75 100644 --- a/echo/package.json +++ b/echo/package.json @@ -11,9 +11,7 @@ "author": "", "license": "Apache-2.0", "devDependencies": { - "typescript": "5.3.3", - "@btfuse/core": "file:../js/dist/fuse.tgz" - }, - "peerDependencies": {}, - "dependencies": {} + "@btfuse/core": "file:../js/dist/fuse.tgz", + "typescript": "5.3.3" + } } diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..b800f44 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,6 @@ +/build +/dist +/BTFuse/openssl/out +/BTFuse.podspec +/BTFuseTestTools.podspec +/Pods diff --git a/ios/.gitmodules b/ios/.gitmodules new file mode 100644 index 0000000..a04d95f --- /dev/null +++ b/ios/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build-tools"] + path = build-tools + url = https://github.com/btfuse/build-tools.git diff --git a/ios/BTFuse.podspec.template b/ios/BTFuse.podspec.template new file mode 100644 index 0000000..7257204 --- /dev/null +++ b/ios/BTFuse.podspec.template @@ -0,0 +1,21 @@ + +Pod::Spec.new do |s| + s.name = 'BTFuse' + s.version = '$VERSION$' + s.summary = 'A native-first framework for building hybrid native-web applications.' + s.homepage = 'https://fuse.breautek.com' + s.author = { 'BTFuse' => 'norman@breautek.com' } + s.license = { + :type => 'Apache-2.0', + :file => 'BTFuse.xcframework/ios-arm64/BTFuse.framework/LICENSE' + } + + s.ios.deployment_target = '15.0' + + s.source = { + :http => 'https://github.com/btfuse/fuse-ios/releases/download/$VERSION$/BTFuse.xcframework.zip', + :sha1 => '$CHECKSUM$' + } + + s.vendored_frameworks = 'BTFuse.xcframework' +end diff --git a/ios/BTFuse.xcworkspace/contents.xcworkspacedata b/ios/BTFuse.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..d1ff831 --- /dev/null +++ b/ios/BTFuse.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + diff --git a/ios/BTFuse.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/BTFuse.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/BTFuse.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/BTFuse/BTFuse.docc/BTFuse.md b/ios/BTFuse/BTFuse.docc/BTFuse.md new file mode 100644 index 0000000..a01c332 --- /dev/null +++ b/ios/BTFuse/BTFuse.docc/BTFuse.md @@ -0,0 +1,13 @@ +# ``BTFuse`` + +Summary + +## Overview + +Text + +## Topics + +### Group + +- ``Symbol`` \ No newline at end of file diff --git a/ios/BTFuse/BTFuse.xcodeproj/project.pbxproj b/ios/BTFuse/BTFuse.xcodeproj/project.pbxproj new file mode 100644 index 0000000..dd5f36b --- /dev/null +++ b/ios/BTFuse/BTFuse.xcodeproj/project.pbxproj @@ -0,0 +1,900 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 4623189FF7D4E90BE001140D /* Pods_BTFuse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F8F21041C403672D61CB71B /* Pods_BTFuse.framework */; }; + 940127172AD78F6200F76331 /* BTFuseJSONSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 940127162AD78F6200F76331 /* BTFuseJSONSerializer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 940127192AD78FFD00F76331 /* BTFuseJSONSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 940127182AD78FFD00F76331 /* BTFuseJSONSerializer.m */; }; + 9418629B2A99564600CCFEE1 /* BTFuseAPIRouter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9418629A2A99564600CCFEE1 /* BTFuseAPIRouter.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9418629D2A9956F100CCFEE1 /* BTFuseAPIRouter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9418629C2A9956F100CCFEE1 /* BTFuseAPIRouter.m */; }; + 9418629F2A995BDC00CCFEE1 /* BTFuseAPIPacket.h in Headers */ = {isa = PBXBuildFile; fileRef = 9418629E2A995BDC00CCFEE1 /* BTFuseAPIPacket.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 941862A12A995C4F00CCFEE1 /* BTFuseAPIPacket.m in Sources */ = {isa = PBXBuildFile; fileRef = 941862A02A995C4F00CCFEE1 /* BTFuseAPIPacket.m */; }; + 941862A32A99617100CCFEE1 /* BTFuseAPIResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 941862A22A99617100CCFEE1 /* BTFuseAPIResponse.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 941862A52A996F7900CCFEE1 /* BTFuseAPIResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 941862A42A996F7900CCFEE1 /* BTFuseAPIResponse.m */; }; + 941862AB2A9FE5F700CCFEE1 /* BTFuseError.h in Headers */ = {isa = PBXBuildFile; fileRef = 941862AA2A9FE5F700CCFEE1 /* BTFuseError.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 941862AD2A9FE65E00CCFEE1 /* BTFuseError.m in Sources */ = {isa = PBXBuildFile; fileRef = 941862AC2A9FE65E00CCFEE1 /* BTFuseError.m */; }; + 9435AEE02B0995AC00C1140A /* Network.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9435AEDF2B0995AC00C1140A /* Network.framework */; }; + 944112BA2AED442300309527 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 944112B92AED442300309527 /* PrivacyInfo.xcprivacy */; }; + 9443F0AF2B1AA9070056B054 /* BTFuseNWErrorFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443F0AE2B1AA9070056B054 /* BTFuseNWErrorFactory.h */; }; + 9443F0B12B1AA9550056B054 /* BTFuseNWErrorFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 9443F0B02B1AA9550056B054 /* BTFuseNWErrorFactory.m */; }; + 9443F0B32B1BC9120056B054 /* BTFuseKeyFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443F0B22B1BC9120056B054 /* BTFuseKeyFactory.h */; }; + 9443F0B52B1BC9280056B054 /* BTFuseKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443F0B42B1BC9280056B054 /* BTFuseKeyPair.h */; }; + 9443F0B72B1BC98D0056B054 /* BTFuseKeyPair.m in Sources */ = {isa = PBXBuildFile; fileRef = 9443F0B62B1BC98D0056B054 /* BTFuseKeyPair.m */; }; + 9443F0B92B1BC9A90056B054 /* BTFuseKeyFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 9443F0B82B1BC9A90056B054 /* BTFuseKeyFactory.m */; }; + 9443F0BB2B1BCEE10056B054 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9443F0BA2B1BCEE10056B054 /* Security.framework */; }; + 94552C612ACC32E600DAE0F4 /* BTFuseLoggerLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = 94552C602ACC32E600DAE0F4 /* BTFuseLoggerLevel.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94552C632ACC367600DAE0F4 /* BTFuseLoggerLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = 94552C622ACC367600DAE0F4 /* BTFuseLoggerLevel.m */; }; + 94552C652ACCD47C00DAE0F4 /* BTFuseLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 94552C642ACCD47C00DAE0F4 /* BTFuseLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94552C672ACCD67100DAE0F4 /* BTFuseLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 94552C662ACCD67100DAE0F4 /* BTFuseLogger.m */; }; + 945A05982AE5838D0042C88A /* BTFuseTestTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 945A05972AE5838D0042C88A /* BTFuseTestTools.framework */; }; + 94668BEC2B202EDA00976FC1 /* BTFuseWebviewNavigationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 94668BEB2B202EDA00976FC1 /* BTFuseWebviewNavigationDelegate.h */; }; + 94668BEE2B202F3200976FC1 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94668BED2B202F3200976FC1 /* WebKit.framework */; }; + 94668BF02B202F4900976FC1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94668BEF2B202F4900976FC1 /* UIKit.framework */; }; + 94668BF22B202F7400976FC1 /* BTFuseWebviewNavigationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 94668BF12B202F7400976FC1 /* BTFuseWebviewNavigationDelegate.m */; }; + 94668BFC2B22B76000976FC1 /* BTFuseContextDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 94668BFB2B22B76000976FC1 /* BTFuseContextDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94668C002B22CC1800976FC1 /* libecho.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94668BFF2B22CC1800976FC1 /* libecho.a */; }; + 947B0CB92AE338850018B6E9 /* BTFuseJSONSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 947B0CB82AE338850018B6E9 /* BTFuseJSONSerializerTests.m */; }; + 947FF0D22AC89FA2003D09BC /* BTFuseAPITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 947FF0D12AC89FA2003D09BC /* BTFuseAPITests.m */; }; + 947FF0F02AC8A375003D09BC /* BTFuseAPIResponseFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 947FF0EF2AC8A375003D09BC /* BTFuseAPIResponseFactory.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 947FF0F22AC8A3DA003D09BC /* BTFuseAPIResponseFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 947FF0F12AC8A3DA003D09BC /* BTFuseAPIResponseFactory.m */; }; + 9489EB982AA54FA40087424D /* BTFuseRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 9489EB972AA54FA40087424D /* BTFuseRuntime.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9489EB9A2AA54FED0087424D /* BTFuseRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 9489EB992AA54FED0087424D /* BTFuseRuntime.m */; }; + 9489EB9F2AA61A1C0087424D /* BTFuseWebviewUIDelegation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9489EB9E2AA61A1C0087424D /* BTFuseWebviewUIDelegation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9489EBA12AA61A770087424D /* BTFuseWebviewUIDelegation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9489EBA02AA61A770087424D /* BTFuseWebviewUIDelegation.m */; }; + 9489EBA32AA621A70087424D /* BTFuseViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9489EBA22AA621A70087424D /* BTFuseViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9489EBA52AA623B70087424D /* BTFuseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9489EBA42AA623B70087424D /* BTFuseViewController.m */; }; + 9489EBAE2AA6445C0087424D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9489EBB02AA6445C0087424D /* Localizable.strings */; }; + 9489EBB82AA659D70087424D /* BTFuseLocalization.h in Headers */ = {isa = PBXBuildFile; fileRef = 9489EBB72AA659D70087424D /* BTFuseLocalization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9489EBBA2AA65A990087424D /* BTFuseLocalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 9489EBB92AA65A990087424D /* BTFuseLocalization.m */; }; + 949DEED72C45FB1C00DEDD84 /* BTFuseStreamReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 949DEED62C45FB1C00DEDD84 /* BTFuseStreamReader.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 949DEED92C45FB6C00DEDD84 /* BTFuseStreamReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 949DEED82C45FB6C00DEDD84 /* BTFuseStreamReader.m */; }; + 949DEEF12C496FAC00DEDD84 /* OpenSSL.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 949DEEF02C496FAC00DEDD84 /* OpenSSL.xcframework */; }; + 94A886B72A714F6D0098530D /* BTFuse.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A8865C2A702C6C0098530D /* BTFuse.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94A886B82A714F6D0098530D /* BTFuseContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A886632A702D240098530D /* BTFuseContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94A886B92A714F6D0098530D /* BTFuseSchemeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A886682A702F020098530D /* BTFuseSchemeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94A886BB2A714F6D0098530D /* BTFuseSchemeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A8866A2A702F430098530D /* BTFuseSchemeHandler.m */; }; + 94A886BC2A714F6D0098530D /* BTFuseContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A886662A702D6A0098530D /* BTFuseContext.m */; }; + 94A886DC2A7169920098530D /* BTFusePlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A886DB2A7169920098530D /* BTFusePlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94A886DE2A716A0C0098530D /* BTFusePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A886DD2A716A0C0098530D /* BTFusePlugin.m */; }; + 94A928412B0C466C00AAC44A /* BTFuseAPIClientInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A928402B0C466C00AAC44A /* BTFuseAPIClientInputStream.m */; }; + 94A928432B0C476F00AAC44A /* BTFuseAPIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A928422B0C476F00AAC44A /* BTFuseAPIClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94A928452B0C47C400AAC44A /* BTFuseAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A928442B0C47C400AAC44A /* BTFuseAPIClient.m */; }; + 94A928482B0C50DB00AAC44A /* BTFuseAPIClientOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A928472B0C50DB00AAC44A /* BTFuseAPIClientOutputStream.m */; }; + 94A9284B2B13E41B00AAC44A /* BTFuseAPIClientInputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A9283F2B0C463700AAC44A /* BTFuseAPIClientInputStream.h */; }; + 94A9284C2B13E41E00AAC44A /* BTFuseAPIClientOutputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A928462B0C500900AAC44A /* BTFuseAPIClientOutputStream.h */; }; + 94A9284F2B13E46300AAC44A /* BTFuseAPIServerHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A9284E2B13E46300AAC44A /* BTFuseAPIServerHeaders.h */; }; + 94A928532B13E4C700AAC44A /* BTFuseAPIServerHeaders.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A928522B13E4C700AAC44A /* BTFuseAPIServerHeaders.m */; }; + 94A928552B1A724700AAC44A /* BTFuseIDGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 94A928542B1A724700AAC44A /* BTFuseIDGenerator.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94A928572B1A729000AAC44A /* BTFuseIDGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A928562B1A729000AAC44A /* BTFuseIDGenerator.m */; }; + 94B0A68F2AB776DC008C291A /* BTFuseAPIServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 94B0A68E2AB776DC008C291A /* BTFuseAPIServer.h */; }; + 94B0A6932AB77790008C291A /* BTFuseAPIServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B0A6922AB77790008C291A /* BTFuseAPIServer.m */; }; + 94B7A9CF2AC89E39003D294D /* BTFuseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B7A9CE2AC89E39003D294D /* BTFuseTests.m */; }; + 94B7A9D02AC89E39003D294D /* BTFuse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94A886C22A714F6D0098530D /* BTFuse.framework */; platformFilter = ios; }; + 94C3AF282B6867B8006AD040 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 94C3AF272B6867B8006AD040 /* LICENSE */; }; + 94DF9FB72B293C9C00757EA7 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94DF9FB62B293C9C00757EA7 /* UniformTypeIdentifiers.framework */; }; + 94F13A1D2CA4EF1800CCCC89 /* BTFuse.docc in Sources */ = {isa = PBXBuildFile; fileRef = 94F13A1C2CA4EF1800CCCC89 /* BTFuse.docc */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 94B7A9D12AC89E39003D294D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 94A886502A702C6C0098530D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 94A886B52A714F6D0098530D; + remoteInfo = BTFuse; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 3F8F21041C403672D61CB71B /* Pods_BTFuse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BTFuse.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 940127162AD78F6200F76331 /* BTFuseJSONSerializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseJSONSerializer.h; sourceTree = ""; }; + 940127182AD78FFD00F76331 /* BTFuseJSONSerializer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseJSONSerializer.m; sourceTree = ""; }; + 9418629A2A99564600CCFEE1 /* BTFuseAPIRouter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIRouter.h; sourceTree = ""; }; + 9418629C2A9956F100CCFEE1 /* BTFuseAPIRouter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIRouter.m; sourceTree = ""; }; + 9418629E2A995BDC00CCFEE1 /* BTFuseAPIPacket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIPacket.h; sourceTree = ""; }; + 941862A02A995C4F00CCFEE1 /* BTFuseAPIPacket.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIPacket.m; sourceTree = ""; }; + 941862A22A99617100CCFEE1 /* BTFuseAPIResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIResponse.h; sourceTree = ""; }; + 941862A42A996F7900CCFEE1 /* BTFuseAPIResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIResponse.m; sourceTree = ""; }; + 941862AA2A9FE5F700CCFEE1 /* BTFuseError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseError.h; sourceTree = ""; }; + 941862AC2A9FE65E00CCFEE1 /* BTFuseError.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseError.m; sourceTree = ""; }; + 9435AEDF2B0995AC00C1140A /* Network.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Network.framework; path = System/Library/Frameworks/Network.framework; sourceTree = SDKROOT; }; + 944112B92AED442300309527 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 9443F0AE2B1AA9070056B054 /* BTFuseNWErrorFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseNWErrorFactory.h; sourceTree = ""; }; + 9443F0B02B1AA9550056B054 /* BTFuseNWErrorFactory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseNWErrorFactory.m; sourceTree = ""; }; + 9443F0B22B1BC9120056B054 /* BTFuseKeyFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseKeyFactory.h; sourceTree = ""; }; + 9443F0B42B1BC9280056B054 /* BTFuseKeyPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseKeyPair.h; sourceTree = ""; }; + 9443F0B62B1BC98D0056B054 /* BTFuseKeyPair.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseKeyPair.m; sourceTree = ""; }; + 9443F0B82B1BC9A90056B054 /* BTFuseKeyFactory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseKeyFactory.m; sourceTree = ""; }; + 9443F0BA2B1BCEE10056B054 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + 94552C5C2ACB3A5600DAE0F4 /* BTFuse.release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = BTFuse.release.xcconfig; path = configs/BTFuse.release.xcconfig; sourceTree = ""; }; + 94552C602ACC32E600DAE0F4 /* BTFuseLoggerLevel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseLoggerLevel.h; sourceTree = ""; usesTabs = 0; }; + 94552C622ACC367600DAE0F4 /* BTFuseLoggerLevel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseLoggerLevel.m; sourceTree = ""; }; + 94552C642ACCD47C00DAE0F4 /* BTFuseLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseLogger.h; sourceTree = ""; }; + 94552C662ACCD67100DAE0F4 /* BTFuseLogger.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseLogger.m; sourceTree = ""; }; + 945A05972AE5838D0042C88A /* BTFuseTestTools.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BTFuseTestTools.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 94668BD22B1EBBB300976FC1 /* libopenssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libopenssl.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 94668BEB2B202EDA00976FC1 /* BTFuseWebviewNavigationDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseWebviewNavigationDelegate.h; sourceTree = ""; }; + 94668BED2B202F3200976FC1 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + 94668BEF2B202F4900976FC1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 94668BF12B202F7400976FC1 /* BTFuseWebviewNavigationDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseWebviewNavigationDelegate.m; sourceTree = ""; }; + 94668BFB2B22B76000976FC1 /* BTFuseContextDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseContextDelegate.h; sourceTree = ""; }; + 94668BFF2B22CC1800976FC1 /* libecho.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libecho.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 947B0CB82AE338850018B6E9 /* BTFuseJSONSerializerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseJSONSerializerTests.m; sourceTree = ""; }; + 947FF0D12AC89FA2003D09BC /* BTFuseAPITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPITests.m; sourceTree = ""; }; + 947FF0EF2AC8A375003D09BC /* BTFuseAPIResponseFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIResponseFactory.h; sourceTree = ""; }; + 947FF0F12AC8A3DA003D09BC /* BTFuseAPIResponseFactory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIResponseFactory.m; sourceTree = ""; }; + 9489EB972AA54FA40087424D /* BTFuseRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseRuntime.h; sourceTree = ""; }; + 9489EB992AA54FED0087424D /* BTFuseRuntime.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseRuntime.m; sourceTree = ""; }; + 9489EB9E2AA61A1C0087424D /* BTFuseWebviewUIDelegation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseWebviewUIDelegation.h; sourceTree = ""; }; + 9489EBA02AA61A770087424D /* BTFuseWebviewUIDelegation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseWebviewUIDelegation.m; sourceTree = ""; }; + 9489EBA22AA621A70087424D /* BTFuseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseViewController.h; sourceTree = ""; }; + 9489EBA42AA623B70087424D /* BTFuseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseViewController.m; sourceTree = ""; }; + 9489EBAF2AA6445C0087424D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 9489EBB72AA659D70087424D /* BTFuseLocalization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseLocalization.h; sourceTree = ""; }; + 9489EBB92AA65A990087424D /* BTFuseLocalization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseLocalization.m; sourceTree = ""; }; + 949DEED62C45FB1C00DEDD84 /* BTFuseStreamReader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseStreamReader.h; sourceTree = ""; }; + 949DEED82C45FB6C00DEDD84 /* BTFuseStreamReader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseStreamReader.m; sourceTree = ""; }; + 949DEEF02C496FAC00DEDD84 /* OpenSSL.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OpenSSL.xcframework; path = ../Pods/OpenSSL/OpenSSL.xcframework; sourceTree = ""; }; + 949DEEF52C4970FF00DEDD84 /* BTFuse.debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = BTFuse.debug.xcconfig; path = configs/BTFuse.debug.xcconfig; sourceTree = ""; }; + 94A8865C2A702C6C0098530D /* BTFuse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuse.h; sourceTree = ""; }; + 94A886632A702D240098530D /* BTFuseContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseContext.h; sourceTree = ""; }; + 94A886662A702D6A0098530D /* BTFuseContext.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseContext.m; sourceTree = ""; }; + 94A886682A702F020098530D /* BTFuseSchemeHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseSchemeHandler.h; sourceTree = ""; }; + 94A8866A2A702F430098530D /* BTFuseSchemeHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseSchemeHandler.m; sourceTree = ""; }; + 94A886C22A714F6D0098530D /* BTFuse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BTFuse.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 94A886DB2A7169920098530D /* BTFusePlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFusePlugin.h; sourceTree = ""; }; + 94A886DD2A716A0C0098530D /* BTFusePlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFusePlugin.m; sourceTree = ""; }; + 94A9283F2B0C463700AAC44A /* BTFuseAPIClientInputStream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIClientInputStream.h; sourceTree = ""; }; + 94A928402B0C466C00AAC44A /* BTFuseAPIClientInputStream.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIClientInputStream.m; sourceTree = ""; }; + 94A928422B0C476F00AAC44A /* BTFuseAPIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIClient.h; sourceTree = ""; }; + 94A928442B0C47C400AAC44A /* BTFuseAPIClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIClient.m; sourceTree = ""; }; + 94A928462B0C500900AAC44A /* BTFuseAPIClientOutputStream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIClientOutputStream.h; sourceTree = ""; }; + 94A928472B0C50DB00AAC44A /* BTFuseAPIClientOutputStream.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIClientOutputStream.m; sourceTree = ""; }; + 94A9284E2B13E46300AAC44A /* BTFuseAPIServerHeaders.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIServerHeaders.h; sourceTree = ""; }; + 94A928522B13E4C700AAC44A /* BTFuseAPIServerHeaders.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIServerHeaders.m; sourceTree = ""; }; + 94A928542B1A724700AAC44A /* BTFuseIDGenerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseIDGenerator.h; sourceTree = ""; }; + 94A928562B1A729000AAC44A /* BTFuseIDGenerator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseIDGenerator.m; sourceTree = ""; }; + 94B0A68E2AB776DC008C291A /* BTFuseAPIServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseAPIServer.h; sourceTree = ""; }; + 94B0A6922AB77790008C291A /* BTFuseAPIServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseAPIServer.m; sourceTree = ""; }; + 94B7A9CC2AC89E39003D294D /* BTFuseTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BTFuseTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 94B7A9CE2AC89E39003D294D /* BTFuseTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseTests.m; sourceTree = ""; }; + 94C3AF272B6867B8006AD040 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; + 94DF9FB62B293C9C00757EA7 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; + 94F13A1C2CA4EF1800CCCC89 /* BTFuse.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = BTFuse.docc; sourceTree = ""; }; + C0D504787CFDCC13C7D8462D /* Pods-BTFuse.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BTFuse.release.xcconfig"; path = "Target Support Files/Pods-BTFuse/Pods-BTFuse.release.xcconfig"; sourceTree = ""; }; + D2524D348AB6B72B049BC41D /* Pods-BTFuse.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BTFuse.debug.xcconfig"; path = "Target Support Files/Pods-BTFuse/Pods-BTFuse.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 94A886BD2A714F6D0098530D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 94DF9FB72B293C9C00757EA7 /* UniformTypeIdentifiers.framework in Frameworks */, + 94668BF02B202F4900976FC1 /* UIKit.framework in Frameworks */, + 949DEEF12C496FAC00DEDD84 /* OpenSSL.xcframework in Frameworks */, + 94668BEE2B202F3200976FC1 /* WebKit.framework in Frameworks */, + 9443F0BB2B1BCEE10056B054 /* Security.framework in Frameworks */, + 9435AEE02B0995AC00C1140A /* Network.framework in Frameworks */, + 4623189FF7D4E90BE001140D /* Pods_BTFuse.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 94B7A9C92AC89E39003D294D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 94B7A9D02AC89E39003D294D /* BTFuse.framework in Frameworks */, + 945A05982AE5838D0042C88A /* BTFuseTestTools.framework in Frameworks */, + 94668C002B22CC1800976FC1 /* libecho.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1F90CC1D6A769DDF9C55C4B5 /* Pods */ = { + isa = PBXGroup; + children = ( + D2524D348AB6B72B049BC41D /* Pods-BTFuse.debug.xcconfig */, + C0D504787CFDCC13C7D8462D /* Pods-BTFuse.release.xcconfig */, + ); + name = Pods; + path = ../Pods; + sourceTree = ""; + }; + 94552C592ACB349A00DAE0F4 /* configurations */ = { + isa = PBXGroup; + children = ( + 949DEEF52C4970FF00DEDD84 /* BTFuse.debug.xcconfig */, + 94552C5C2ACB3A5600DAE0F4 /* BTFuse.release.xcconfig */, + ); + name = configurations; + sourceTree = ""; + }; + 9489EB9B2AA5507B0087424D /* plugins */ = { + isa = PBXGroup; + children = ( + 9489EB972AA54FA40087424D /* BTFuseRuntime.h */, + ); + path = plugins; + sourceTree = ""; + }; + 9489EB9C2AA5508C0087424D /* plugins */ = { + isa = PBXGroup; + children = ( + 9489EB992AA54FED0087424D /* BTFuseRuntime.m */, + ); + path = plugins; + sourceTree = ""; + }; + 9489EBA62AA640ED0087424D /* localization */ = { + isa = PBXGroup; + children = ( + 9489EBB02AA6445C0087424D /* Localizable.strings */, + ); + name = localization; + sourceTree = ""; + }; + 94A8864F2A702C6C0098530D = { + isa = PBXGroup; + children = ( + 94F13A1C2CA4EF1800CCCC89 /* BTFuse.docc */, + 94C3AF272B6867B8006AD040 /* LICENSE */, + 944112B92AED442300309527 /* PrivacyInfo.xcprivacy */, + 94552C592ACB349A00DAE0F4 /* configurations */, + 9489EBA62AA640ED0087424D /* localization */, + 94A886652A702D3A0098530D /* src */, + 94A8865B2A702C6C0098530D /* BTFuse */, + 94B7A9CD2AC89E39003D294D /* BTFuseTests */, + 94A8865A2A702C6C0098530D /* Products */, + B09295BDA9DD81FE38C25D6F /* Frameworks */, + 1F90CC1D6A769DDF9C55C4B5 /* Pods */, + ); + sourceTree = ""; + }; + 94A8865A2A702C6C0098530D /* Products */ = { + isa = PBXGroup; + children = ( + 94A886C22A714F6D0098530D /* BTFuse.framework */, + 94B7A9CC2AC89E39003D294D /* BTFuseTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 94A8865B2A702C6C0098530D /* BTFuse */ = { + isa = PBXGroup; + children = ( + 94A9284A2B13E3FE00AAC44A /* internal */, + 9489EB9B2AA5507B0087424D /* plugins */, + 94A8865C2A702C6C0098530D /* BTFuse.h */, + 94A886632A702D240098530D /* BTFuseContext.h */, + 94A886682A702F020098530D /* BTFuseSchemeHandler.h */, + 947FF0EF2AC8A375003D09BC /* BTFuseAPIResponseFactory.h */, + 94A886DB2A7169920098530D /* BTFusePlugin.h */, + 9418629A2A99564600CCFEE1 /* BTFuseAPIRouter.h */, + 9418629E2A995BDC00CCFEE1 /* BTFuseAPIPacket.h */, + 941862A22A99617100CCFEE1 /* BTFuseAPIResponse.h */, + 941862AA2A9FE5F700CCFEE1 /* BTFuseError.h */, + 9489EB9E2AA61A1C0087424D /* BTFuseWebviewUIDelegation.h */, + 9489EBA22AA621A70087424D /* BTFuseViewController.h */, + 9489EBB72AA659D70087424D /* BTFuseLocalization.h */, + 94552C602ACC32E600DAE0F4 /* BTFuseLoggerLevel.h */, + 94552C642ACCD47C00DAE0F4 /* BTFuseLogger.h */, + 940127162AD78F6200F76331 /* BTFuseJSONSerializer.h */, + 94A928422B0C476F00AAC44A /* BTFuseAPIClient.h */, + 94A928542B1A724700AAC44A /* BTFuseIDGenerator.h */, + 94668BFB2B22B76000976FC1 /* BTFuseContextDelegate.h */, + 949DEED62C45FB1C00DEDD84 /* BTFuseStreamReader.h */, + ); + path = BTFuse; + sourceTree = ""; + }; + 94A886652A702D3A0098530D /* src */ = { + isa = PBXGroup; + children = ( + 94A928512B13E49100AAC44A /* internal */, + 9489EB9C2AA5508C0087424D /* plugins */, + 94A886662A702D6A0098530D /* BTFuseContext.m */, + 94A8866A2A702F430098530D /* BTFuseSchemeHandler.m */, + 94A886DD2A716A0C0098530D /* BTFusePlugin.m */, + 9418629C2A9956F100CCFEE1 /* BTFuseAPIRouter.m */, + 941862A02A995C4F00CCFEE1 /* BTFuseAPIPacket.m */, + 941862A42A996F7900CCFEE1 /* BTFuseAPIResponse.m */, + 941862AC2A9FE65E00CCFEE1 /* BTFuseError.m */, + 9489EBA02AA61A770087424D /* BTFuseWebviewUIDelegation.m */, + 9489EBA42AA623B70087424D /* BTFuseViewController.m */, + 9489EBB92AA65A990087424D /* BTFuseLocalization.m */, + 947FF0F12AC8A3DA003D09BC /* BTFuseAPIResponseFactory.m */, + 94552C622ACC367600DAE0F4 /* BTFuseLoggerLevel.m */, + 94552C662ACCD67100DAE0F4 /* BTFuseLogger.m */, + 940127182AD78FFD00F76331 /* BTFuseJSONSerializer.m */, + 94A928442B0C47C400AAC44A /* BTFuseAPIClient.m */, + 94A928562B1A729000AAC44A /* BTFuseIDGenerator.m */, + 949DEED82C45FB6C00DEDD84 /* BTFuseStreamReader.m */, + ); + path = src; + sourceTree = ""; + }; + 94A9284A2B13E3FE00AAC44A /* internal */ = { + isa = PBXGroup; + children = ( + 94A9283F2B0C463700AAC44A /* BTFuseAPIClientInputStream.h */, + 94A928462B0C500900AAC44A /* BTFuseAPIClientOutputStream.h */, + 94B0A68E2AB776DC008C291A /* BTFuseAPIServer.h */, + 94A9284E2B13E46300AAC44A /* BTFuseAPIServerHeaders.h */, + 9443F0AE2B1AA9070056B054 /* BTFuseNWErrorFactory.h */, + 9443F0B22B1BC9120056B054 /* BTFuseKeyFactory.h */, + 9443F0B42B1BC9280056B054 /* BTFuseKeyPair.h */, + 94668BEB2B202EDA00976FC1 /* BTFuseWebviewNavigationDelegate.h */, + ); + name = internal; + sourceTree = ""; + }; + 94A928512B13E49100AAC44A /* internal */ = { + isa = PBXGroup; + children = ( + 94B0A6922AB77790008C291A /* BTFuseAPIServer.m */, + 94A928402B0C466C00AAC44A /* BTFuseAPIClientInputStream.m */, + 94A928472B0C50DB00AAC44A /* BTFuseAPIClientOutputStream.m */, + 94A928522B13E4C700AAC44A /* BTFuseAPIServerHeaders.m */, + 9443F0B02B1AA9550056B054 /* BTFuseNWErrorFactory.m */, + 9443F0B62B1BC98D0056B054 /* BTFuseKeyPair.m */, + 9443F0B82B1BC9A90056B054 /* BTFuseKeyFactory.m */, + 94668BF12B202F7400976FC1 /* BTFuseWebviewNavigationDelegate.m */, + ); + name = internal; + sourceTree = ""; + }; + 94B7A9CD2AC89E39003D294D /* BTFuseTests */ = { + isa = PBXGroup; + children = ( + 94B7A9CE2AC89E39003D294D /* BTFuseTests.m */, + 947FF0D12AC89FA2003D09BC /* BTFuseAPITests.m */, + 947B0CB82AE338850018B6E9 /* BTFuseJSONSerializerTests.m */, + ); + path = BTFuseTests; + sourceTree = ""; + }; + B09295BDA9DD81FE38C25D6F /* Frameworks */ = { + isa = PBXGroup; + children = ( + 949DEEF02C496FAC00DEDD84 /* OpenSSL.xcframework */, + 94DF9FB62B293C9C00757EA7 /* UniformTypeIdentifiers.framework */, + 94668BFF2B22CC1800976FC1 /* libecho.a */, + 94668BEF2B202F4900976FC1 /* UIKit.framework */, + 94668BED2B202F3200976FC1 /* WebKit.framework */, + 94668BD22B1EBBB300976FC1 /* libopenssl.a */, + 9443F0BA2B1BCEE10056B054 /* Security.framework */, + 9435AEDF2B0995AC00C1140A /* Network.framework */, + 945A05972AE5838D0042C88A /* BTFuseTestTools.framework */, + 3F8F21041C403672D61CB71B /* Pods_BTFuse.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 94A886B62A714F6D0098530D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 94A886DC2A7169920098530D /* BTFusePlugin.h in Headers */, + 9489EB9F2AA61A1C0087424D /* BTFuseWebviewUIDelegation.h in Headers */, + 94A886B72A714F6D0098530D /* BTFuse.h in Headers */, + 9489EBA32AA621A70087424D /* BTFuseViewController.h in Headers */, + 9418629B2A99564600CCFEE1 /* BTFuseAPIRouter.h in Headers */, + 94A886B92A714F6D0098530D /* BTFuseSchemeHandler.h in Headers */, + 94A928552B1A724700AAC44A /* BTFuseIDGenerator.h in Headers */, + 9489EBB82AA659D70087424D /* BTFuseLocalization.h in Headers */, + 940127172AD78F6200F76331 /* BTFuseJSONSerializer.h in Headers */, + 9443F0AF2B1AA9070056B054 /* BTFuseNWErrorFactory.h in Headers */, + 949DEED72C45FB1C00DEDD84 /* BTFuseStreamReader.h in Headers */, + 9443F0B32B1BC9120056B054 /* BTFuseKeyFactory.h in Headers */, + 9443F0B52B1BC9280056B054 /* BTFuseKeyPair.h in Headers */, + 94552C612ACC32E600DAE0F4 /* BTFuseLoggerLevel.h in Headers */, + 941862AB2A9FE5F700CCFEE1 /* BTFuseError.h in Headers */, + 947FF0F02AC8A375003D09BC /* BTFuseAPIResponseFactory.h in Headers */, + 94A9284F2B13E46300AAC44A /* BTFuseAPIServerHeaders.h in Headers */, + 94668BEC2B202EDA00976FC1 /* BTFuseWebviewNavigationDelegate.h in Headers */, + 94668BFC2B22B76000976FC1 /* BTFuseContextDelegate.h in Headers */, + 94A928432B0C476F00AAC44A /* BTFuseAPIClient.h in Headers */, + 9489EB982AA54FA40087424D /* BTFuseRuntime.h in Headers */, + 94552C652ACCD47C00DAE0F4 /* BTFuseLogger.h in Headers */, + 9418629F2A995BDC00CCFEE1 /* BTFuseAPIPacket.h in Headers */, + 94A9284B2B13E41B00AAC44A /* BTFuseAPIClientInputStream.h in Headers */, + 94B0A68F2AB776DC008C291A /* BTFuseAPIServer.h in Headers */, + 941862A32A99617100CCFEE1 /* BTFuseAPIResponse.h in Headers */, + 94A9284C2B13E41E00AAC44A /* BTFuseAPIClientOutputStream.h in Headers */, + 94A886B82A714F6D0098530D /* BTFuseContext.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 94A886B52A714F6D0098530D /* BTFuse */ = { + isa = PBXNativeTarget; + buildConfigurationList = 94A886BF2A714F6D0098530D /* Build configuration list for PBXNativeTarget "BTFuse" */; + buildPhases = ( + 86DD15681D11060B0F30F338 /* [CP] Check Pods Manifest.lock */, + 94A886B62A714F6D0098530D /* Headers */, + 94A886BA2A714F6D0098530D /* Sources */, + 94A886BD2A714F6D0098530D /* Frameworks */, + 94A886BE2A714F6D0098530D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BTFuse; + productName = BTFuse; + productReference = 94A886C22A714F6D0098530D /* BTFuse.framework */; + productType = "com.apple.product-type.framework"; + }; + 94B7A9CB2AC89E39003D294D /* BTFuseTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 94B7A9D32AC89E39003D294D /* Build configuration list for PBXNativeTarget "BTFuseTests" */; + buildPhases = ( + 94B7A9C82AC89E39003D294D /* Sources */, + 94B7A9C92AC89E39003D294D /* Frameworks */, + 94B7A9CA2AC89E39003D294D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 94B7A9D22AC89E39003D294D /* PBXTargetDependency */, + ); + name = BTFuseTests; + productName = BTFuseTests; + productReference = 94B7A9CC2AC89E39003D294D /* BTFuseTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 94A886502A702C6C0098530D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1510; + TargetAttributes = { + 94A886B52A714F6D0098530D = { + LastSwiftMigration = 1600; + }; + 94B7A9CB2AC89E39003D294D = { + CreatedOnToolsVersion = 15.0; + }; + }; + }; + buildConfigurationList = 94A886532A702C6C0098530D /* Build configuration list for PBXProject "BTFuse" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 94A8864F2A702C6C0098530D; + productRefGroup = 94A8865A2A702C6C0098530D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 94A886B52A714F6D0098530D /* BTFuse */, + 94B7A9CB2AC89E39003D294D /* BTFuseTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 94A886BE2A714F6D0098530D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 94C3AF282B6867B8006AD040 /* LICENSE in Resources */, + 944112BA2AED442300309527 /* PrivacyInfo.xcprivacy in Resources */, + 9489EBAE2AA6445C0087424D /* Localizable.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 94B7A9CA2AC89E39003D294D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 86DD15681D11060B0F30F338 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-BTFuse-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 94A886BA2A714F6D0098530D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 941862A12A995C4F00CCFEE1 /* BTFuseAPIPacket.m in Sources */, + 94A886DE2A716A0C0098530D /* BTFusePlugin.m in Sources */, + 941862AD2A9FE65E00CCFEE1 /* BTFuseError.m in Sources */, + 9489EBA12AA61A770087424D /* BTFuseWebviewUIDelegation.m in Sources */, + 94552C672ACCD67100DAE0F4 /* BTFuseLogger.m in Sources */, + 9443F0B12B1AA9550056B054 /* BTFuseNWErrorFactory.m in Sources */, + 94A928532B13E4C700AAC44A /* BTFuseAPIServerHeaders.m in Sources */, + 94A886BB2A714F6D0098530D /* BTFuseSchemeHandler.m in Sources */, + 94F13A1D2CA4EF1800CCCC89 /* BTFuse.docc in Sources */, + 9418629D2A9956F100CCFEE1 /* BTFuseAPIRouter.m in Sources */, + 9489EB9A2AA54FED0087424D /* BTFuseRuntime.m in Sources */, + 94A928572B1A729000AAC44A /* BTFuseIDGenerator.m in Sources */, + 949DEED92C45FB6C00DEDD84 /* BTFuseStreamReader.m in Sources */, + 9489EBA52AA623B70087424D /* BTFuseViewController.m in Sources */, + 94668BF22B202F7400976FC1 /* BTFuseWebviewNavigationDelegate.m in Sources */, + 947FF0F22AC8A3DA003D09BC /* BTFuseAPIResponseFactory.m in Sources */, + 94A928412B0C466C00AAC44A /* BTFuseAPIClientInputStream.m in Sources */, + 941862A52A996F7900CCFEE1 /* BTFuseAPIResponse.m in Sources */, + 9443F0B72B1BC98D0056B054 /* BTFuseKeyPair.m in Sources */, + 94B0A6932AB77790008C291A /* BTFuseAPIServer.m in Sources */, + 94A928482B0C50DB00AAC44A /* BTFuseAPIClientOutputStream.m in Sources */, + 940127192AD78FFD00F76331 /* BTFuseJSONSerializer.m in Sources */, + 94A928452B0C47C400AAC44A /* BTFuseAPIClient.m in Sources */, + 94552C632ACC367600DAE0F4 /* BTFuseLoggerLevel.m in Sources */, + 9489EBBA2AA65A990087424D /* BTFuseLocalization.m in Sources */, + 94A886BC2A714F6D0098530D /* BTFuseContext.m in Sources */, + 9443F0B92B1BC9A90056B054 /* BTFuseKeyFactory.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 94B7A9C82AC89E39003D294D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 947B0CB92AE338850018B6E9 /* BTFuseJSONSerializerTests.m in Sources */, + 94B7A9CF2AC89E39003D294D /* BTFuseTests.m in Sources */, + 947FF0D22AC89FA2003D09BC /* BTFuseAPITests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 94B7A9D22AC89E39003D294D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + platformFilter = ios; + target = 94A886B52A714F6D0098530D /* BTFuse */; + targetProxy = 94B7A9D12AC89E39003D294D /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 9489EBB02AA6445C0087424D /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 9489EBAF2AA6445C0087424D /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 94A8865E2A702C6C0098530D /* 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++20"; + 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 = ""; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = 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; + HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/openssl/include"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LIBRARY_SEARCH_PATHS = ""; + MARKETING_VERSION = ""; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ""; + SDKROOT = iphoneos; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 94A8865F2A702C6C0098530D /* 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++20"; + 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 = ""; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = 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; + HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/openssl/include"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LIBRARY_SEARCH_PATHS = ""; + MARKETING_VERSION = ""; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ""; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 94A886C02A714F6D0098530D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D2524D348AB6B72B049BC41D /* Pods-BTFuse.debug.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = AF37P8XHYY; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ""; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 6.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 94A886C12A714F6D0098530D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 94552C5C2ACB3A5600DAE0F4 /* BTFuse.release.xcconfig */; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = AF37P8XHYY; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ""; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 6.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; + 94B7A9D42AC89E39003D294D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = AF37P8XHYY; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../echo/echo/\"", + "$(BUILT_PRODUCTS_DIR)/openssl/include", + ); + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse.test; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = NO; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 94B7A9D52AC89E39003D294D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = AF37P8XHYY; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../echo/echo/\"", + "$(BUILT_PRODUCTS_DIR)/openssl/include", + ); + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse.test; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = NO; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 94A886532A702C6C0098530D /* Build configuration list for PBXProject "BTFuse" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94A8865E2A702C6C0098530D /* Debug */, + 94A8865F2A702C6C0098530D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 94A886BF2A714F6D0098530D /* Build configuration list for PBXNativeTarget "BTFuse" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94A886C02A714F6D0098530D /* Debug */, + 94A886C12A714F6D0098530D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 94B7A9D32AC89E39003D294D /* Build configuration list for PBXNativeTarget "BTFuseTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94B7A9D42AC89E39003D294D /* Debug */, + 94B7A9D52AC89E39003D294D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 94A886502A702C6C0098530D /* Project object */; +} diff --git a/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuse.xcscheme b/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuse.xcscheme new file mode 100644 index 0000000..49b17e2 --- /dev/null +++ b/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuse.xcscheme @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuseTests.xcscheme b/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuseTests.xcscheme new file mode 100644 index 0000000..4596209 --- /dev/null +++ b/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/BTFuseTests.xcscheme @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/openssl.xcscheme b/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/openssl.xcscheme new file mode 100644 index 0000000..b8f686e --- /dev/null +++ b/ios/BTFuse/BTFuse.xcodeproj/xcshareddata/xcschemes/openssl.xcscheme @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/BTFuse/BTFuse/BTFuse.h b/ios/BTFuse/BTFuse/BTFuse.h new file mode 100644 index 0000000..121f368 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuse.h @@ -0,0 +1,44 @@ + +/* +Copyright Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import + +FOUNDATION_EXPORT double BTFuseVersionNumber; +FOUNDATION_EXPORT const unsigned char BTFuseVersionString[]; + +#import +#import +#import +#import +#import +#import +#import +#import +//#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +// Core Plugins +#import diff --git a/ios/BTFuse/BTFuse/BTFuseAPIClient.h b/ios/BTFuse/BTFuse/BTFuseAPIClient.h new file mode 100644 index 0000000..5b4eb13 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIClient.h @@ -0,0 +1,72 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIClient_h +#define BTFuseAPIClient_h + +#import +#import + +@interface BTFuseAPIClient: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(nw_connection_t) connection NS_DESIGNATED_INITIALIZER; + +- (NSInputStream*) getInputStream; +- (NSOutputStream*) getOutputStream; + +- (NSInteger) write:(NSData*) buffer; +- (NSInteger) read:(NSMutableData*) buffer length:(uint32_t) length; + +- (void) start:(void (^)(NSError* error)) completionBlock; + +- (NSString*) getID; + +- (void) close; + +/** + States indicating whether a connection can be used to send and receive data. + Can be one of: + - nw_connection_state_invalid + The connection is not valid. + + - nw_connection_state_waiting + The connection is waiting for a network path change. + + - nw_connection_state_preparing + The connection in the process of being established. + + - nw_connection_state_ready + The connection is established, and ready to send and receive data. + + - nw_connection_state_failed + The connection has disconnected or encountered an error. + + - nw_connection_state_cancelled + The connection has been canceled. + */ +- (nw_connection_state_t) getConnectionState; + +- (NSString*) getHTTPHeader: (NSString*) name; +- (NSDictionary*) getHTTPHeaders; +- (NSString*) getHTTPVersion; +- (NSString*) getHTTPMethod; +- (NSString*) getHTTPPath; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIClientInputStream.h b/ios/BTFuse/BTFuse/BTFuseAPIClientInputStream.h new file mode 100644 index 0000000..c89f952 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIClientInputStream.h @@ -0,0 +1,35 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIClientInputStream_h +#define BTFuseAPIClientInputStream_h + +#import +#import + +@interface BTFuseAPIClientInputStream: NSInputStream + +@property (readonly) BOOL hasBytesAvailable; +@property (readonly) NSStreamStatus streamStatus; +@property (nullable, readonly, copy) NSError* streamError; +@property (nullable, atomic, weak) id delegate; + +- (instancetype _Nonnull) init:(nw_connection_t _Nonnull) connection; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIClientOutputStream.h b/ios/BTFuse/BTFuse/BTFuseAPIClientOutputStream.h new file mode 100644 index 0000000..5b01d22 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIClientOutputStream.h @@ -0,0 +1,32 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIClientOutputStream_h +#define BTFuseAPIClientOutputStream_h + + +@interface BTFuseAPIClientOutputStream: NSOutputStream + +@property (readonly) BOOL hasSpaceAvailable; +@property (nullable, readonly, copy) NSError* streamError; +@property (readonly) NSStreamStatus streamStatus; + +- (instancetype _Nonnull) init:(nw_connection_t _Nonnull ) connection; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIPacket.h b/ios/BTFuse/BTFuse/BTFuseAPIPacket.h new file mode 100644 index 0000000..19c9ebe --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIPacket.h @@ -0,0 +1,62 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIPacket_h +#define BTFuseAPIPacket_h + +#import +#import + +@class BTFuseContext; + +@interface BTFuseAPIPacket: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context route:(NSString*) route headers:(NSDictionary*) headers client:(BTFuseAPIClient*) client NS_DESIGNATED_INITIALIZER; + +- (NSString*) getRoute; +- (BTFuseAPIClient*) getClient; +- (uint64_t) getContentLength; +- (NSString*) getContentType; + +/** + Reads the packet as a string. + Do not call on the main thread. + */ +- (NSString*) readAsString; + +/** + Reads the packet as binary. + Do not call on the main thread. + */ +- (NSData*) readAsBinary; + +/** + Reads the packet as a JSON/Dictionary object. + Do not call on the main thread. + */ +- (NSDictionary*) readAsJSONObject:(NSError**) error; + +/** + Reads the packet as an array. + Do not call on the main thread. + */ +- (NSArray*) readAsJSONArray:(NSError**) error; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIResponse.h b/ios/BTFuse/BTFuse/BTFuseAPIResponse.h new file mode 100644 index 0000000..b096c31 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIResponse.h @@ -0,0 +1,66 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIResponse_h +#define BTFuseAPIResponse_h + +#import +#import +#import +#import + +@class BTFuseContext; + +typedef NS_ENUM(NSUInteger, BTFuseAPIResponseStatus) { + BTFuseAPIResponseStatusOk = 200, + BTFuseAPIResponseStatusError = 400, + BTFuseAPIResponseStatusInternalError = 500 +}; + +@interface BTFuseAPIResponse: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context client:(BTFuseAPIClient*) client NS_DESIGNATED_INITIALIZER; + +// Header APIs +- (void) setStatus:(NSUInteger) status; +- (NSString*) getStatusText:(NSUInteger) status; +- (void) setContentLength:(NSUInteger) length; +- (void) setContentType:(NSString*) contentType; +- (void) didFinishHeaders; +- (void) finishHeaders:(NSUInteger) status withContentType:(NSString*) contentType withContentLength:(NSUInteger) contentLength; + +// Data APIs +- (void) pushData:(NSData*) data; +- (void) didFinish; + +- (void) didInternalError; +- (bool) isClosed; + +// Convenience methods, if you don't need to chunk data +- (void) sendString:(NSString*) data; +- (void) sendData:(NSData*) data; +- (void) sendData:(NSDate*) data withType:(NSString*) type; +- (void) sendJSON:(NSDictionary*) data; +- (void) sendNoContent; +- (void) sendError:(BTFuseError*) error; + +- (void) kill:(NSString*) message; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIResponseFactory.h b/ios/BTFuse/BTFuse/BTFuseAPIResponseFactory.h new file mode 100644 index 0000000..4ce3d36 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIResponseFactory.h @@ -0,0 +1,34 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIResponseFactory_h +#define BTFuseAPIResponseFactory_h + +#import +#import + +@class BTFuseContext; + +@interface BTFuseAPIResponseFactory: NSObject {} + +- (instancetype) init NS_DESIGNATED_INITIALIZER; + +- (BTFuseAPIResponse*) create:(BTFuseContext*) context client:(BTFuseAPIClient*) client; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIRouter.h b/ios/BTFuse/BTFuse/BTFuseAPIRouter.h new file mode 100644 index 0000000..4bcf1bf --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIRouter.h @@ -0,0 +1,36 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIRouter_h +#define BTFuseAPIRouter_h + +#import +#import + +@class BTFuseContext; + +@interface BTFuseAPIRouter: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context NS_DESIGNATED_INITIALIZER; + +- (BTFuseContext*) getContext; +- (void) execute:(BTFuseAPIPacket*) packet withResponse:(BTFuseAPIResponse*) response; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIServer.h b/ios/BTFuse/BTFuse/BTFuseAPIServer.h new file mode 100644 index 0000000..2e342d5 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIServer.h @@ -0,0 +1,37 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIServer_h +#define BTFuseAPIServer_h + +#import +#import "BTFuseKeyPair.h" + +extern const uint32_t BTFUSEAPISERVER_BUFFER_SIZE; + +@interface BTFuseAPIServer: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context; +- (int) getPort; +- (NSString*) getSecret; +- (BTFuseContext*) getContext; +- (BTFuseKeyPair*) getKeypair; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseAPIServerHeaders.h b/ios/BTFuse/BTFuse/BTFuseAPIServerHeaders.h new file mode 100644 index 0000000..3918e75 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseAPIServerHeaders.h @@ -0,0 +1,41 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseAPIServerHeaders_h +#define BTFuseAPIServerHeaders_h + +@interface BTFuseAPIServerHeaders: NSObject { + NSMutableDictionary* $headers; + NSString* $method; + NSString* $version; + NSString* $path; +} + +- (instancetype) init NS_DESIGNATED_INITIALIZER; +- (NSString*) getMethod; +- (NSString*) getPath; +- (NSString*) getVersion; +- (NSString*) getHeader:(NSString*) name; +- (NSDictionary*) getHeaders; +- (void) setMethod:(NSString*) method; +- (void) setPath:(NSString*) path; +- (void) setVersion:(NSString*) version; +- (void) setHeader:(NSString*) name withValue:(NSString*) value; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseContext.h b/ios/BTFuse/BTFuse/BTFuseContext.h new file mode 100644 index 0000000..4e489b7 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseContext.h @@ -0,0 +1,57 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseContext_H +#define BTFuseContext_H + +#import +#import +#import +#import +#import + +@class BTFuseViewController; +@class BTFusePlugin; +@class BTFuseAPIRouter; +@class BTFuseLogger; + +@interface BTFuseContext: NSObject + +- (nonnull instancetype) init NS_UNAVAILABLE; +//- (nonnull instancetype) init NS_DESIGNATED_INITIALIZER; +- (nonnull instancetype) init:(nonnull id) delegate; +//- (nonnull instancetype) init:(nonnull BTFuseViewController*) controller NS_DESIGNATED_INITIALIZER; +- (nonnull BTFuseAPIResponseFactory*) getResponseFactory; +- (void) setResponseFactory:(nonnull BTFuseAPIResponseFactory*) factory; +- (nullable WKWebView*) getWebview; +- (nonnull UIView*) getLayout; +//- (nonnull BTFuseViewController*) getViewController; +- (void) registerPlugin:(nonnull BTFusePlugin*)plugin; +- (nonnull BTFusePlugin*) getPlugin:(nonnull NSString*)pluginID; +- (nonnull BTFuseAPIRouter*) getAPIRouter; +- (void) execCallback:(nonnull NSString*) callbackID withData:(nonnull NSString*) data; +- (void) execCallback:(nonnull NSString*) callbackID; +- (int) getAPIPort; +- (nonnull NSString*) getAPIKeyIdentifier; +- (nonnull NSString*) getAPISecret; +- (nonnull BTFuseLogger*) getLogger; +- (nonnull id) createWebviewNavigationDelegate; +- (nonnull NSString*) getHost; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseContextDelegate.h b/ios/BTFuse/BTFuse/BTFuseContextDelegate.h new file mode 100644 index 0000000..62198c8 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseContextDelegate.h @@ -0,0 +1,34 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseContextDelegate_h +#define BTFuseContextDelegate_h + +#import +#import + +@protocol BTFuseContextDelegate + +- (void) dispatchToWebview:(nonnull NSString*) callbackID withData:(nonnull NSString*) data; +- (void) dispatchToWebview:(nonnull NSString*) callbackID; +- (nonnull WKWebView*) getWebview; +- (nonnull UIView*) getLayout; + +@end + + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseError.h b/ios/BTFuse/BTFuse/BTFuseError.h new file mode 100644 index 0000000..8183a76 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseError.h @@ -0,0 +1,35 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseError_h +#define BTFuseError_h + +@interface BTFuseError: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(NSString*) domain withCode:(NSInteger) code withMessage:(NSString*) message NS_DESIGNATED_INITIALIZER; +- (instancetype) init:(NSString*) domain withCode:(NSInteger) code withError:(NSError*) error; + +- (NSString*) getDomain; +- (NSString*) getMessage; +- (NSInteger) getCode; + +- (NSString*) serialize: (NSError*)error; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseIDGenerator.h b/ios/BTFuse/BTFuse/BTFuseIDGenerator.h new file mode 100644 index 0000000..5abd836 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseIDGenerator.h @@ -0,0 +1,28 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseIDGenerator_h +#define BTFuseIDGenerator_h + +@interface BTFuseIDGenerator: NSObject + +- (instancetype) init NS_DESIGNATED_INITIALIZER; +- (NSString*) generate; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseJSONSerializer.h b/ios/BTFuse/BTFuse/BTFuseJSONSerializer.h new file mode 100644 index 0000000..9da1899 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseJSONSerializer.h @@ -0,0 +1,30 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +#ifndef BTFuseJSONSerializer_h +#define BTFuseJSONSerializer_h + +@interface BTFuseJSONSerializer: NSObject + +- (instancetype) init NS_UNAVAILABLE; + ++ (NSString*) serialize:(NSDictionary*) data withError:(NSError**) error; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseKeyFactory.h b/ios/BTFuse/BTFuse/BTFuseKeyFactory.h new file mode 100644 index 0000000..5fa39bf --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseKeyFactory.h @@ -0,0 +1,33 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseKeyFactory_h +#define BTFuseKeyFactory_h + +#import "BTFuseKeyPair.h" + +@interface BTFuseKeyFactory: NSObject + +- (instancetype) init NS_UNAVAILABLE; + ++ (instancetype) getInstance; + +- (BTFuseKeyPair*) create; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseKeyPair.h b/ios/BTFuse/BTFuse/BTFuseKeyPair.h new file mode 100644 index 0000000..8f41dbd --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseKeyPair.h @@ -0,0 +1,39 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseKeyPair_h +#define BTFuseKeyPair_h + +#import +#include + +@interface BTFuseKeyPair: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(EVP_PKEY*) key certificate:(X509*) certificate identifier:(NSString*) identifier; + +- (SecKeyRef) getPrivate; +- (SecKeyRef) getPublic; +- (SecCertificateRef) getCertificate; +- (SecIdentityRef) getIdentity; +- (SecTrustRef) getTrust; +- (NSString*) getIdentifier; +- (X509*) getX509; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseLocalization.h b/ios/BTFuse/BTFuse/BTFuseLocalization.h new file mode 100644 index 0000000..65af810 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseLocalization.h @@ -0,0 +1,34 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseLocalization_h +#define BTFuseLocalization_h + +/** + A static class that will look for strings in the mainBundle, and fallback to the framework bundle. + This offers a chance for the application to override UI text that the framework produces. + */ +@interface BTFuseLocalization: NSObject + +- (instancetype) init NS_UNAVAILABLE; + ++ (NSString*) lookup:(NSString*) key; + +@end + + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseLogger.h b/ios/BTFuse/BTFuse/BTFuseLogger.h new file mode 100644 index 0000000..7dd78b4 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseLogger.h @@ -0,0 +1,42 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseLogger_h +#define BTFuseLogger_h + +#import + +@class BTFuseContext; + +@interface BTFuseLogger: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context NS_DESIGNATED_INITIALIZER; + +- (void) setLevel:(BTFuseLoggerLevel) level; +- (BTFuseLoggerLevel) getLevel; + +- (void) setCallbackID:(NSString*) callbackID; + +- (void) debug:(NSString*) format, ... NS_FORMAT_FUNCTION(1, 2); +- (void) info:(NSString*) format, ... NS_FORMAT_FUNCTION(1, 2); +- (void) warn:(NSString*) format, ... NS_FORMAT_FUNCTION(1, 2); +- (void) error:(NSString*) format, ... NS_FORMAT_FUNCTION(1, 2); + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseLoggerLevel.h b/ios/BTFuse/BTFuse/BTFuseLoggerLevel.h new file mode 100644 index 0000000..ac3fcdd --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseLoggerLevel.h @@ -0,0 +1,31 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseLoggerLevel_h +#define BTFuseLoggerLevel_h + +typedef NS_ENUM(NSUInteger, BTFuseLoggerLevel) { + BTFuseLoggerLevelSilent = 0, + BTFuseLoggerLevelDebug = 1 << 0, + BTFuseLoggerLevelInfo = 1 << 1, + BTFuseLoggerLevelWarn = 1 << 2, + BTFuseLoggerLevelError = 1 << 3 +}; + +NSString* BTFuseLoggerLevel_toString(BTFuseLoggerLevel level); + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseNWErrorFactory.h b/ios/BTFuse/BTFuse/BTFuseNWErrorFactory.h new file mode 100644 index 0000000..6ec8c9d --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseNWErrorFactory.h @@ -0,0 +1,31 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseNWErrorFactory_h +#define BTFuseNWErrorFactory_h + +#import + +@interface BTFuseNWErrorFactory: NSObject + +- (instancetype) init NS_UNAVAILABLE; + ++ (NSError*) create:(nw_error_t) nwError; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFusePlugin.h b/ios/BTFuse/BTFuse/BTFusePlugin.h new file mode 100644 index 0000000..938cf94 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFusePlugin.h @@ -0,0 +1,49 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFusePlugin_h +#define BTFusePlugin_h + +#import +#import +#import + +typedef void (^BTFusePluginAPIHandle)(BTFuseAPIPacket* packet, BTFuseAPIResponse* response); + +@class BTFuseContext; + +@protocol BTFusePluginProtocol + +- (NSString*)getID; + +@end + +@interface BTFusePlugin: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context NS_DESIGNATED_INITIALIZER; + +- (void) route:(NSString*)path withPacket:(BTFuseAPIPacket*) packet withResponse:(BTFuseAPIResponse*) response; + +- (void) initHandles; +- (void) attachHandler:(NSString*) path callback:(BTFusePluginAPIHandle)callback; + +- (BTFuseContext*) getContext; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseSchemeHandler.h b/ios/BTFuse/BTFuse/BTFuseSchemeHandler.h new file mode 100644 index 0000000..86123c3 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseSchemeHandler.h @@ -0,0 +1,34 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseSchemeHandler_h +#define BTFuseSchemeHandler_h + +#import +#import + +@class BTFuseContext; + +@interface BTFuseSchemeHandler: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*)context NS_DESIGNATED_INITIALIZER; +- (BTFuseContext*) getContext; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseStreamReader.h b/ios/BTFuse/BTFuse/BTFuseStreamReader.h new file mode 100644 index 0000000..28d01f8 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseStreamReader.h @@ -0,0 +1,48 @@ + +/* +Copyright Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseStreamReader_h +#define BTFuseStreamReader_h + +/** + The NSInputStream object is non-blocking, requiring a delegate implementation + to listen for stream events to determine when it's safe to read the stream, and to determine + when the stream has ended. + + This makes it difficult to use in context of a thread, so this object can be used as the stream + delegate to respond to events and to block the thread when necessary for the read calls. This + API will behave similar to the C read API. + + Do not read streams on the main thread + */ +@interface BTFuseStreamReader: NSObject + +- (instancetype) init:(NSInputStream*) stream; + +/** + On success, the number of bytes read is returned (zero indicates + end of file), and the file position is advanced by this number. + It is not an error if this number is smaller than the number of + bytes requested; this may happen for example because fewer bytes + are actually available right now. + On error, -1 is returned + */ +- (int64_t) read:(uint8_t*) buffer maxBytes:(uint32_t) max; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseViewController.h b/ios/BTFuse/BTFuse/BTFuseViewController.h new file mode 100644 index 0000000..131826a --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseViewController.h @@ -0,0 +1,58 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseViewController_h +#define BTFuseViewController_h + +#import +#import +#import +#import + +@class BTFuseContext; + +@protocol BTFuseViewControllerDelegate + - (void) onContextReady; + - (void) onWebviewReady; + - (void) onBeforeWebviewLoad; +@end + +@interface BTFuseViewController: UIViewController < + WKScriptMessageHandler, + WKScriptMessageHandlerWithReply, + BTFuseContextDelegate +> + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) initWithCoder:(NSCoder*) coder NS_UNAVAILABLE; +- (instancetype) initWithNibName:(NSString*) nibNameOrNil bundle:(NSBundle*) nibBundleOrNil NS_UNAVAILABLE; +- (instancetype) init:(id) delegate; + +- (BTFuseContext*) getContext; + +- (WKWebView*) getWebview; + +- (UIView*) getLayout; + +/** +* Convenience method for attaching the views and controller configuration. +*/ +- (void) attach:(UIViewController*) controller; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseWebviewNavigationDelegate.h b/ios/BTFuse/BTFuse/BTFuseWebviewNavigationDelegate.h new file mode 100644 index 0000000..421432c --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseWebviewNavigationDelegate.h @@ -0,0 +1,33 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseWebviewNavigationDelegate_h +#define BTFuseWebviewNavigationDelegate_h + +#import +#import "BTFuseKeyPair.h" + +@class BTFuseContext; + +@interface BTFuseWebviewNavigationDelegate: NSObject + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(BTFuseContext*) context keypair:(BTFuseKeyPair*) keypair NS_DESIGNATED_INITIALIZER; + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/BTFuseWebviewUIDelegation.h b/ios/BTFuse/BTFuse/BTFuseWebviewUIDelegation.h new file mode 100644 index 0000000..0a9d0d0 --- /dev/null +++ b/ios/BTFuse/BTFuse/BTFuseWebviewUIDelegation.h @@ -0,0 +1,28 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseWebviewUIDelegation_h +#define BTFuseWebviewUIDelegation_h + +#import +#import + +@interface BTFuseWebviewUIDelegation : UIViewController + +@end + +#endif diff --git a/ios/BTFuse/BTFuse/plugins/BTFuseRuntime.h b/ios/BTFuse/BTFuse/plugins/BTFuseRuntime.h new file mode 100644 index 0000000..eac6efa --- /dev/null +++ b/ios/BTFuse/BTFuse/plugins/BTFuseRuntime.h @@ -0,0 +1,38 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseRuntime_h +#define BTFuseRuntime_h + +#import +#import + +@interface BTFuseRuntime : BTFusePlugin + +@property (atomic, strong) NSMutableArray* $pauseHandlers; +@property (atomic, strong) NSMutableArray* $resumeHandlers; + +- (NSString*) getID; + +- (NSDictionary*) getInfo; + +- (void) onPause; +- (void) onResume; + +@end + +#endif diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.docc/BTFuseTestTools.md b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.docc/BTFuseTestTools.md new file mode 100644 index 0000000..c854132 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.docc/BTFuseTestTools.md @@ -0,0 +1,13 @@ +# ``BTFuseTestTools`` + +Summary + +## Overview + +Text + +## Topics + +### Group + +- ``Symbol`` \ No newline at end of file diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/project.pbxproj b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2d123dc --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/project.pbxproj @@ -0,0 +1,436 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 944112BC2AED44C800309527 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 944112BB2AED44C800309527 /* PrivacyInfo.xcprivacy */; }; + 945A05922AE582C90042C88A /* BTFuse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 945A05912AE582C90042C88A /* BTFuse.framework */; }; + 946278442AC8A94A008A89FA /* BTFuseTestViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 946278432AC8A94A008A89FA /* BTFuseTestViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 946278462AC8A987008A89FA /* BTFuseTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 946278452AC8A987008A89FA /* BTFuseTestViewController.m */; }; + 9462784C2AC8B154008A89FA /* BTFuseTestAPIResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 9462784B2AC8B154008A89FA /* BTFuseTestAPIResponse.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9462784E2AC8B1AF008A89FA /* BTFuseTestAPIResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 9462784D2AC8B1AF008A89FA /* BTFuseTestAPIResponse.m */; }; + 946278502AC8B1D1008A89FA /* BTFuseTestAPIResponseFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9462784F2AC8B1D1008A89FA /* BTFuseTestAPIResponseFactory.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 946278522AC8B3EE008A89FA /* BTFuseTestAPIResponseFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 946278512AC8B3EE008A89FA /* BTFuseTestAPIResponseFactory.m */; }; + 94668BFE2B22C5B100976FC1 /* BTFuseTestUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 94668BFD2B22C5B100976FC1 /* BTFuseTestUtils.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 947FF1092AC8A82E003D09BC /* BTFuseTestTools.h in Headers */ = {isa = PBXBuildFile; fileRef = 947FF1082AC8A82E003D09BC /* BTFuseTestTools.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94C3AF2B2B68681A006AD040 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 94C3AF2A2B68681A006AD040 /* LICENSE */; }; + 94D499BB2AC9CFEE009917A7 /* BTFuseTestAPIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 94D499BA2AC9CFEE009917A7 /* BTFuseTestAPIClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 94D499BD2AC9D254009917A7 /* BTFuseTestAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 94D499BC2AC9D254009917A7 /* BTFuseTestAPIClient.m */; }; + 94F13A1F2CA4EF2C00CCCC89 /* BTFuseTestTools.docc in Sources */ = {isa = PBXBuildFile; fileRef = 94F13A1E2CA4EF2C00CCCC89 /* BTFuseTestTools.docc */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 944112BB2AED44C800309527 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 94552C5E2ACB624400DAE0F4 /* libecho.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libecho.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 945A05912AE582C90042C88A /* BTFuse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BTFuse.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 946278432AC8A94A008A89FA /* BTFuseTestViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseTestViewController.h; sourceTree = ""; }; + 946278452AC8A987008A89FA /* BTFuseTestViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseTestViewController.m; sourceTree = ""; }; + 9462784B2AC8B154008A89FA /* BTFuseTestAPIResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseTestAPIResponse.h; sourceTree = ""; }; + 9462784D2AC8B1AF008A89FA /* BTFuseTestAPIResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseTestAPIResponse.m; sourceTree = ""; }; + 9462784F2AC8B1D1008A89FA /* BTFuseTestAPIResponseFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseTestAPIResponseFactory.h; sourceTree = ""; }; + 946278512AC8B3EE008A89FA /* BTFuseTestAPIResponseFactory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseTestAPIResponseFactory.m; sourceTree = ""; }; + 94668BFD2B22C5B100976FC1 /* BTFuseTestUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseTestUtils.h; sourceTree = ""; }; + 947FF1052AC8A82E003D09BC /* BTFuseTestTools.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BTFuseTestTools.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 947FF1082AC8A82E003D09BC /* BTFuseTestTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseTestTools.h; sourceTree = ""; }; + 94C3AF2A2B68681A006AD040 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../../LICENSE; sourceTree = ""; }; + 94D499BA2AC9CFEE009917A7 /* BTFuseTestAPIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BTFuseTestAPIClient.h; sourceTree = ""; }; + 94D499BC2AC9D254009917A7 /* BTFuseTestAPIClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BTFuseTestAPIClient.m; sourceTree = ""; }; + 94F13A1E2CA4EF2C00CCCC89 /* BTFuseTestTools.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = BTFuseTestTools.docc; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 947FF1022AC8A82E003D09BC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 945A05922AE582C90042C88A /* BTFuse.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 946278412AC8A926008A89FA /* include */ = { + isa = PBXGroup; + children = ( + 946278432AC8A94A008A89FA /* BTFuseTestViewController.h */, + 9462784B2AC8B154008A89FA /* BTFuseTestAPIResponse.h */, + 9462784F2AC8B1D1008A89FA /* BTFuseTestAPIResponseFactory.h */, + 94D499BA2AC9CFEE009917A7 /* BTFuseTestAPIClient.h */, + 94668BFD2B22C5B100976FC1 /* BTFuseTestUtils.h */, + ); + path = include; + sourceTree = ""; + }; + 946278422AC8A92C008A89FA /* src */ = { + isa = PBXGroup; + children = ( + 946278452AC8A987008A89FA /* BTFuseTestViewController.m */, + 9462784D2AC8B1AF008A89FA /* BTFuseTestAPIResponse.m */, + 946278512AC8B3EE008A89FA /* BTFuseTestAPIResponseFactory.m */, + 94D499BC2AC9D254009917A7 /* BTFuseTestAPIClient.m */, + ); + path = src; + sourceTree = ""; + }; + 947FF0FB2AC8A82E003D09BC = { + isa = PBXGroup; + children = ( + 94F13A1E2CA4EF2C00CCCC89 /* BTFuseTestTools.docc */, + 94C3AF2A2B68681A006AD040 /* LICENSE */, + 944112BB2AED44C800309527 /* PrivacyInfo.xcprivacy */, + 947FF1072AC8A82E003D09BC /* BTFuseTestTools */, + 947FF1062AC8A82E003D09BC /* Products */, + 947FF10F2AC8A83B003D09BC /* Frameworks */, + ); + sourceTree = ""; + }; + 947FF1062AC8A82E003D09BC /* Products */ = { + isa = PBXGroup; + children = ( + 947FF1052AC8A82E003D09BC /* BTFuseTestTools.framework */, + ); + name = Products; + sourceTree = ""; + }; + 947FF1072AC8A82E003D09BC /* BTFuseTestTools */ = { + isa = PBXGroup; + children = ( + 946278412AC8A926008A89FA /* include */, + 946278422AC8A92C008A89FA /* src */, + 947FF1082AC8A82E003D09BC /* BTFuseTestTools.h */, + ); + path = BTFuseTestTools; + sourceTree = ""; + }; + 947FF10F2AC8A83B003D09BC /* Frameworks */ = { + isa = PBXGroup; + children = ( + 945A05912AE582C90042C88A /* BTFuse.framework */, + 94552C5E2ACB624400DAE0F4 /* libecho.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 947FF1002AC8A82E003D09BC /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 946278502AC8B1D1008A89FA /* BTFuseTestAPIResponseFactory.h in Headers */, + 9462784C2AC8B154008A89FA /* BTFuseTestAPIResponse.h in Headers */, + 94D499BB2AC9CFEE009917A7 /* BTFuseTestAPIClient.h in Headers */, + 94668BFE2B22C5B100976FC1 /* BTFuseTestUtils.h in Headers */, + 946278442AC8A94A008A89FA /* BTFuseTestViewController.h in Headers */, + 947FF1092AC8A82E003D09BC /* BTFuseTestTools.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 947FF1042AC8A82E003D09BC /* BTFuseTestTools */ = { + isa = PBXNativeTarget; + buildConfigurationList = 947FF10C2AC8A82E003D09BC /* Build configuration list for PBXNativeTarget "BTFuseTestTools" */; + buildPhases = ( + 947FF1002AC8A82E003D09BC /* Headers */, + 947FF1012AC8A82E003D09BC /* Sources */, + 947FF1022AC8A82E003D09BC /* Frameworks */, + 947FF1032AC8A82E003D09BC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BTFuseTestTools; + productName = BTFuseTestTools; + productReference = 947FF1052AC8A82E003D09BC /* BTFuseTestTools.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 947FF0FC2AC8A82E003D09BC /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1510; + TargetAttributes = { + 947FF1042AC8A82E003D09BC = { + CreatedOnToolsVersion = 15.0; + }; + }; + }; + buildConfigurationList = 947FF0FF2AC8A82E003D09BC /* Build configuration list for PBXProject "BTFuseTestTools" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 947FF0FB2AC8A82E003D09BC; + productRefGroup = 947FF1062AC8A82E003D09BC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 947FF1042AC8A82E003D09BC /* BTFuseTestTools */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 947FF1032AC8A82E003D09BC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 94C3AF2B2B68681A006AD040 /* LICENSE in Resources */, + 944112BC2AED44C800309527 /* PrivacyInfo.xcprivacy in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 947FF1012AC8A82E003D09BC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 94D499BD2AC9D254009917A7 /* BTFuseTestAPIClient.m in Sources */, + 946278462AC8A987008A89FA /* BTFuseTestViewController.m in Sources */, + 9462784E2AC8B1AF008A89FA /* BTFuseTestAPIResponse.m in Sources */, + 946278522AC8B3EE008A89FA /* BTFuseTestAPIResponseFactory.m in Sources */, + 94F13A1F2CA4EF2C00CCCC89 /* BTFuseTestTools.docc in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 947FF10A2AC8A82E003D09BC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + 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; + }; + 947FF10B2AC8A82E003D09BC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 947FF10D2AC8A82E003D09BC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = AF37P8XHYY; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse.testtools; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 947FF10E2AC8A82E003D09BC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = AF37P8XHYY; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse.testtools; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 947FF0FF2AC8A82E003D09BC /* Build configuration list for PBXProject "BTFuseTestTools" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 947FF10A2AC8A82E003D09BC /* Debug */, + 947FF10B2AC8A82E003D09BC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 947FF10C2AC8A82E003D09BC /* Build configuration list for PBXNativeTarget "BTFuseTestTools" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 947FF10D2AC8A82E003D09BC /* Debug */, + 947FF10E2AC8A82E003D09BC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 947FF0FC2AC8A82E003D09BC /* Project object */; +} diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/xcshareddata/xcschemes/BTFuseTestTools.xcscheme b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/xcshareddata/xcschemes/BTFuseTestTools.xcscheme new file mode 100644 index 0000000..d79ea73 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools.xcodeproj/xcshareddata/xcschemes/BTFuseTestTools.xcscheme @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/BTFuseTestTools.h b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/BTFuseTestTools.h new file mode 100644 index 0000000..4060f27 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/BTFuseTestTools.h @@ -0,0 +1,30 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import + +//! Project version number for BTFuseTestTools. +FOUNDATION_EXPORT double BTFuseTestToolsVersionNumber; + +//! Project version string for BTFuseTestTools. +FOUNDATION_EXPORT const unsigned char BTFuseTestToolsVersionString[]; + +#import +#import +#import +#import +#import diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIClient.h b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIClient.h new file mode 100644 index 0000000..3865f43 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIClient.h @@ -0,0 +1,61 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseTestAPIClient_h +#define BTFuseTestAPIClient_h + +@interface BTFuseTestAPIClientResponse: NSObject + +@property (nonatomic, strong) NSNumber* _Nonnull status; +@property (nonatomic, strong) NSData* _Nonnull data; + +- (nonnull instancetype) init NS_UNAVAILABLE; +- (nonnull instancetype) initWithCode:(nonnull NSNumber*) code data:(nonnull NSData*) data NS_DESIGNATED_INITIALIZER; + +- (bool) isError; + +@end + +typedef void (^BTFuseTestAPIClientCallback)(NSError* _Nullable error, BTFuseTestAPIClientResponse* _Nullable response); + +@interface BTFuseTestAPIClient: NSObject +- (nonnull instancetype) init NS_UNAVAILABLE; +- (nonnull instancetype) init:(nonnull NSString*) pluginID + secret:(nonnull NSString*) secret + port:(int) port + endpoint:(nonnull NSString*) endpoint + data:(nullable NSData*) data + type:(nullable NSString*) type; + +- (void) execute:(nonnull BTFuseTestAPIClientCallback) callback; + +@end + +@interface BTFuseTestAPIClientBuilder: NSObject + +@property (nonatomic, strong) NSString* _Nonnull pluginID; +@property (nonatomic, strong) NSNumber* _Nonnull apiPort; +@property (nonatomic, strong) NSString* _Nonnull apiSecret; +@property (nonatomic, strong) NSString* _Nonnull endpoint; +@property (nonatomic, strong) NSData* _Nullable data; +@property (nonatomic, strong) NSString* _Nullable contentType; + +- (nonnull BTFuseTestAPIClient*) build; + +@end + +#endif diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponse.h b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponse.h new file mode 100644 index 0000000..04281a2 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponse.h @@ -0,0 +1,27 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseTestAPIResponse_h +#define BTFuseTestAPIResponse_h + +#import + +@interface BTFuseTestAPIResponse: BTFuseAPIResponse + +@end + +#endif diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponseFactory.h b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponseFactory.h new file mode 100644 index 0000000..5b19204 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestAPIResponseFactory.h @@ -0,0 +1,28 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseTestAPIResponseFactory_h +#define BTFuseTestAPIResponseFactory_h + +#import +#import + +@interface BTFuseTestAPIResponseFactory: BTFuseAPIResponseFactory + +@end + +#endif diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestUtils.h b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestUtils.h new file mode 100644 index 0000000..5a0c2c1 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestUtils.h @@ -0,0 +1,23 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseTestUtils_h +#define BTFuseTestUtils_h + +typedef void (^BTFuseTestSetupCompletionHandler)(NSError* _Nullable); + +#endif diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestViewController.h b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestViewController.h new file mode 100644 index 0000000..a42018a --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/include/BTFuseTestViewController.h @@ -0,0 +1,38 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifndef BTFuseTestViewController_h +#define BTFuseTestViewController_h + +#import + +@protocol BTFuseTestControllerDelegate + +- (void) onContextReady:(BTFuseContext*) context; +- (void) onBeforeWebviewLoad; +- (void) onReady; + +@end + +@interface BTFuseTestViewController: BTFuseViewController + +- (instancetype) init NS_UNAVAILABLE; +- (instancetype) init:(id) delegate NS_DESIGNATED_INITIALIZER; + +@end + +#endif diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIClient.m b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIClient.m new file mode 100644 index 0000000..5509cb9 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIClient.m @@ -0,0 +1,151 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@implementation BTFuseTestAPIClientResponse + +- (instancetype) initWithCode:(NSNumber*) code data:(NSData*) data { + self = [super init]; + + self.status = code; + self.data = data; + + return self; +} + +- (bool) isError { + return [self.status integerValue] >= 400; +} + +@end + +@implementation BTFuseTestAPIClientBuilder + +- (BTFuseTestAPIClient*) build { + return [ + [BTFuseTestAPIClient alloc] + init: self.pluginID + secret: self.apiSecret + port: [self.apiPort intValue] + endpoint: self.endpoint + data: self.data + type: self.contentType + ]; +} + +@end + +@interface BTFuseTestAPIClient () { + NSString* $pluginID; + NSString* $apiSecret; + int $apiPort; + NSString* $endpoint; + NSData* $data; + NSString* $type; + NSString* SECRET_HEADER; + NSString* API_ENDPOINT_BASE; +} +@end + +@implementation BTFuseTestAPIClient + +- (instancetype) init:(NSString*) pluginID secret:(NSString*) secret port:(int) port endpoint:(NSString*) endpoint data:(NSData*) data type:(NSString*) type { + self = [super init]; + + $pluginID = pluginID; + $apiSecret = secret; + $apiPort = port; + $endpoint = endpoint; + $data = data; + $type = type; + + SECRET_HEADER = @"X-Fuse-Secret"; + API_ENDPOINT_BASE = @"https://localhost"; + + return self; +} + +- (NSString*) $getURL { + return [NSString stringWithFormat:@"%@:%d/api/%@%@", API_ENDPOINT_BASE, $apiPort, $pluginID, $endpoint]; +} + +- (void) URLSession:(NSURLSession*) session didReceiveChallenge:(NSURLAuthenticationChallenge*) challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential* _Nullable)) completionHandler +{ + // This is a test class, let's just accept all certificates + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + completionHandler(NSURLSessionAuthChallengeUseCredential, credential); + } + else { + // Handle other types of challenges here + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + } +} + +- (void) execute:(BTFuseTestAPIClientCallback) callback { + NSURL* url = [NSURL URLWithString:[self $getURL]]; + NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL: url]; + [request setHTTPMethod: @"POST"]; + [request setValue: $apiSecret forHTTPHeaderField:SECRET_HEADER]; + if ($type != nil) { + [request setValue:$type forHTTPHeaderField:@"Content-Type"]; + } + if ($data != nil) { + [request setHTTPBody: $data]; + } + + NSURLSessionConfiguration* configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + +// NSURLSession* session = [NSURLSession sharedSession]; + NSOperationQueue* queue = [[NSOperationQueue alloc] init]; + NSURLSession* session = [NSURLSession sessionWithConfiguration: configuration delegate: self delegateQueue: queue]; + + NSURLSessionDataTask* task = [session dataTaskWithRequest: request completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable response, NSError* _Nullable error) { + if (error) { + callback(error, nil); + return; + } + + if (![response isKindOfClass:[NSHTTPURLResponse class]]) { + NSError* error = [[NSError alloc] initWithDomain:@"BTFuseTestAPIClient" code: 0 userInfo:@{ + NSLocalizedDescriptionKey: @"Did not receive a HTTP response" + }]; + callback(error, nil); + return; + } + + NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; + + NSData* responseData = nil; + if (data) { + responseData = data; + } + else { + responseData = [[NSData alloc] init]; + } + + BTFuseTestAPIClientResponse* res = [[BTFuseTestAPIClientResponse alloc] initWithCode:@(httpResponse.statusCode) data:responseData]; + callback(nil, res); + }]; + + [task resume]; +} + +@end diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponse.m b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponse.m new file mode 100644 index 0000000..4a2ee9a --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponse.m @@ -0,0 +1,23 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@implementation BTFuseTestAPIResponse + +@end diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponseFactory.m b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponseFactory.m new file mode 100644 index 0000000..f82dc4a --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestAPIResponseFactory.m @@ -0,0 +1,27 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@implementation BTFuseTestAPIResponseFactory + +- (BTFuseAPIResponse*) create:(BTFuseContext*) context client:(BTFuseAPIClient*) client { + return [[BTFuseTestAPIResponse alloc] init:context client: client]; +} + +@end diff --git a/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestViewController.m b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestViewController.m new file mode 100644 index 0000000..cff2328 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/BTFuseTestTools/src/BTFuseTestViewController.m @@ -0,0 +1,47 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import + +@implementation BTFuseTestViewController { + id $delegate; +} + +- (instancetype) init:(id) delegate { + self = [super init: self]; + + $delegate = delegate; + + return self; +} + +- (void) onContextReady { + [[self getContext] setResponseFactory: [[BTFuseTestAPIResponseFactory alloc] init]]; + [$delegate onContextReady: [self getContext]]; +} + +- (void) onWebviewReady { + [$delegate onReady]; +} + +- (void) onBeforeWebviewLoad { + [$delegate onBeforeWebviewLoad]; +} + +@end diff --git a/ios/BTFuse/BTFuseTestTools/PrivacyInfo.xcprivacy b/ios/BTFuse/BTFuseTestTools/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..6757779 --- /dev/null +++ b/ios/BTFuse/BTFuseTestTools/PrivacyInfo.xcprivacy @@ -0,0 +1,19 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + + + NSPrivacyTracking + + + diff --git a/ios/BTFuse/BTFuseTests/BTFuseAPITests.m b/ios/BTFuse/BTFuseTests/BTFuseAPITests.m new file mode 100644 index 0000000..b9590c6 --- /dev/null +++ b/ios/BTFuse/BTFuseTests/BTFuseAPITests.m @@ -0,0 +1,118 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#import + +@interface BTFuseAPITests : XCTestCase { + BTFuseTestViewController* $viewController; + BTFuseTestAPIClientBuilder* $apiBuilder; + BTFuseTestSetupCompletionHandler $onSetupComplete; +} + +@end + +@implementation BTFuseAPITests + +- (void) onContextReady:(BTFuseContext*) context { + $apiBuilder = [[BTFuseTestAPIClientBuilder alloc] init]; + + [context registerPlugin: [[EchoPlugin alloc] init: context]]; + + $apiBuilder.apiPort = @([context getAPIPort]); + $apiBuilder.apiSecret = [context getAPISecret]; + $apiBuilder.pluginID = @"echo"; + $apiBuilder.contentType = @"text/plain"; +} + +- (void) onBeforeWebviewLoad {} + +- (void) onReady { + $onSetupComplete(NULL); +} + +- (void) setUpWithCompletionHandler:(BTFuseTestSetupCompletionHandler) completion { + $viewController = [[BTFuseTestViewController alloc] init: self]; + [$viewController loadViewIfNeeded]; + $onSetupComplete = completion; +} + +- (void) tearDown { + $viewController = nil; +} + +- (void) testSimpleEchoRequest { + $apiBuilder.endpoint = @"/echo"; + $apiBuilder.data = [@"Hello Test!" dataUsingEncoding:NSUTF8StringEncoding]; + BTFuseTestAPIClient* client = [$apiBuilder build]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"testSimpleEchoRequest"]; + + [client execute:^(NSError * _Nullable error, BTFuseTestAPIClientResponse * _Nullable response) { + XCTAssertNil(error, @"Error should be nil"); + + NSString* payload = [[NSString alloc] initWithData:response.data encoding:NSUTF8StringEncoding]; + XCTAssertTrue([payload isEqualToString:@"Hello Test!"], @"Payload should echo input"); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:30.0 handler:nil]; +} + +- (void) testThreadedRequest { + $apiBuilder.endpoint = @"/threadtest"; + $apiBuilder.data = [@"Hello Test!" dataUsingEncoding:NSUTF8StringEncoding]; + BTFuseTestAPIClient* client = [$apiBuilder build]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"testThreadedRequest"]; + + [client execute:^(NSError * _Nullable error, BTFuseTestAPIClientResponse * _Nullable response) { + XCTAssertNil(error, @"Error should be nil"); + + NSString* payload = [[NSString alloc] initWithData:response.data encoding:NSUTF8StringEncoding]; + XCTAssertTrue([payload isEqualToString:@"Hello Test!"], @"Payload should echo input"); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:30.0 handler:nil]; +} + +- (void) testStreamReader { + $apiBuilder.endpoint = @"/echoWithReader"; + $apiBuilder.data = [@"Hello Test!" dataUsingEncoding:NSUTF8StringEncoding]; + BTFuseTestAPIClient* client = [$apiBuilder build]; + + XCTestExpectation* expectation = [self expectationWithDescription:@"testSimpleEchoRequest"]; + + [client execute:^(NSError * _Nullable error, BTFuseTestAPIClientResponse * _Nullable response) { + XCTAssertNil(error, @"Error should be nil"); + + NSString* payload = [[NSString alloc] initWithData:response.data encoding:NSUTF8StringEncoding]; + XCTAssertTrue([payload isEqualToString:@"Hello Test!"], @"Payload should echo input"); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:30.0 handler:nil]; +} + +@end diff --git a/ios/BTFuse/BTFuseTests/BTFuseJSONSerializerTests.m b/ios/BTFuse/BTFuseTests/BTFuseJSONSerializerTests.m new file mode 100644 index 0000000..1ef54c0 --- /dev/null +++ b/ios/BTFuse/BTFuseTests/BTFuseJSONSerializerTests.m @@ -0,0 +1,41 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import + +@interface BTFuseJSONSerializerTests : XCTestCase {} + +@end + +@implementation BTFuseJSONSerializerTests + +- (void) setUp {} + +- (void) tearDown {} + +- (void) testShouldNotHaveLinebreaks { + NSError* error = nil; + NSString* json = [BTFuseJSONSerializer serialize:@{ + @"test": @(123) + } withError:&error]; + + XCTAssertEqualObjects(json, @"{\"test\":123}"); +} + +@end diff --git a/ios/BTFuse/BTFuseTests/BTFuseTests.m b/ios/BTFuse/BTFuseTests/BTFuseTests.m new file mode 100644 index 0000000..50834ff --- /dev/null +++ b/ios/BTFuse/BTFuseTests/BTFuseTests.m @@ -0,0 +1,69 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import + +@interface BTFuseTests : XCTestCase { + BTFuseTestViewController* $viewController; + BTFuseTestSetupCompletionHandler $onSetupComplete; +} + +@end + +@implementation BTFuseTests + +- (void) onContextReady:(BTFuseContext*) context {} +- (void) onBeforeWebviewLoad {} +- (void) onReady { + $onSetupComplete(NULL); +} + +- (void) setUpWithCompletionHandler:(BTFuseTestSetupCompletionHandler) completion { + $onSetupComplete = completion; + $viewController = [[BTFuseTestViewController alloc] init: self]; + [$viewController loadViewIfNeeded]; +} + +- (void) tearDown { + $viewController = nil; +} + +- (void) testShouldHaveContext { + BTFuseContext* context = [$viewController getContext]; + XCTAssertNotNil(context, @"BTFuseContext should not be nil"); +} + +- (void) testShouldHaveWebview { + WKWebView* webview = [$viewController getWebview]; + XCTAssertNotNil(webview, @"WKWebView should not be nil"); +} + +- (void) testShouldHaveAPIPort { + BTFuseContext* context = [$viewController getContext]; + int port = [context getAPIPort]; + XCTAssertTrue(port > 1024 && port < 65535, @"Fuse API Port should be > 1024 and < 65535"); +} + +- (void) testShouldHaveAPISecret { + BTFuseContext* context = [$viewController getContext]; + NSString* secret = [context getAPISecret]; + XCTAssertNotNil(secret, @"API Fuse Secret should not be nil"); +} + +@end diff --git a/ios/BTFuse/PrivacyInfo.xcprivacy b/ios/BTFuse/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..cfbe279 --- /dev/null +++ b/ios/BTFuse/PrivacyInfo.xcprivacy @@ -0,0 +1,8 @@ + + + + + NSPrivacyTracking + + + diff --git a/ios/BTFuse/configs/BTFuse.debug.xcconfig b/ios/BTFuse/configs/BTFuse.debug.xcconfig new file mode 100644 index 0000000..2c5d8bf --- /dev/null +++ b/ios/BTFuse/configs/BTFuse.debug.xcconfig @@ -0,0 +1,17 @@ + +// Copyright 2023-2024 Breautek +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../Pods/Target Support Files/Pods-BTFuse/Pods-BTFuse.debug.xcconfig" +#include "version.xcconfig" diff --git a/ios/BTFuse/configs/BTFuse.release.xcconfig b/ios/BTFuse/configs/BTFuse.release.xcconfig new file mode 100644 index 0000000..c5be4fc --- /dev/null +++ b/ios/BTFuse/configs/BTFuse.release.xcconfig @@ -0,0 +1,17 @@ + +// Copyright 2023-2024 Breautek +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "../Pods/Target Support Files/Pods-BTFuse/Pods-BTFuse.release.xcconfig" +#include "version.xcconfig" diff --git a/ios/BTFuse/configs/version.xcconfig b/ios/BTFuse/configs/version.xcconfig new file mode 100644 index 0000000..fb9d5fe --- /dev/null +++ b/ios/BTFuse/configs/version.xcconfig @@ -0,0 +1,3 @@ +// This is an auto-generated file, do not edit! +CURRENT_PROJECT_VERSION = 0.8.12 +MARKETING_VERSION = 0.8.12 diff --git a/ios/BTFuse/en.lproj/Localizable.strings b/ios/BTFuse/en.lproj/Localizable.strings new file mode 100644 index 0000000..dc2a5d7 --- /dev/null +++ b/ios/BTFuse/en.lproj/Localizable.strings @@ -0,0 +1,19 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +"FUSE_DIALOG_OK_BUTTON_LABEL" = "OK"; +"FUSE_DIALOG_CANCEL_BUTTON_LABEL" = "Cancel"; diff --git a/ios/BTFuse/src/BTFuseAPIClient.m b/ios/BTFuse/src/BTFuseAPIClient.m new file mode 100644 index 0000000..b5fca54 --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIClient.m @@ -0,0 +1,241 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import "BTFuseAPIClientInputStream.h" +#import "BTFuseAPIClientOutputStream.h" +#import "BTFuseAPIServerHeaders.h" +#import +#import "BTFuseNWErrorFactory.h" + +@implementation BTFuseAPIClient { + NSString* $ident; + nw_connection_t $connection; + BTFuseAPIClientInputStream* $input; + BTFuseAPIClientOutputStream* $output; + BTFuseAPIServerHeaders* $headers; + nw_connection_state_t $connState; + dispatch_queue_t $clientQueue; + dispatch_semaphore_t $isReady; +} + +- (instancetype) init:(nw_connection_t) connection { + self = [super init]; + + $isReady = dispatch_semaphore_create(0); + + BTFuseIDGenerator* idgen = [[BTFuseIDGenerator alloc] init]; + $ident = [idgen generate]; + + $clientQueue = dispatch_queue_create("com.breautek.fuse.BTFuseAPIClient_ClientQueue", DISPATCH_QUEUE_SERIAL); + + $connection = connection; + + nw_connection_set_state_changed_handler(connection, ^(nw_connection_state_t state, nw_error_t _Nullable nwError) { + if (nwError != nil) { + NSError* error = [BTFuseNWErrorFactory create: nwError]; + + NSLog(@"Error in State Change"); + NSLog(@"Error: %@", [error localizedDescription]); + + [self close]; + return; + } + + self->$connState = state; + + if (state == nw_connection_state_ready) { + dispatch_semaphore_signal(self->$isReady); + } + }); + + nw_connection_start(connection); + + $input = [[BTFuseAPIClientInputStream alloc] init: $connection]; + $output = [[BTFuseAPIClientOutputStream alloc] init: $connection]; + + return self; +} + +- (NSString*) getID { + return $ident; +} + +- (NSInteger) write:(NSData*) buffer { + return [$output write: [buffer bytes] maxLength: [buffer length]]; +} + +- (void) start:(void (^)(NSError* error)) completionBlock { + dispatch_async($clientQueue, ^{ + dispatch_semaphore_wait(self->$isReady, DISPATCH_TIME_FOREVER); + + self->$headers = [self $parseHeaders]; + + NSError* error = nil; + + if (self->$headers == nil) { + error = [ + [NSError alloc] + initWithDomain: @"BTFuseAPIClient" + code: 0 + userInfo: @{ + NSLocalizedDescriptionKey: @"Unable to parse HTTP headers" + } + ]; + } + + completionBlock(error); + }); +} + +- (NSInputStream*) getInputStream { + return $input; +} + +- (NSOutputStream*) getOutputStream { + return $output; +} + +- (nw_connection_state_t) getConnectionState { + return $connState; +} + +- (NSString*) $readLine:(NSInputStream*) input { + NSMutableData* buffer = [[NSMutableData alloc] init]; + uint8_t p = '\0'; + uint8_t c = '\0'; + + while (true) { + NSInteger bytesRead = [input read: &c maxLength:1]; + + if (bytesRead <= 0) { + [self close]; + break; + } + + if (p == '\r' && c == '\n') { + break; + } + + if (c != '\r' && c != '\n') { + [buffer appendBytes: &c length: sizeof(c)]; + } + + p = c; + } + + if (buffer.length == 0) { + return nil; + } + else { + return [[NSString alloc] initWithData: buffer encoding: NSUTF8StringEncoding]; + } +} + +- (BTFuseAPIServerHeaders*) $parseHeaders { + BTFuseAPIServerHeaders* headers = [[BTFuseAPIServerHeaders alloc] init]; + + NSInputStream* input = $input; + + NSString* initialLine = [self $readLine: input]; + if (initialLine == nil) { + return nil; + } + + NSArray* initParts = [initialLine componentsSeparatedByString:@" "]; + if (initParts.count < 3) { + return nil; + } + + [headers setMethod: [initParts objectAtIndex: 0]]; + [headers setPath: [initParts objectAtIndex: 1]]; + [headers setVersion: [initParts objectAtIndex: 2]]; + + while (true) { + NSString* line = [self $readLine: input]; + + if (line == nil) { + break; + } + + NSArray* parts = [line componentsSeparatedByString:@":"]; + NSString* headerKey = [parts[0] stringByTrimmingCharactersInSet: NSCharacterSet.whitespaceAndNewlineCharacterSet]; + NSString* headerValue; + + if (parts.count > 2) { + // There was additional : in the value + headerValue = [line substringFromIndex:headerKey.length + 1]; + } + else { + headerValue = parts[1]; + } + + [headers setHeader:headerKey withValue:[headerValue stringByTrimmingCharactersInSet: NSCharacterSet.whitespaceAndNewlineCharacterSet]]; + } + + return headers; +} + +- (NSString*) getHTTPHeader:(NSString*) name { + return [$headers getHeader: name]; +} + +- (NSDictionary*) getHTTPHeaders { + return [$headers getHeaders]; +} + +- (NSString*) getHTTPMethod { + return [$headers getMethod]; +} + +- (NSString*) getHTTPVersion { + return [$headers getVersion]; +} + +- (NSString*) getHTTPPath { + return [$headers getPath]; +} + +- (void) close { + [$input close]; + [$output close]; // closing the output stream also closes the connection +} + +- (NSInteger) read:(NSMutableData*) buffer length:(uint32_t) length { + NSUInteger totalBytesRead = 0; + NSUInteger bytesRead = 0; + + [buffer setLength:length]; + + NSUInteger bytesRequired = length; + + while (totalBytesRead < length) { + uint8_t tempBuffer[bytesRequired]; + bytesRead = [$input read: tempBuffer maxLength: bytesRequired]; + if (bytesRead < 0) { + return totalBytesRead; + } + + [buffer replaceBytesInRange:NSMakeRange(totalBytesRead, bytesRead) withBytes:tempBuffer]; + totalBytesRead += bytesRead; + } + + return totalBytesRead; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIClientInputStream.m b/ios/BTFuse/src/BTFuseAPIClientInputStream.m new file mode 100644 index 0000000..8c4aa40 --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIClientInputStream.m @@ -0,0 +1,211 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import "BTFuseAPIClientInputStream.h" +#import "BTFuseNWErrorFactory.h" +#import "BTFuseAPIServer.h" + +@implementation BTFuseAPIClientInputStream { + __weak nw_connection_t $connection; + NSMutableData* $buffer; + bool $isCompleted; + dispatch_semaphore_t $readSemaphore; + bool _hasBytesAvailable; + NSStreamStatus _streamStatus; + NSError* _streamError; + dispatch_queue_t $readQueue; + id _delegate; +} + +@synthesize hasBytesAvailable; +@synthesize streamStatus; +@synthesize streamError; +@synthesize delegate; + +- (instancetype) init:(nw_connection_t) connection { + self = [super init]; + $buffer = [[NSMutableData alloc] initWithCapacity: BTFUSEAPISERVER_BUFFER_SIZE]; + + $readQueue = dispatch_queue_create("com.breautek.fuse.BTFuseAPIInputStream_ReadQueue", DISPATCH_QUEUE_SERIAL); + + self.streamStatus = NSStreamStatusNotOpen; + $connection = connection; + + $readSemaphore = dispatch_semaphore_create(0); + + self.streamStatus = NSStreamStatusOpening; + + dispatch_async($readQueue, ^{ + self.streamStatus = NSStreamStatusOpen; + [self $readData]; + }); + + return self; +} + +- (uint32_t) $getAvailable { + uint32_t availability = 0; + + NSUInteger length = [$buffer length]; + availability = BTFUSEAPISERVER_BUFFER_SIZE - (uint32_t)length; + + return availability; +} + +- (void) $readData { + nw_connection_receive($connection, 1, [self $getAvailable], ^(dispatch_data_t content, nw_content_context_t context, bool isComplete, nw_error_t error) { + + if (error != nil) { + self.streamStatus = NSStreamStatusError; + self.streamError = [ + [NSError alloc] + initWithDomain: @"BTFuseAPIServer" + code: 0 + userInfo: @{ + NSLocalizedDescriptionKey: @"Read Failure", + NSUnderlyingErrorKey: [self getNWError: error] + } + ]; + return; + } + + NSData* data = (NSData*)content; + + @synchronized (self->$buffer) { + if (isComplete) { + self->$isCompleted = true; + } + + if ([data length] > 0) { + [self setHasBytesAvailable:true]; + } + + [self->$buffer appendData: data]; + } + + dispatch_semaphore_signal(self->$readSemaphore); + + if (!isComplete) { + dispatch_async(self->$readQueue, ^{ + [self $readData]; + }); + } + }); +} + +- (NSError*) getNWError:(nw_error_t) nwError { + return [BTFuseNWErrorFactory create: nwError]; +} + +- (NSInteger) read:(uint8_t*) buffer maxLength:(NSUInteger) len { + streamStatus = NSStreamStatusReading; + + if (![self hasBytesAvailable]) { + dispatch_semaphore_wait($readSemaphore, DISPATCH_TIME_FOREVER); + } + + NSUInteger bytesRead = len; + + @synchronized (self->$buffer) { + NSUInteger bufLength = [$buffer length]; + if (bytesRead > bufLength) { + bytesRead = bufLength; + } + + [$buffer getBytes: buffer length: bytesRead]; + + NSRange expiredRange = NSMakeRange(0, bytesRead); + [$buffer replaceBytesInRange: expiredRange withBytes: nil length: 0]; + + NSUInteger newLength = bufLength - bytesRead; + [$buffer setLength: newLength]; + + [self setHasBytesAvailable: newLength > 0]; + } + + streamStatus = NSStreamStatusOpen; + + + return bytesRead; +} + +- (BOOL) getBuffer:(uint8_t* _Nullable*) buffer length:(NSUInteger*) len { + return false; +} + +- (BOOL) hasBytesAvailable { + return _hasBytesAvailable; +} + +- (void) setHasBytesAvailable:(BOOL) hasBytesAvailable { + _hasBytesAvailable = hasBytesAvailable; + if (hasBytesAvailable && self.delegate != nil) { + [self.delegate stream: self handleEvent: NSStreamEventHasBytesAvailable]; + } +} + +- (void) setStreamStatus:(NSStreamStatus) status { + _streamStatus = status; + if (self.delegate != nil) { + switch (status) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusReading: + case NSStreamStatusWriting: + case NSStreamStatusClosed: + case NSStreamStatusError: + break; + case NSStreamStatusOpen: + [self.delegate stream: self handleEvent: NSStreamEventOpenCompleted]; + break; + case NSStreamStatusAtEnd: + [self.delegate stream: self handleEvent: NSStreamEventEndEncountered]; + break; + } + } +} + +- (NSStreamStatus) streamStatus { + return _streamStatus; +} + +- (void) setStreamError:(NSError*) streamError { + _streamError = streamError; + if (self.delegate != nil) { + [self.delegate stream: self handleEvent: NSStreamEventErrorOccurred]; + } +} + +- (void) setDelegate:(id) delegate { + _delegate = delegate; +} + +- (id) delegate { + return _delegate; +} + +- (NSError*) streamError { + return _streamError; +} + +- (void) close { + self->streamStatus = NSStreamStatusClosed; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIClientOutputStream.m b/ios/BTFuse/src/BTFuseAPIClientOutputStream.m new file mode 100644 index 0000000..636028a --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIClientOutputStream.m @@ -0,0 +1,109 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import "BTFuseAPIClientOutputStream.h" +#import "BTFuseNWErrorFactory.h" + +@implementation BTFuseAPIClientOutputStream { + __weak nw_connection_t $connection; + bool _hasSpaceAvailable; + NSError* _streamError; + NSStreamStatus _streamStatus; +} + +@synthesize hasSpaceAvailable; +@synthesize streamStatus; +@synthesize streamError; + +- (instancetype _Nonnull) init:(nw_connection_t _Nonnull) connection { + self = [super init]; + + $connection = connection; + + return self; +} + +- (void) setHasSpaceAvailable:(BOOL) hasSpaceAvailable { + _hasSpaceAvailable = hasSpaceAvailable; +} + +- (bool) hasSpaceAvailable { + return _hasSpaceAvailable; +} + +- (NSInteger) write:(const uint8_t*) buffer maxLength:(NSUInteger) len { + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + + __block NSInteger bytesWritten = -1; + + dispatch_data_t dispatchedData = dispatch_data_create(buffer, len, dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), DISPATCH_DATA_DESTRUCTOR_DEFAULT); + + nw_connection_send($connection, dispatchedData, NW_CONNECTION_DEFAULT_MESSAGE_CONTEXT, false, ^(nw_error_t error) { + + if (error != nil) { + self.streamStatus = NSStreamStatusError; + self.streamError = [ + [NSError alloc] + initWithDomain: @"BTFuseAPIServer" + code: 0 + userInfo: @{ + NSLocalizedDescriptionKey: @"Write Failure", + NSUnderlyingErrorKey: [self getNWError: error] + } + ]; + dispatch_semaphore_signal(semaphore); + return; + } + + bytesWritten = len; + + dispatch_semaphore_signal(semaphore); + }); + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return bytesWritten; +} + +- (void) setStreamError:(NSError*) streamError { + _streamError = streamError; +} + +- (NSError*) streamError { + return _streamError; +} + +- (NSError*) getNWError:(nw_error_t) nwError { + return [BTFuseNWErrorFactory create: nwError]; +} + +- (void) setStreamStatus:(NSStreamStatus) status { + _streamStatus = status; +} + +- (NSStreamStatus) streamStatus { + return _streamStatus; +} + +- (void) close { + [self setStreamStatus: NSStreamStatusClosed]; + nw_connection_cancel($connection); +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIPacket.m b/ios/BTFuse/src/BTFuseAPIPacket.m new file mode 100644 index 0000000..2b178d6 --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIPacket.m @@ -0,0 +1,123 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import + +const uint32_t BTFUSE_API_PACKET_BUFFER_SIZE = 1024 * 1024 * 4; + +@implementation BTFuseAPIPacket { + NSString* $route; + BTFuseAPIClient* $client; + NSDictionary* $headers; + BTFuseContext* $context; + BTFuseStreamReader* $reader; +} + +- (instancetype) init:(BTFuseContext*) context route:(NSString*) route headers:(NSDictionary*) headers client:(BTFuseAPIClient*) client { + self = [super init]; + + $context = context; + $route = route; + $headers = headers; + $client = client; + $reader = [[BTFuseStreamReader alloc] init: [$client getInputStream]]; + + return self; +} + +- (NSString*) getRoute { + return $route; +} + +- (BTFuseAPIClient*) getClient { + return $client; +} + +- (uint64_t) getContentLength { + NSString* value = [$headers valueForKey: @"Content-Length"]; + return value.longLongValue; +} + +- (NSString*) getContentType { + return [$headers valueForKey: @"Content-Type"]; +} + +- (NSString*) readAsString { + NSData* data = [self readAsBinary]; + return [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; +} + +- (NSData*) readAsBinary { + uint64_t contentLength = [self getContentLength]; + uint64_t totalBytesRead = 0; + + NSMutableData* data = [[NSMutableData alloc] init]; + + uint32_t chunkSize = BTFUSE_API_PACKET_BUFFER_SIZE; + if (chunkSize > contentLength) { + chunkSize = (uint32_t) contentLength; + } + + uint8_t buffer[chunkSize]; + int64_t bytesRead = 0; + + while (true) { + uint64_t totalBytesToRead = contentLength - totalBytesRead; + if (totalBytesToRead == 0) { + break; + } + + uint32_t bytesToRead = 0; + if (totalBytesToRead > UINT32_MAX) { + bytesToRead = UINT32_MAX; + } + else { + bytesToRead = (uint32_t) totalBytesToRead; + } + + if (bytesToRead > chunkSize) { + bytesToRead = chunkSize; + } + + bytesRead = [$reader read: buffer maxBytes: bytesToRead]; + + if (bytesRead == -1) { + NSLog(@"Socket Read Error"); + return nil; + } + + totalBytesRead += bytesRead; + [data appendBytes: buffer length: bytesRead]; + } + + return data; +} + +- (NSDictionary*) readAsJSONObject:(NSError**) error { + NSData* data = [self readAsBinary]; + return [NSJSONSerialization JSONObjectWithData: data options:NSJSONReadingMutableContainers error: error]; +} + +- (NSArray*) readAsJSONArray:(NSError**) error { + NSData* data = [self readAsBinary]; + return [NSJSONSerialization JSONObjectWithData: data options:NSJSONReadingMutableContainers error: error]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIResponse.m b/ios/BTFuse/src/BTFuseAPIResponse.m new file mode 100644 index 0000000..d37ac76 --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIResponse.m @@ -0,0 +1,303 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#include + +typedef void (^BTFuseAPIResponse_TaskBlock)(void); + +@implementation BTFuseAPIResponse { + dispatch_queue_t $workerQueue; + BTFuseAPIClient* $client; + bool $hasSentHeaders; + bool $isClosed; + BTFuseContext* $context; + NSUInteger $status; + NSUInteger $contentLength; + NSString* $contentType; + dispatch_queue_t $networkQueue; + uint64_t $startTime; +} + +- (instancetype) init:(BTFuseContext*) context client:(BTFuseAPIClient*) client { + self = [super init]; + + $startTime = mach_absolute_time(); + $workerQueue = dispatch_queue_create("BTFuseAPIResponse_WorkerQueue", DISPATCH_QUEUE_SERIAL); + $context = context; + + $client = client; + $isClosed = false; + $hasSentHeaders = false; + $status = BTFuseAPIResponseStatusOk; + $contentLength = 0; + $contentType = @"application/octet-stream"; + + return self; +} + +- (void) __addNetworkingTask:(BTFuseAPIResponse_TaskBlock) task { + dispatch_async($workerQueue, ^{ + task(); + }); +} + +- (void) $kill:(NSString*) message { + if ($isClosed) { + return; + } + + $status = 0; + + BTFuseLogger* logger = [$context getLogger]; + [logger error: @"Killing %@ for reason: %@", [$client getID], message]; + + $isClosed = true; + [$client close]; + [self $printEndTime]; +} + +- (void) $printEndTime { + BTFuseLogger* logger = [$context getLogger]; + + uint64_t elapsed = mach_absolute_time() - $startTime; + mach_timebase_info_data_t timebase; + kern_return_t kernResult = mach_timebase_info(&timebase); + + if (kernResult != KERN_SUCCESS) { + [logger info:@"Response (Request %@ with status %lu. Time information not available.", [$client getID], $status]; + return; + } + + double UNIT = 1e-9 * (double)timebase.numer / (double)timebase.denom; + double elapsedSeconds = (double)elapsed * UNIT; + + [logger info:@"Response (Request %@) closed with status %lu in %fs", [$client getID], $status, elapsedSeconds]; +} + +- (ssize_t) $write:(const void*) data length:(size_t) length { + NSData* nsdata = [[NSData alloc] initWithBytes: data length: length]; + return [$client write: nsdata]; +} + +- (void) write:(const void*) sourceData length:(size_t) length { + void* data = malloc(length); + memcpy(data, sourceData, length); + [self __addNetworkingTask:^{ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Warc-retain-cycles" + /* + The block is stored temporary and removed when processed later, + thus retain cycles should be a non-issue here. + */ + if ([self isClosed]) { + return; + } + + ssize_t bytesWritten = [self $write:data length: length]; + free(data); + if (bytesWritten < 0) { + [self $kill:@"Network Socket Error"]; + } + #pragma clang diagnostic pop + }]; +} + +- (void) setStatus:(NSUInteger)status { + $status = status; +} + +- (void) setContentType:(NSString*)contentType { + $contentType = contentType; +} + +- (void) setContentLength:(NSUInteger)length { + $contentLength = length; +} + +- (bool) isClosed { + return $isClosed; +} + +- (void) didFinishHeaders { + $hasSentHeaders = true; + + NSMutableString* headers = [[NSMutableString alloc] initWithString:@"HTTP/1.1"]; + [headers appendString:[NSString stringWithFormat:@" %lu %@\r\n", $status, [self getStatusText:$status]]]; + [headers appendString:[NSString stringWithFormat:@"Access-Control-Allow-Origin: %@\r\n", @"btfuse://localhost"]]; + [headers appendString:[NSString stringWithFormat:@"Access-Control-Allow-Headers: %@\r\n", @"*"]]; + [headers appendString:[NSString stringWithFormat:@"Cache-Control: %@\r\n", @"no-cache"]]; + [headers appendString:[NSString stringWithFormat:@"Content-Type: %@\r\n", $contentType]]; + [headers appendString:[NSString stringWithFormat:@"Content-Length: %lu\r\n", $contentLength]]; + [headers appendString:@"\r\n"]; + + [self write: [headers UTF8String] length: [headers lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; +} + +- (void) kill:(NSString*) message { + [self __addNetworkingTask:^{ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Warc-retain-cycles" + /* + The block is stored temporary and removed when processed later, + thus retain cycles should be a non-issue here. + */ + if ([self isClosed]) { + return; + } + + [self $kill: message]; + #pragma clang diagnostic pop + }]; +} + +- (NSString*) getStatusText:(NSUInteger) status { + switch (status) { + case BTFuseAPIResponseStatusOk: + return @"OK"; + case BTFuseAPIResponseStatusError: + return @"Bad Request"; + case BTFuseAPIResponseStatusInternalError: + return @"Internal Error"; + default: + return @"Unknown"; + } +} + +- (void) pushData:(NSData*) data { + if (!$hasSentHeaders) { + [self kill:@"Cannot send data before headers are sent. Must call finishHeaders first!"]; + return; + } + + [self write: [data bytes] length:[data length]]; +} + +- (void) didFinish { + [self __addNetworkingTask:^{ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Warc-retain-cycles" + /* + The block is stored temporary and removed when processed later, + thus retain cycles should be a non-issue here. + */ + self->$isClosed = true; + [self->$client close]; + #pragma clang diagnostic pop + + [self $printEndTime]; + }]; +} + +- (void) didInternalError { + [self setStatus:BTFuseAPIResponseStatusInternalError]; + [self setContentType:@"text/plain"]; + NSString* msg = @"Internal Error. See native logs for more details"; + [self setContentLength:[msg length]]; + [self didFinishHeaders]; + [self pushData: [msg dataUsingEncoding:NSUTF8StringEncoding]]; + [self didFinish]; +} + +- (void) finishHeaders:(NSUInteger) status withContentType:(NSString*) contentType withContentLength:(NSUInteger) contentLength { + [self setStatus:status]; + [self setContentType:contentType]; + [self setContentLength:contentLength]; + [self didFinishHeaders]; +} + +- (void) sendData:(NSData*) data { + [self finishHeaders:BTFuseAPIResponseStatusOk withContentType:@"application/octet-stream" withContentLength: data.length]; + [self pushData: data]; + [self didFinish]; +} + +- (void) sendData:(NSData*) data withType:(NSString*) type { + [self finishHeaders:BTFuseAPIResponseStatusOk withContentType:type withContentLength: data.length]; + [self pushData: data]; + [self didFinish]; +} + +- (void) sendJSON:(NSDictionary*) data { + NSError* serializationError; + NSData* serialized = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:&serializationError]; + if (serializationError != nil) { + BTFuseLogger* logger = [$context getLogger]; + + [logger error:@"Error domain: %@", serializationError.domain]; + [logger error:@"Error code: %ld", (long)serializationError.code]; + [logger error:@"Error description: %@", serializationError.localizedDescription]; + + if (serializationError.localizedFailureReason) { + [logger error:@"Failure reason: %@", serializationError.localizedFailureReason]; + } + + if (serializationError.localizedRecoverySuggestion) { + [logger error:@"Recovery suggestion: %@", serializationError.localizedRecoverySuggestion]; + } + + [logger error:@"Error user info: %@", serializationError.userInfo]; + [self didInternalError]; + return; + } + [self finishHeaders:BTFuseAPIResponseStatusOk withContentType:@"application/json" withContentLength: serialized.length]; + [self pushData:serialized]; + [self didFinish]; +} + +- (void) sendString:(NSString*) data { + [self finishHeaders:BTFuseAPIResponseStatusOk withContentType:@"text/plain" withContentLength:[data length]]; + [self pushData: [data dataUsingEncoding:NSUTF8StringEncoding]]; + [self didFinish]; +} + +- (void) sendNoContent { + [self finishHeaders:BTFuseAPIResponseStatusOk withContentType:@"text/plain" withContentLength:0]; + [self didFinish]; +} + +- (void) sendError:(BTFuseError*) error { + NSError* serializationError = nil; + NSString* data = [error serialize:serializationError]; + if (serializationError != nil) { + BTFuseLogger* logger = [$context getLogger]; + [logger error:@"Error domain: %@", serializationError.domain]; + [logger error:@"Error code: %ld", (long)serializationError.code]; + [logger error:@"Error description: %@", serializationError.localizedDescription]; + + if (serializationError.localizedFailureReason) { + [logger error:@"Failure reason: %@", serializationError.localizedFailureReason]; + } + + if (serializationError.localizedRecoverySuggestion) { + [logger error:@"Recovery suggestion: %@", serializationError.localizedRecoverySuggestion]; + } + + [logger error:@"Error user info: %@", serializationError.userInfo]; + [self didInternalError]; + return; + } + + [self finishHeaders:BTFuseAPIResponseStatusError withContentType:@"application/json" withContentLength:[data length]]; + [self pushData: [data dataUsingEncoding:NSUTF8StringEncoding]]; + [self didFinish]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIResponseFactory.m b/ios/BTFuse/src/BTFuseAPIResponseFactory.m new file mode 100644 index 0000000..19be090 --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIResponseFactory.m @@ -0,0 +1,34 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import + +@implementation BTFuseAPIResponseFactory + +- (instancetype) init { + self = [super init]; + + return self; +} + +- (BTFuseAPIResponse*) create:(BTFuseContext*) context client:(BTFuseAPIClient*) client { + return [[BTFuseAPIResponse alloc] init:context client: client]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIRouter.m b/ios/BTFuse/src/BTFuseAPIRouter.m new file mode 100644 index 0000000..dec0610 --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIRouter.m @@ -0,0 +1,73 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#import + +@implementation BTFuseAPIRouter { + __weak BTFuseContext* $context; +} + +- (instancetype) init: (BTFuseContext*) context { + self = [super init]; + + $context = context; + + return self; +} + +- (BTFuseContext*) getContext { + return $context; +} + +- (void) execute:(BTFuseAPIPacket*) packet withResponse:(BTFuseAPIResponse*) response { + NSString* route = [packet getRoute]; + + NSArray* parts = [route componentsSeparatedByString: @"/"]; + + if ([parts count] < 3) { + [response setStatus:BTFuseAPIResponseStatusError]; + [response setContentType:@"application/json"]; + NSError* error = nil; + NSString* message = [[[BTFuseError alloc] init:@"BTFuseAPIRouter" withCode:1 withMessage:@"Malformed route"] serialize:error]; + NSData* msgData = [message dataUsingEncoding:NSUTF8StringEncoding]; + [response setContentLength: [msgData length]]; + [response didFinishHeaders]; + [response pushData:msgData]; + [response didFinish]; + return; + } + + NSString* pluginID = [parts objectAtIndex: 2]; + BTFusePlugin* plugin = [$context getPlugin: pluginID]; + if (plugin == nil) { + [response sendError:[[BTFuseError alloc] init:@"BTFuse" withCode:0 withMessage:[NSString stringWithFormat: @"Unknown Plugin: %@", pluginID]]]; + return; + } + + NSMutableArray* components = [parts mutableCopy]; + + [components removeObjectsInRange: NSMakeRange(0, 3)]; //Removes /, api, and the plugin ID from components, and leaves /methodName + NSString* servicePath = [@"/" stringByAppendingString:[components componentsJoinedByString:@"/"]]; + + [plugin route: servicePath withPacket: packet withResponse: response]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIServer.m b/ios/BTFuse/src/BTFuseAPIServer.m new file mode 100644 index 0000000..415e73d --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIServer.m @@ -0,0 +1,199 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#import "BTFuseAPIServer.h" +#import "BTFuseAPIResponse.h" +#import "BTFuseAPIPacket.h" +#import "BTFuseAPIRouter.h" +#import +#include +#include +#import +#import "BTFuseKeyFactory.h" +#import "BTFuseKeyPair.h" + +const uint32_t BTFUSEAPISERVER_BUFFER_SIZE = 1024 * 1024; //1mb + +@implementation BTFuseAPIServer { + BTFuseContext* $context; + int $sockFD; + int $port; + NSString* $secret; + nw_listener_t $networkListener; + struct sockaddr_in $serverAddress; + nw_parameters_t $networkParams; + nw_endpoint_t $networkEndpoint; + dispatch_queue_t $networkServerThread; + BTFuseKeyPair* $keypair; +} + + +NSString* $generateSecret(void) { + size_t secretLength = 32; // Length in bytes + uint8_t secretBytes[secretLength]; + + OSStatus status = SecRandomCopyBytes(kSecRandomDefault, secretLength, secretBytes); + if (status != errSecSuccess) { + // Handle the error, generating a secure random secret failed + return nil; + } + + NSMutableString *secretString = [NSMutableString stringWithCapacity:secretLength * 2]; + for (size_t i = 0; i < secretLength; i++) { + [secretString appendFormat:@"%02x", secretBytes[i]]; + } + + return [secretString copy]; +} + +- (instancetype) init:(BTFuseContext*) context { + self = [super init]; + + $context = context; + + BTFuseLogger* logger = [$context getLogger]; + + $secret = $generateSecret(); + if ($secret == nil) { + [logger error:@"BTFuseAPIServer: Secret Generation Failure"]; + return nil; + } + + BTFuseKeyFactory* keyFactory = [BTFuseKeyFactory getInstance]; + $keypair = [keyFactory create]; + + if ($keypair == nil) { + [logger error:@"BTFuseAPIServer: Key Generation Failure"]; + return nil; + } + + $networkServerThread = dispatch_queue_create("com.breautek.fuse.BTFuseAPIServer", DISPATCH_QUEUE_SERIAL); + + $networkParams = nw_parameters_create_secure_tcp( + // TLS + ^(nw_protocol_options_t options) { + sec_protocol_options_t secureOptions = nw_tls_copy_sec_protocol_options(options); + + BTFuseAPIServer* server = self; + + SecIdentityRef identityRef = [server->$keypair getIdentity]; + sec_identity_t identity = sec_identity_create(identityRef); + + sec_protocol_options_set_local_identity(secureOptions, identity); + sec_protocol_options_set_tls_server_name(secureOptions, "localhost"); + + sec_protocol_options_set_challenge_block(secureOptions, ^(sec_protocol_metadata_t metadata, sec_protocol_challenge_complete_t complete) { + NSLog(@"Received identity challenge"); + complete(identity); + }, server->$networkServerThread); + }, + NW_PARAMETERS_DEFAULT_CONFIGURATION //TCP + ); + + $serverAddress.sin_family = AF_INET; + $serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1"); + $serverAddress.sin_port = htons(0); + $serverAddress.sin_len = sizeof($serverAddress); + $networkEndpoint = nw_endpoint_create_address((const struct sockaddr*)&$serverAddress); + nw_parameters_set_local_endpoint($networkParams, $networkEndpoint); + + $networkListener = nw_listener_create($networkParams); + + nw_listener_set_queue($networkListener, $networkServerThread); + nw_listener_set_new_connection_limit($networkListener, NW_LISTENER_INFINITE_CONNECTION_LIMIT); + nw_listener_set_new_connection_handler($networkListener, ^(nw_connection_t connection) { + NSLog(@"Accepting new connection..."); + + dispatch_queue_t connQueue = dispatch_queue_create("com.breautek.fuse.BTFuseAPIServer_ConnQueue", DISPATCH_QUEUE_SERIAL); + nw_connection_set_queue(connection, connQueue); + + BTFuseAPIClient* client = [[BTFuseAPIClient alloc] init: connection]; + + [client start:^(NSError* error) { + if (error != nil) { + [client close]; + return; + } + + NSString* method = [client getHTTPMethod]; + BTFuseLogger* logger = [[self getContext] getLogger]; + [logger info: @"API Server Request (%@): (%@) %@", [client getID], method, [client getHTTPPath]]; + + BTFuseContext* context = [self getContext]; + + if ([method isEqualToString: @"OPTIONS"]) { + BTFuseAPIResponse* res = [[context getResponseFactory] create: context client: client]; + [res sendNoContent]; + return; + } + + NSString* givenSecret = [client getHTTPHeader:@"X-Fuse-Secret"]; + if (![[self getSecret] isEqualToString: givenSecret]) { + [client close]; + return; + } + + BTFuseAPIResponse* res = [[context getResponseFactory] create: context client: client]; + BTFuseAPIPacket* packet = [[BTFuseAPIPacket alloc] init: context route:[client getHTTPPath] headers: [client getHTTPHeaders] client:client]; + + [[context getAPIRouter] execute: packet withResponse: res]; + }]; + }); + + __block dispatch_semaphore_t onAPIServerReady = dispatch_semaphore_create(0); + + nw_listener_set_state_changed_handler($networkListener, ^(nw_listener_state_t state, nw_error_t error) { + if (state == nw_connection_state_failed) { + NSLog(@"Failed to open API server: %d", nw_error_get_error_code(error)); + return; + } + + self->$port = nw_listener_get_port(self->$networkListener); + dispatch_semaphore_signal(onAPIServerReady); + }); + + nw_listener_start($networkListener); + + dispatch_semaphore_wait(onAPIServerReady, DISPATCH_TIME_FOREVER); + + return self; +} + +- (int) getPort { + if ($port == 0) { + NSLog(@"Warning: API Server has not been initialized."); + } + return $port; +} + +- (NSString*) getSecret { + return $secret; +} + +- (BTFuseContext*) getContext { + return $context; +} + +- (BTFuseKeyPair*) getKeypair { + return $keypair; +} + +@end diff --git a/ios/BTFuse/src/BTFuseAPIServerHeaders.m b/ios/BTFuse/src/BTFuseAPIServerHeaders.m new file mode 100644 index 0000000..6bacefb --- /dev/null +++ b/ios/BTFuse/src/BTFuseAPIServerHeaders.m @@ -0,0 +1,71 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import "BTFuseAPIServerHeaders.h" + +@implementation BTFuseAPIServerHeaders + +- (instancetype) init { + self = [super init]; + + $headers = [[NSMutableDictionary alloc] init]; + $method = nil; + $version = nil; + $path = nil; + + return self; +} + +- (void) setMethod:(NSString*) method { + $method = method; +} + +- (void) setVersion:(NSString*) version { + $version = version; +} + +- (void) setPath:(NSString*) path { + $path = path; +} + +- (void) setHeader:(NSString*) name withValue:(NSString*) value { + [$headers setObject:value forKey:name]; +} + +- (NSString*) getMethod { + return $method; +} + +- (NSString*) getVersion { + return $version; +} + +- (NSString*) getPath { + return $path; +} + +- (NSString*) getHeader:(NSString*) name { + return [$headers objectForKey:name]; +} + +- (NSDictionary*) getHeaders { + return $headers; +} + +@end + diff --git a/ios/BTFuse/src/BTFuseContext.m b/ios/BTFuse/src/BTFuseContext.m new file mode 100644 index 0000000..5247001 --- /dev/null +++ b/ios/BTFuse/src/BTFuseContext.m @@ -0,0 +1,131 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import "BTFuseWebviewNavigationDelegate.h" + +/** + BTFuseContext is the main context file representing the runtime environment. + */ +@implementation BTFuseContext { + NSMutableDictionary* $pluginMap; + BTFuseAPIRouter* $apiRouter; + BTFuseAPIResponseFactory* $responseFactory; + BTFuseLogger* $logger; + BTFuseAPIServer* $apiServer; + id $contextDelegate; +} + +- (instancetype) init:(id) delegate { + self = [super init]; + + $contextDelegate = delegate; + $logger = [[BTFuseLogger alloc] init: self]; + + NSBundle* bundle = [NSBundle bundleForClass: [BTFuseContext class]]; + NSString* version = [bundle objectForInfoDictionaryKey: @"CFBundleShortVersionString"]; + NSString* build = [bundle objectForInfoDictionaryKey: @"CFBundleVersion"]; + [$logger info:@"Fuse %@ (%@)", version, build]; + + $apiServer = [[BTFuseAPIServer alloc] init: self]; + + $responseFactory = [[BTFuseAPIResponseFactory alloc] init]; + $apiRouter = [[BTFuseAPIRouter alloc] init: self]; + $pluginMap = [[NSMutableDictionary alloc] init]; + + [self registerPlugin:[[BTFuseRuntime alloc] init: self]]; + + return self; +} + +- (void) execCallback:(NSString*) callbackID withData:(NSString*) data { + [$contextDelegate dispatchToWebview: callbackID withData: data]; +} + +- (void) execCallback:(NSString*) callbackID { + [$contextDelegate dispatchToWebview: callbackID]; +} + +- (UIView*) getLayout { + return [$contextDelegate getLayout]; +} + +- (WKWebView*) getWebview { + return [$contextDelegate getWebview]; +} + +- (BTFuseAPIRouter*) getAPIRouter { + return $apiRouter; +} + +- (void) registerPlugin:(BTFusePlugin *)plugin { + if ([$pluginMap objectForKey:[plugin getID]] != nil) { + NSLog(@"A plugin is already registered for %@", [plugin getID]); + return; + } + + [$pluginMap setObject:plugin forKey:[plugin getID]]; +} + +- (BTFusePlugin*) getPlugin:(NSString*)pluginID { + return [$pluginMap objectForKey:pluginID]; +} + +- (nonnull BTFuseAPIResponseFactory*) getResponseFactory { + return $responseFactory; +} + +- (void) setResponseFactory:(nonnull BTFuseAPIResponseFactory*) factory { + $responseFactory = factory; +} + +- (int) getAPIPort { + return [$apiServer getPort]; +} + +- (NSString*) getAPISecret { + return [$apiServer getSecret]; +} + +- (nonnull NSString*) getAPIKeyIdentifier { + BTFuseKeyPair* kp = [$apiServer getKeypair]; + return [kp getIdentifier]; +} + +- (BTFuseLogger*) getLogger { + return $logger; +} + +- (nonnull id) createWebviewNavigationDelegate { + return [[BTFuseWebviewNavigationDelegate alloc] init: self keypair: [$apiServer getKeypair]]; +} + +- (nonnull NSString*) getHost { + return @"localhost"; +} + +@end diff --git a/ios/BTFuse/src/BTFuseError.m b/ios/BTFuse/src/BTFuseError.m new file mode 100644 index 0000000..91d5f10 --- /dev/null +++ b/ios/BTFuse/src/BTFuseError.m @@ -0,0 +1,65 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@implementation BTFuseError { + NSInteger $code; + NSString* $domain; + NSString* $message; +} + +- (instancetype)init:(NSString *)domain withCode:(NSInteger)code withMessage:(NSString *)message { + self = [super init]; + + $domain = domain; + $message = message; + $code = code; + + return self; +} + +- (instancetype)init:(NSString *)domain withCode:(NSInteger)code withError:(NSError *)error { + return [self init:domain withCode:code withMessage:[error localizedDescription]]; +} + +- (NSInteger)getCode { + return $code; +} + +- (NSString *)getDomain { + return $domain; +} + +- (NSString *)getMessage { + return $message; +} + +- (NSString *)serialize:(NSError*) error { + NSDictionary* obj = @{ + @"domain": $domain, + @"code": [[NSNumber alloc] initWithInteger: $code], + @"message": $message + }; + + NSString* serialized = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:obj options:0 error:&error] encoding: NSUTF8StringEncoding]; + + return serialized; +} + +@end diff --git a/ios/BTFuse/src/BTFuseIDGenerator.m b/ios/BTFuse/src/BTFuseIDGenerator.m new file mode 100644 index 0000000..cac603c --- /dev/null +++ b/ios/BTFuse/src/BTFuseIDGenerator.m @@ -0,0 +1,34 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@implementation BTFuseIDGenerator + +- (instancetype) init { + self = [super init]; + + return self; +} + +- (NSString*) generate { + NSUUID* uuid = [NSUUID UUID]; + return [uuid UUIDString]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseJSONSerializer.m b/ios/BTFuse/src/BTFuseJSONSerializer.m new file mode 100644 index 0000000..cc56b80 --- /dev/null +++ b/ios/BTFuse/src/BTFuseJSONSerializer.m @@ -0,0 +1,33 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +#import +#import + +@implementation BTFuseJSONSerializer + ++ (NSString*) serialize:(NSDictionary*) data withError:(NSError *__autoreleasing*) error { + NSData* serialized = [NSJSONSerialization dataWithJSONObject:data options:0 error:error]; + if (error == nil) { + return nil; + } + + return [[NSString alloc] initWithData:serialized encoding:NSUTF8StringEncoding]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseKeyFactory.m b/ios/BTFuse/src/BTFuseKeyFactory.m new file mode 100644 index 0000000..8f065b4 --- /dev/null +++ b/ios/BTFuse/src/BTFuseKeyFactory.m @@ -0,0 +1,94 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import "BTFuseKeyFactory.h" +#import "BTFuseKeyPair.h" +#import "BTFuseIDGenerator.h" +#include +#include +#include + +@implementation BTFuseKeyFactory + +- (instancetype) init { + self = [super init]; + + return self; +} + ++ (instancetype) getInstance { + static BTFuseKeyFactory* instance = nil; + static dispatch_once_t construct; + dispatch_once(&construct, ^{ + instance = [[self alloc] init]; + }); + return instance; +} + +- (BTFuseKeyPair*) create { + + EVP_PKEY* key = EVP_RSA_gen(2048); + + if (!key) { + NSLog(@"Error generating keypair"); + return nil; + } + + X509* x509 = X509_new(); + if (!x509) { + NSLog(@"Error generating certificate"); + EVP_PKEY_free(key); + return nil; + } + + ASN1_INTEGER_set(X509_get_serialNumber(x509), 1); + + // Make certificate valid for a year + X509_gmtime_adj(X509_get_notBefore(x509), 0); + X509_gmtime_adj(X509_get_notAfter(x509), 31536000L); + X509_set_pubkey(x509, key); + + BTFuseIDGenerator* idgen = [[BTFuseIDGenerator alloc] init]; + NSString* nsSignature = [idgen generate]; + + unsigned char* signature = (unsigned char*)strdup([nsSignature UTF8String]); + + X509_NAME* name = X509_get_subject_name(x509); + + X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char *)"localhost", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "OU", MBSTRING_ASC, (unsigned char *)"Fuse", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char *)"Breautek", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "L", MBSTRING_ASC, (unsigned char *)"Moncton", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "ST", MBSTRING_ASC, (unsigned char *)"NB", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char *)"Canada", -1, -1, 0); + X509_NAME_add_entry_by_txt(name, "UID", MBSTRING_ASC, signature, -1, -1, 0); + X509_set_issuer_name(x509, name); + + if (!X509_sign(x509, key, EVP_sha384())) { + NSLog(@"Unable to sign certificate"); + X509_free(x509); + EVP_PKEY_free(key); + return nil; + } + + // From this point on, BTFuseKeyPair will assume ownership of the key and x509 objects + + return [[BTFuseKeyPair alloc] init: key certificate: x509 identifier: nsSignature]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseKeyPair.m b/ios/BTFuse/src/BTFuseKeyPair.m new file mode 100644 index 0000000..b2e1117 --- /dev/null +++ b/ios/BTFuse/src/BTFuseKeyPair.m @@ -0,0 +1,199 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import "BTFuseKeyPair.h" +#include +#include +#include +#import "BTFuseIDGenerator.h" + +@implementation BTFuseKeyPair { + EVP_PKEY* $key; + X509* $certificate; + BIO* $privateKeyData; + SecIdentityRef $identity; + SecTrustRef $trust; + NSString* $identifier; +} + +- (instancetype) init:(EVP_PKEY*) key certificate:(X509*) certificate identifier:(NSString*) identifier { + self = [super init]; + + $key = key; + $certificate = certificate; + $identifier = identifier; + + $privateKeyData = BIO_new(BIO_s_mem()); + + if (!i2d_PrivateKey_bio($privateKeyData, $key)) { + NSLog(@"Unable to fetch private key data"); + BIO_free($privateKeyData); + X509_free($certificate); + EVP_PKEY_free($key); + return nil; + } + + BTFuseIDGenerator* idgen = [[BTFuseIDGenerator alloc] init]; + NSString* pw = [idgen generate]; + const char* cPw = [pw UTF8String]; + + PKCS12* p12 = PKCS12_create(cPw, "BTFuseAPIServerCertificates", $key, $certificate, NULL, NID_pbe_WithSHA1And3_Key_TripleDES_CBC, NID_pbe_WithSHA1And3_Key_TripleDES_CBC, 0, 0, 0); + if (p12 == NULL) { + NSLog(@"Unable to generate a P12 identity"); + return nil; + } + + const EVP_MD* macAlgorithm = EVP_sha1(); + PKCS12_set_mac(p12, cPw, (int)strlen(cPw), NULL, 0, 2048, macAlgorithm); + + unsigned char* rawData = NULL; + int size = i2d_PKCS12(p12, &rawData); + + if (size < 0) { + PKCS12_free(p12); + NSLog(@"Unable to encode P12 identity"); + return nil; + } + + // Copy OpenSSL data into Objective-C dataland + NSMutableData* data = [[NSMutableData alloc] init]; + [data setLength: size]; + void* buffer = [data mutableBytes]; + memcpy(buffer, rawData, size); + free(rawData); + PKCS12_free(p12); + + CFDataRef dataRef = (__bridge CFDataRef) data; + +// SecCertificateRef certRef = NULL; + CFArrayRef items = NULL; + + OSStatus importStatus = SecPKCS12Import( + dataRef, + (__bridge CFDictionaryRef) @{ + (__bridge id)kSecImportExportPassphrase: pw + }, + &items + ); + + if (importStatus != errSecSuccess) { + NSLog(@"Failed to bridge PKCS12 with error: %d", (int)importStatus); + return nil; + } + + if (CFArrayGetCount(items) == 0) { + NSLog(@"PKCS12 Import Failure, no objects found."); + CFRelease(items); + return nil; + } + + CFDictionaryRef importItem = CFArrayGetValueAtIndex(items, 0); + + $identity = (SecIdentityRef) CFDictionaryGetValue(importItem, kSecImportItemIdentity); + $trust = (SecTrustRef) CFDictionaryGetValue(importItem, kSecImportItemTrust); + + return self; +} + + +- (void) dealloc {} + +- (SecKeyRef) getPrivate { + char* rawData; + NSMutableData* data = [[NSMutableData alloc] init]; + + long dataLength = BIO_get_mem_data($privateKeyData, &rawData); + + if (dataLength < 0) { + return nil; + } + + [data setLength: dataLength]; + void* buffer = [data mutableBytes]; + memcpy(buffer, rawData, dataLength); + + return SecKeyCreateWithData( + (__bridge CFDataRef)data, + (__bridge CFDictionaryRef)@{ + (__bridge id)kSecAttrIsExtractable: @YES + }, + NULL + ); +} + +- (SecKeyRef) getPublic { + unsigned char* rawData = NULL; + int size = i2d_PublicKey($key, &rawData); + + if (size < 0) { + return nil; + } + + NSMutableData* data = [[NSMutableData alloc] init]; + [data setLength: size]; + void* buffer = [data mutableBytes]; + memcpy(buffer, rawData, size); + free(rawData); + + return SecKeyCreateWithData( + (__bridge CFDataRef)data, + (__bridge CFDictionaryRef)@{ + (__bridge id)kSecAttrIsExtractable: @YES + }, + NULL + ); +} + +- (SecCertificateRef) getCertificate { + unsigned char* rawData = NULL; + int size = i2d_X509($certificate, &rawData); + + if (size < 0) { + return nil; + } + + NSMutableData* data = [[NSMutableData alloc] init]; + [data setLength: size]; + void* buffer = [data mutableBytes]; + memcpy(buffer, rawData, size); + free(rawData); + + return SecCertificateCreateWithData( + kCFAllocatorDefault, + (__bridge CFDataRef)data + ); +} + +- (SecIdentityRef) getIdentity { + return $identity; +} + +- (SecTrustRef) getTrust { + return $trust; +} + +- (NSString*) getIdentifier { + return $identifier; +} + +- (X509*) getX509 { + return $certificate; +} + +@end diff --git a/ios/BTFuse/src/BTFuseLocalization.m b/ios/BTFuse/src/BTFuseLocalization.m new file mode 100644 index 0000000..2603757 --- /dev/null +++ b/ios/BTFuse/src/BTFuseLocalization.m @@ -0,0 +1,38 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@implementation BTFuseLocalization : NSObject + ++ (NSString*) lookup: (NSString*) key { + NSBundle* mainBundle = [NSBundle mainBundle]; + NSBundle* bundle = [NSBundle bundleForClass: [BTFuseLocalization class]]; + + NSString* str = NSLocalizedStringWithDefaultValue(key, nil, mainBundle, nil, nil); + + if (str == nil) { + // If we can't resolve the key, then default the text to the key. Make the error obvious in the UI so that it can + // be corrected. + str = NSLocalizedStringWithDefaultValue(key, nil, bundle, key, nil); + } + + return str; +} + +@end diff --git a/ios/BTFuse/src/BTFuseLogger.m b/ios/BTFuse/src/BTFuseLogger.m new file mode 100644 index 0000000..8f7a881 --- /dev/null +++ b/ios/BTFuse/src/BTFuseLogger.m @@ -0,0 +1,132 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import + +#import +#import + +@implementation BTFuseLogger { + BTFuseLoggerLevel $level; + BTFuseContext* $context; + NSString* $callbackID; +} + +- (instancetype) init:(BTFuseContext*) context { + self = [super init]; + + $context = context; + $level = BTFuseLoggerLevelInfo | BTFuseLoggerLevelWarn | BTFuseLoggerLevelError; + + #ifdef DEBUG + $level |= BTFuseLoggerLevelDebug; + #endif + + return self; +} + +- (void) setLevel:(BTFuseLoggerLevel) level { + $level = level; +} + +- (BTFuseLoggerLevel) getLevel { + return $level; +} + +- (void) setCallbackID:(NSString*) callbackID { + $callbackID = callbackID; +} + +- (void) $bridgeToWebview:(BTFuseLoggerLevel) level message:(NSString*) message { + if ($callbackID == nil) { + return; + } + + NSDictionary* packet = @{ + @"level": @(level), + @"message": message + }; + + NSError* error = nil; + NSData* serialized = [NSJSONSerialization dataWithJSONObject: packet options: 0 error: &error]; + + if (!serialized) { + NSLog(@"Packet Serialization Error: %@", error); + return; + } + + NSString* json = [[NSString alloc] initWithData: serialized encoding: NSUTF8StringEncoding]; + [$context execCallback: $callbackID withData:json]; +} + +- (void) debug:(NSString*) format, ... __attribute__((format(NSString, 1, 2))) { + if (!($level & BTFuseLoggerLevelDebug)) { + return; + } + + va_list args; + va_start(args, format); + NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; + va_end(args); + + NSLog(@"[%@]: %@", BTFuseLoggerLevel_toString(BTFuseLoggerLevelDebug), message); + [self $bridgeToWebview:BTFuseLoggerLevelDebug message: message]; +} + +- (void) info:(NSString*) format, ... __attribute__((format(NSString, 1, 2))) { + if (!($level & BTFuseLoggerLevelInfo)) { + return; + } + + va_list args; + va_start(args, format); + NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; + va_end(args); + + NSLog(@"[%@]: %@", BTFuseLoggerLevel_toString(BTFuseLoggerLevelInfo), message); + [self $bridgeToWebview:BTFuseLoggerLevelInfo message: message]; +} + +- (void) warn:(NSString*) format, ... __attribute__((format(NSString, 1, 2))) { + if (!($level & BTFuseLoggerLevelWarn)) { + return; + } + + va_list args; + va_start(args, format); + NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; + va_end(args); + + NSLog(@"[%@]: %@", BTFuseLoggerLevel_toString(BTFuseLoggerLevelWarn), message); + [self $bridgeToWebview:BTFuseLoggerLevelWarn message: message]; +} + +- (void) error:(NSString*) format, ... __attribute__((format(NSString, 1, 2))) { + if (!($level & BTFuseLoggerLevelError)) { + return; + } + + va_list args; + va_start(args, format); + NSString* message = [[NSString alloc] initWithFormat:format arguments:args]; + va_end(args); + + NSLog(@"[%@]: %@", BTFuseLoggerLevel_toString(BTFuseLoggerLevelError), message); + [self $bridgeToWebview:BTFuseLoggerLevelError message: message]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseLoggerLevel.m b/ios/BTFuse/src/BTFuseLoggerLevel.m new file mode 100644 index 0000000..329977b --- /dev/null +++ b/ios/BTFuse/src/BTFuseLoggerLevel.m @@ -0,0 +1,36 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +NSString* BTFuseLoggerLevel_toString(BTFuseLoggerLevel level) { + switch (level) { + case BTFuseLoggerLevelSilent: + return @"SILENT"; + case BTFuseLoggerLevelDebug: + return @"DEBUG"; + case BTFuseLoggerLevelInfo: + return @"INFO"; + case BTFuseLoggerLevelWarn: + return @"WARN"; + case BTFuseLoggerLevelError: + return @"ERROR"; + default: + return @"UNKNOWN"; + } +} diff --git a/ios/BTFuse/src/BTFuseNWErrorFactory.m b/ios/BTFuse/src/BTFuseNWErrorFactory.m new file mode 100644 index 0000000..853ba79 --- /dev/null +++ b/ios/BTFuse/src/BTFuseNWErrorFactory.m @@ -0,0 +1,58 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import "BTFuseNWErrorFactory.h" + +@implementation BTFuseNWErrorFactory + ++ (NSError*) create:(nw_error_t) nwError { + nw_error_domain_t nwDomainCode = nw_error_get_error_domain(nwError); + NSString* domain; + CFStringRef domainRef = nil; + switch (nwDomainCode) { + case nw_error_domain_invalid: + default: + domain = @"invalid"; + break; + case nw_error_domain_dns: + domainRef = kNWErrorDomainDNS; + break; + case nw_error_domain_tls: + domainRef = kNWErrorDomainTLS; + break; + case nw_error_domain_posix: + domainRef = kNWErrorDomainPOSIX; + break; + } + + if (domainRef != nil) { + CFIndex length = CFStringGetLength(domainRef); + char buffer[length + 1]; + CFStringGetCString(domainRef, buffer, sizeof(buffer), kCFStringEncodingUTF8); + domain = (__bridge_transfer NSString*)CFStringCreateWithCString(NULL, buffer, kCFStringEncodingUTF8); + } + + return [ + [NSError alloc] + initWithDomain: domain + code: nw_error_get_error_code(nwError) + userInfo: @{} + ]; +} + +@end diff --git a/ios/BTFuse/src/BTFusePlugin.m b/ios/BTFuse/src/BTFusePlugin.m new file mode 100644 index 0000000..d0e7b56 --- /dev/null +++ b/ios/BTFuse/src/BTFusePlugin.m @@ -0,0 +1,71 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import + +@implementation BTFusePlugin { + NSMutableDictionary* $handles; + __weak BTFuseContext* $context; +} + +- (instancetype)init:(BTFuseContext*)context { + self = [super init]; + + $context = context; + $handles = [[NSMutableDictionary alloc] init]; + [self initHandles]; + + return self; +} + +- (BTFuseContext*) getContext { + return $context; +} + +- (NSString*)getID { + NSAssert(NO, @"BTFusePlugin.getID is abstract and must be overwritten by the concrete class."); + return nil; +} + +- (void) route:(NSString*) path withPacket:(BTFuseAPIPacket*) packet withResponse:(BTFuseAPIResponse*) response { + BTFusePluginAPIHandle apiHandle = [$handles objectForKey: path]; + if (apiHandle == nil) { + [response setStatus:BTFuseAPIResponseStatusError]; + [response setContentType:@"application/json"]; + NSError* error = nil; + NSString* message = [[[BTFuseError alloc] init:@"BTFusePlugin" withCode:1 withMessage:@"No Handler"] serialize:error]; + NSData* msgData = [message dataUsingEncoding:NSUTF8StringEncoding]; + [response setContentLength: [msgData length]]; + [response didFinishHeaders]; + [response pushData:msgData]; + [response didFinish]; + return; + } + + apiHandle(packet, response); +} + +- (void) attachHandler:(NSString *)path callback:(BTFusePluginAPIHandle)callback { + [$handles setObject:callback forKey:path]; +} + +- (void) initHandles {} + +@end diff --git a/ios/BTFuse/src/BTFuseSchemeHandler.m b/ios/BTFuse/src/BTFuseSchemeHandler.m new file mode 100644 index 0000000..ed7cac0 --- /dev/null +++ b/ios/BTFuse/src/BTFuseSchemeHandler.m @@ -0,0 +1,130 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +NSString* const SCHEME = @"btfuse"; +NSString* const HOST = @"localhost"; + +@implementation BTFuseSchemeHandler { + __weak BTFuseContext* $context; +} + +- (instancetype) init:(BTFuseContext*) context { + self = [super init]; + + $context = context; + + return self; +} + +- (BTFuseContext*) getContext { + return $context; +} + +- (void)webView:(WKWebView*)webView startURLSchemeTask:(id)urlSchemeTask { + NSURLRequest* request = urlSchemeTask.request; + NSURL* requestURL = request.URL; + NSString* scheme = requestURL.scheme; + + if (![scheme isEqualToString: SCHEME]) { + [self sendErrorResponseWithStatusCode:404 toURLSchemeTask:urlSchemeTask]; + return; + } + + NSString* path = requestURL.path; + + if (![requestURL.host isEqualToString: HOST]) { + [self sendErrorResponseWithStatusCode:404 toURLSchemeTask:urlSchemeTask]; + return; + } + + BTFuseLogger* logger = [$context getLogger]; + + [logger info: @"Incoming DOM Request: %@", path]; + + NSURL* route = [NSURL fileURLWithPath: path]; + + NSString* routeService = route.pathComponents[1]; + + if ([routeService isEqualToString:@"assets"]) { + NSString* bundlePath = [[NSBundle mainBundle] resourcePath]; + NSString* assetPath = [bundlePath stringByAppendingPathComponent:path]; + NSData* content = [NSData dataWithContentsOfFile:assetPath]; + + NSString* fileExtension = [requestURL pathExtension]; + UTType* uti = [UTType typeWithFilenameExtension: fileExtension]; + + NSString* contentType = nil; + + if (uti == nil) { + [logger warn: @"Could not discover MIME type for extension \"%@\". The webview will likely fail.", fileExtension]; + contentType = @"application/octet-stream"; + } + else { + contentType = [uti preferredMIMEType]; + } + + if (content) { + NSURLResponse* response = [[NSURLResponse alloc] initWithURL:requestURL MIMEType: contentType expectedContentLength:content.length textEncodingName:@"utf-8"]; + [urlSchemeTask didReceiveResponse: response]; + [urlSchemeTask didReceiveData: content]; + [urlSchemeTask didFinish]; + } + else { + [self sendErrorResponseWithStatusCode:404 toURLSchemeTask:urlSchemeTask]; + } + } + else { + [logger error:@"Unknown Service Route: %@", routeService]; + NSHTTPURLResponse* response = [[NSHTTPURLResponse alloc] initWithURL:urlSchemeTask.request.URL statusCode: 404 HTTPVersion:@"HTTP/1.1" headerFields:nil]; + [urlSchemeTask didReceiveResponse:response]; + [urlSchemeTask didFinish]; + } +} + +- (void) webView:(nonnull WKWebView*) webView stopURLSchemeTask:(nonnull id) urlSchemeTask {} + +- (void) sendErrorResponseWithStatusCode:(NSInteger) statusCode toURLSchemeTask:(id )urlSchemeTask { + NSDictionary* statusCodeTexts = @{ + @(200): @"OK", + @(404): @"Not Found", + // Add more status codes and texts as needed + }; + + // Create a basic HTML response + NSString* statusText = statusCodeTexts[@(statusCode)]; + NSString* errorHTML = [NSString stringWithFormat:@"

%ld %@

", (long)statusCode, statusText]; + NSData* errorData = [errorHTML dataUsingEncoding:NSUTF8StringEncoding]; + NSHTTPURLResponse* response = [[NSHTTPURLResponse alloc] initWithURL:urlSchemeTask.request.URL statusCode:statusCode HTTPVersion:@"HTTP/1.1" headerFields:nil]; + + // Send the response + [urlSchemeTask didReceiveResponse:response]; + [urlSchemeTask didReceiveData:errorData]; + [urlSchemeTask didFinish]; +} + +@end diff --git a/ios/BTFuse/src/BTFuseStreamReader.m b/ios/BTFuse/src/BTFuseStreamReader.m new file mode 100644 index 0000000..9d70742 --- /dev/null +++ b/ios/BTFuse/src/BTFuseStreamReader.m @@ -0,0 +1,76 @@ + +/* +Copyright Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +const char* BTFUSE_FILESYSTEM_READER_QUEUE = "com.breautek.btfuse.Reader"; + +@implementation BTFuseStreamReader { + NSInputStream* $stream; + dispatch_semaphore_t $readSemaphore; + NSError* $error; +} + +- (instancetype) init:(NSInputStream*) stream { + self = [super init]; + + $stream = stream; + $stream.delegate = self; + $error = nil; + $readSemaphore = dispatch_semaphore_create(0); + + return self; +} + +- (void) stream:(NSStream*) stream handleEvent:(NSStreamEvent) event { + if (stream != $stream) { + return; + } + + switch (event) { + case NSStreamEventHasBytesAvailable: + case NSStreamEventEndEncountered: + dispatch_semaphore_signal($readSemaphore); + break; + case NSStreamEventErrorOccurred: + NSLog(@"Stream encountered an error: %@", [stream streamError].localizedDescription); + $error = [stream streamError]; + dispatch_semaphore_signal($readSemaphore); + break; + case NSStreamEventOpenCompleted: + default: break; + } +} + +- (int64_t) read:(uint8_t*) buffer maxBytes:(uint32_t) max { + if (!$stream.hasBytesAvailable && $stream.streamStatus != NSStreamEventEndEncountered) { + dispatch_semaphore_wait($readSemaphore, DISPATCH_TIME_FOREVER); + } + + if ($error != nil) { + return -1; + } + + return [$stream read: buffer maxLength: max]; +} + +- (void) dealloc { + $stream = nil; +} + +@end diff --git a/ios/BTFuse/src/BTFuseViewController.m b/ios/BTFuse/src/BTFuseViewController.m new file mode 100644 index 0000000..f999cf3 --- /dev/null +++ b/ios/BTFuse/src/BTFuseViewController.m @@ -0,0 +1,184 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#import +#import +#import "BTFuseWebviewNavigationDelegate.h" +#import "BTFuseAPIServer.h" +#import +#import + +@implementation BTFuseViewController { + BTFuseContext* $context; + WKWebView* $webview; + BTFuseWebviewUIDelegation* $webviewUIDelegation; + BTFuseWebviewNavigationDelegate* $webviewNavigationDelegation; + id $delegate; +} + +- (instancetype) init:(id) delegate { + self = [super init]; + + $delegate = delegate; + $webview = nil; + $context = nil; + $webviewUIDelegation = nil; + $webviewNavigationDelegation = nil; + + return self; +} + +- (void) dispatchToWebview:(NSString*) callbackID { + dispatch_async(dispatch_get_main_queue(), ^{ + NSString* js = [[NSString alloc] initWithFormat:@"window.__btfuse_doCallback(\"%@\");", callbackID]; + [self->$webview evaluateJavaScript:js completionHandler:nil]; + }); +} + +- (void) dispatchToWebview:(NSString*) callbackID withData:(NSString*) data { + dispatch_async(dispatch_get_main_queue(), ^{ + NSString* escapedData = [[data stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""] stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; + NSString* js = [[NSString alloc] initWithFormat:@"window.__btfuse_doCallback(\"%@\",\"%@\");", callbackID, escapedData]; + [self->$webview evaluateJavaScript:js completionHandler:nil]; + }); +} + +- (void) viewDidLoad { + [super viewDidLoad]; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + self->$context = [[BTFuseContext alloc] init: self]; + + [self->$delegate onContextReady]; + + dispatch_async(dispatch_get_main_queue(), ^ { + self->$webviewUIDelegation = [[BTFuseWebviewUIDelegation alloc] init]; + self->$webviewNavigationDelegation = [self->$context createWebviewNavigationDelegate]; + + WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init]; + [configuration.userContentController addScriptMessageHandlerWithReply: self contentWorld: WKContentWorld.pageWorld name:@"getAPIPort"]; + [configuration.userContentController addScriptMessageHandlerWithReply: self contentWorld: WKContentWorld.pageWorld name:@"getAPISecret"]; + [configuration.userContentController addScriptMessageHandler: self name:@"log"]; + [configuration.userContentController addScriptMessageHandler: self name:@"setLogCallback"]; + + NSString* fuseBuildTag = @"Release"; + #ifdef DEBUG + fuseBuildTag = @"Debug"; + #endif + // TODO: Pull Version information somehow + configuration.applicationNameForUserAgent = [NSString stringWithFormat:@"FuseRuntime (%@ %@ Build", @"0.0.0", fuseBuildTag]; + + //TODO: pass the configuration object to a overridable method to give a chance for application-level configuration + [configuration setURLSchemeHandler: [ + [BTFuseSchemeHandler alloc] init: self->$context] + forURLScheme: @"BTfuse" + ]; + + self->$webview = [[WKWebView alloc] initWithFrame: CGRectZero configuration: configuration]; + self->$webview.UIDelegate = self->$webviewUIDelegation; + self->$webview.navigationDelegate = self->$webviewNavigationDelegation; + + [self addChildViewController: self->$webviewUIDelegation]; + [self.view addSubview: self->$webviewUIDelegation.view]; + [self->$webviewUIDelegation didMoveToParentViewController: self]; + + // Calculate or determine the desired frame + CGRect webviewFrame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); + + // Set the frame for the WKWebView + self->$webview.frame = webviewFrame; + + [self->$delegate onWebviewReady]; + + // Add the WKWebView as a subview + [self.view addSubview: self->$webview]; + + [self->$delegate onBeforeWebviewLoad]; + NSURL* url = [NSURL URLWithString: [NSString stringWithFormat: @"btfuse://%@/assets/index.html", [self->$context getHost]]]; + NSURLRequest* request = [NSURLRequest requestWithURL:url]; + [self->$webview loadRequest:request]; + }); + }); +} + +- (void) attach:(UIViewController*) controller { + [controller addChildViewController: self]; + [controller.view addSubview: self.view]; + [self didMoveToParentViewController: controller]; +} + + +- (WKWebView*) getWebview { + return $webview; +} + +- (UIView*) getLayout { + return self.view; +} + +- (BTFuseContext*) getContext { + return $context; +} + +- (void) userContentController:(WKUserContentController*) userContentController didReceiveScriptMessage:(WKScriptMessage*) message { + if ([message.name isEqualToString:@"log"] /* && [message.body isKindOfClass:[NSString class]]*/) { + if ([message.body isKindOfClass:[NSArray class]]) { + NSArray* logArgs = message.body; + if ([logArgs count] < 2) { + NSLog(@"Received log from webview but with invalid arguments."); + } + + BTFuseLoggerLevel level = [[logArgs objectAtIndex: 0] unsignedIntValue]; + NSString* levelLabel = BTFuseLoggerLevel_toString(level); + NSString* content = [logArgs objectAtIndex: 1]; + + NSLog(@"[%@]: %@", levelLabel, content); + } + else { + NSLog(@"Received log from webview but with invalid arguments."); + } + } + else if ([message.name isEqualToString:@"setLogCallback"]) { + if ([message.body isKindOfClass:[NSString class]]) { + NSString* callbackID = message.body; + [[$context getLogger] setCallbackID: callbackID]; + } + } +} + +- (void) userContentController:(WKUserContentController*) userContentController + didReceiveScriptMessage:(WKScriptMessage*) message + replyHandler:(void (^)(id _Nullable, NSString* _Nullable)) replyHandler +{ + if ([message.name isEqualToString:@"getAPIPort" ]) { + int port = [$context getAPIPort]; + replyHandler([[NSNumber alloc] initWithInt:port], nil); + return; + } + else if ([message.name isEqualToString:@"getAPISecret"]) { + NSString* secret = [$context getAPISecret]; + replyHandler(secret, nil); + return; + } + + replyHandler(nil, @"Unhandled Script"); +} + +@end diff --git a/ios/BTFuse/src/BTFuseWebviewNavigationDelegate.m b/ios/BTFuse/src/BTFuseWebviewNavigationDelegate.m new file mode 100644 index 0000000..7356b24 --- /dev/null +++ b/ios/BTFuse/src/BTFuseWebviewNavigationDelegate.m @@ -0,0 +1,163 @@ + +/* +Copyright Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import +#include +#include + +@implementation BTFuseWebviewNavigationDelegate { + __weak BTFuseContext* $context; + BTFuseKeyPair* $keypair; +} + +- (instancetype) init:(BTFuseContext*) context keypair:(BTFuseKeyPair*) keypair { + self = [super init]; + + $context = context; + $keypair = keypair; + + return self; +} + +- (void) webView:(WKWebView*) webView + didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*) challenge + completionHandler: (void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential* _Nullable)) completionHandler +{ + if (![challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + NSURLProtectionSpace* protectionSpace = challenge.protectionSpace; + + // First we will do some basic checks, anything that isn't hitting our API server can be routed to the default handling. + + if (![protectionSpace.host isEqualToString: @"localhost" ]) { + // not our API server, do the default + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + if (![protectionSpace.protocol isEqualToString: @"https" ]) { + // not our API server, do the default + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + if (protectionSpace.port != [$context getAPIPort]) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; + CFArrayRef certificates = SecTrustCopyCertificateChain(serverTrust); + + if (CFArrayGetCount(certificates) == 0) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + SecCertificateRef certificate = (SecCertificateRef) CFArrayGetValueAtIndex(certificates, 0); + + // Apple lacks iOS APIs to read certificate information. APIs to pull OIDs from the certificate are, + // unfortunately only available in MacOS SDK. So we will export the certificate data and bridge it to OpenSSL instead. + CFDataRef certData = SecCertificateCopyData(certificate); + if (certData == NULL) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + CFIndex length = CFDataGetLength(certData); + const uint8_t* bytes = CFDataGetBytePtr(certData); + + BIO* bio = BIO_new_mem_buf(bytes, (int) length); + if (!bio) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + X509* x509 = d2i_X509_bio(bio, NULL); + if (!x509) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + X509_NAME* subject = X509_get_subject_name(x509); + int nameCount = X509_NAME_entry_count(subject); + + ASN1_OBJECT* uidFieldOid = OBJ_txt2obj("UID", 0); + + NSString* certUID = nil; + + for (int i = 0; i < nameCount; i++) { + X509_NAME_ENTRY* entry = X509_NAME_get_entry(subject, i); + ASN1_OBJECT* obj = X509_NAME_ENTRY_get_object(entry); + ASN1_STRING* data = X509_NAME_ENTRY_get_data(entry); + + if (OBJ_cmp(obj, uidFieldOid) == 0) { + const unsigned char* uidValue = ASN1_STRING_get0_data(data); + certUID = [[NSString alloc] initWithCString: (const char*) uidValue encoding:NSUTF8StringEncoding]; + break; + } + } + + if (certUID == nil) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + NSString* keyIdentifier = [self->$context getAPIKeyIdentifier]; + if (![keyIdentifier isEqualToString: certUID]) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + X509_STORE* x509Store = X509_STORE_new(); + if (!x509Store) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + X509_STORE_CTX* ctx = X509_STORE_CTX_new(); + if (!ctx) { + X509_STORE_free(x509Store); + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + X509_STORE_add_cert(x509Store, [self->$keypair getX509]); + X509_STORE_CTX_init(ctx, x509Store, x509, NULL); + + int verificationResult = X509_verify_cert(ctx); + + X509_STORE_CTX_free(ctx); + X509_STORE_free(x509Store); + + if (verificationResult <= 0) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + return; + } + + NSURLCredential* credential = [NSURLCredential credentialForTrust:serverTrust]; + completionHandler(NSURLSessionAuthChallengeUseCredential, credential); + }); +} + +@end diff --git a/ios/BTFuse/src/BTFuseWebviewUIDelegation.m b/ios/BTFuse/src/BTFuseWebviewUIDelegation.m new file mode 100644 index 0000000..1c78beb --- /dev/null +++ b/ios/BTFuse/src/BTFuseWebviewUIDelegation.m @@ -0,0 +1,140 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import +#import + +@implementation BTFuseWebviewUIDelegation + +- (void) webView:(WKWebView*) webView + runJavaScriptAlertPanelWithMessage:(NSString*) message + initiatedByFrame:(WKFrameInfo*) frame + completionHandler:(void (^)(void)) completionHandler +{ + + UIAlertController* alertController = [ UIAlertController + alertControllerWithTitle: nil + message: message + preferredStyle: UIAlertControllerStyleAlert + ]; + + [ + alertController + addAction: [ + UIAlertAction + actionWithTitle: [BTFuseLocalization lookup:@"FUSE_DIALOG_OK_BUTTON_LABEL"] + style: UIAlertActionStyleDefault + handler: ^(UIAlertAction * _Nonnull action) { + completionHandler(); + } + ] + ]; + + [self presentViewController: alertController animated: true completion: nil]; +} + +- (void) webView:(WKWebView*) webView + runJavaScriptConfirmPanelWithMessage:(NSString*) message + initiatedByFrame:(WKFrameInfo*) frame + completionHandler:(void (^)(BOOL)) completionHandler +{ + UIAlertController* alertController = [ + UIAlertController + alertControllerWithTitle: nil + message: message + preferredStyle: UIAlertControllerStyleAlert + ]; + + [ + alertController + addAction: [ + UIAlertAction + actionWithTitle: [BTFuseLocalization lookup:@"FUSE_DIALOG_CANCEL_BUTTON_LABEL"] + style: UIAlertActionStyleDefault + handler: ^(UIAlertAction* _Nonnull action) { + completionHandler(false); + } + ] + ]; + + [ + alertController + addAction: [ + UIAlertAction + actionWithTitle: [BTFuseLocalization lookup:@"FUSE_DIALOG_OK_BUTTON_LABEL"] + style: UIAlertActionStyleDefault + handler: ^(UIAlertAction* _Nonnull action) { + completionHandler(true); + } + ] + ]; + + [self presentViewController:alertController animated:YES completion:nil]; +} + +- (void) webView:(WKWebView*) webView + runJavaScriptTextInputPanelWithPrompt:(NSString*) prompt + defaultText:(NSString*) defaultText + initiatedByFrame:(WKFrameInfo*) frame + completionHandler:(void (^)(NSString* _Nullable)) completionHandler +{ + UIAlertController* alertController = [ + UIAlertController alertControllerWithTitle: nil + message: prompt + preferredStyle: UIAlertControllerStyleAlert + ]; + + [ + alertController + addTextFieldWithConfigurationHandler:^(UITextField* _Nonnull textField) { + textField.text = defaultText; + } + ]; + + [ + alertController + addAction: [ + UIAlertAction + actionWithTitle: [BTFuseLocalization lookup:@"FUSE_DIALOG_CANCEL_BUTTON_LABEL"] + style: UIAlertActionStyleDefault + handler: ^(UIAlertAction * _Nonnull action) { + completionHandler(nil); + } + ] + ]; + + [ + alertController + addAction: [ + UIAlertAction + actionWithTitle: [BTFuseLocalization lookup:@"FUSE_DIALOG_OK_BUTTON_LABEL"] + style: UIAlertActionStyleDefault + handler: ^(UIAlertAction * _Nonnull action) { + completionHandler(alertController.textFields.firstObject.text); + } + ] + ]; + + [self presentViewController: alertController animated: true completion: nil]; +} + +- (void) webViewDidClose:(WKWebView*) webView { + NSLog(@"Webview closed!"); +} + +@end diff --git a/ios/BTFuse/src/plugins/BTFuseRuntime.m b/ios/BTFuse/src/plugins/BTFuseRuntime.m new file mode 100644 index 0000000..bc6c9a6 --- /dev/null +++ b/ios/BTFuse/src/plugins/BTFuseRuntime.m @@ -0,0 +1,118 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import "BTFuseRuntime.h" +#import +#import +#import + +@implementation BTFuseRuntime + +- (NSString*) getID { + return @"FuseRuntime"; +} + +- (instancetype) init:(BTFuseContext*) context { + self = [super init:context]; + + self.$resumeHandlers = [[NSMutableArray alloc] init]; + self.$pauseHandlers = [[NSMutableArray alloc] init]; + + // Register for background and foreground notifications + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil]; + + return self; +} + +- (void) initHandles { + __weak BTFuseRuntime* weakSelf = self; + + [self attachHandler:@"/info" callback:^void(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + [response sendJSON:[weakSelf getInfo]]; + }]; + + [self attachHandler:@"/registerPauseHandler" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + [weakSelf.$pauseHandlers addObject:[packet readAsString]]; + [response sendNoContent]; + }]; + + [self attachHandler:@"/unregisterPauseHandler" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + NSString* targetValue = [packet readAsString]; + NSInteger indexToRemove = [weakSelf.$pauseHandlers indexOfObjectPassingTest: ^BOOL (NSString* obj, NSUInteger idx, BOOL* stop) { + return [obj isEqualToString: targetValue]; + }]; + + if (indexToRemove != NSNotFound) { + [weakSelf.$pauseHandlers removeObjectAtIndex:indexToRemove]; + } + + [response sendNoContent]; + }]; + + [self attachHandler:@"/registerResumeHandler" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + [weakSelf.$resumeHandlers addObject:[packet readAsString]]; + [response sendNoContent]; + }]; + + [self attachHandler:@"/unregisterResumeHandler" callback:^(BTFuseAPIPacket* packet, BTFuseAPIResponse* response) { + NSString* targetValue = [packet readAsString]; + NSInteger indexToRemove = [weakSelf.$resumeHandlers indexOfObjectPassingTest: ^BOOL (NSString* obj, NSUInteger idx, BOOL* stop) { + return [obj isEqualToString: targetValue]; + }]; + + if (indexToRemove != NSNotFound) { + [weakSelf.$resumeHandlers removeObjectAtIndex:indexToRemove]; + } + + [response sendNoContent]; + }]; +} + +- (NSDictionary*) getInfo { + UIDevice* device = [UIDevice currentDevice]; + + NSString* version = [device systemVersion]; + + bool debugMode = false; + #ifdef DEBUG + debugMode = true; + #endif + + return @{ + @"version": version, + @"debugMode": @(debugMode) + }; +} + +- (void) onPause { + @synchronized (self.$pauseHandlers) { + for (id callbackID in self.$pauseHandlers) { + [[self getContext] execCallback:callbackID]; + } + } +} + +- (void) onResume { + @synchronized (self.$resumeHandlers) { + for (id callbackID in self.$resumeHandlers) { + [[self getContext] execCallback:callbackID]; + } + } +} + +@end diff --git a/ios/BTFuseTestTools.podspec.template b/ios/BTFuseTestTools.podspec.template new file mode 100644 index 0000000..63bd046 --- /dev/null +++ b/ios/BTFuseTestTools.podspec.template @@ -0,0 +1,21 @@ + +Pod::Spec.new do |s| + s.name = 'BTFuseTestTools' + s.version = '$VERSION$' + s.summary = 'Fuse Framework Test Toolkit' + s.homepage = 'https://fuse.breautek.com' + s.author = { 'BTFuse' => 'norman@breautek.com' } + s.license = { + :type => 'Apache-2.0', + :file => 'BTFuseTestTools.xcframework/ios-arm64/BTFuseTestTools.framework/LICENSE' + } + + s.ios.deployment_target = '15.0' + + s.source = { + :http => 'https://github.com/btfuse/fuse-ios/releases/download/$VERSION$/BTFuseTestTools.xcframework.zip', + :sha1 => '$CHECKSUM$' + } + + s.vendored_frameworks = 'BTFuseTestTools.xcframework' +end diff --git a/ios/LICENSE b/ios/LICENSE new file mode 100644 index 0000000..bc3ddf4 --- /dev/null +++ b/ios/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023 Breautek + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/ios/NOTICE b/ios/NOTICE new file mode 100644 index 0000000..a62fc8a --- /dev/null +++ b/ios/NOTICE @@ -0,0 +1,7 @@ + +### ENCRYPTION + +This software includes third-party libraries that handles encrypting traffic between the embedded webview +and the embedded Fuse API server. + +Please remember that export/import and/or use of strong cryptography software, providing cryptography hooks, or even just communicating technical details about cryptography software is illegal in some parts of the world. So when you import this package to your country, re-distribute it from there or even just email technical suggestions or even source patches to the authors or other people you are strongly advised to pay close attention to any laws or regulations which apply to you. Breautek, or any other contributors to the Fuse framework are not liable for any violations you make here. So be careful, it is your responsibility. diff --git a/ios/Overview.docc/Overview.md b/ios/Overview.docc/Overview.md new file mode 100644 index 0000000..e9ab83a --- /dev/null +++ b/ios/Overview.docc/Overview.md @@ -0,0 +1,20 @@ + +# BTFuse + +@Metadata { + @TitleHeading("Title Heading") + @TechnologyRoot +} + + +This is a summary + +## Overview + +This is some text + +## Topics + +### GroupName + +Landing diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..17e386c --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,14 @@ + +platform :ios, '15.0' + +workspace 'BTFuse.xcworkspace' + +source 'https://github.com/breautek/pods.git' + +target 'BTFuse' do + use_frameworks! + project 'BTFuse/BTFuse.xcodeproj' + + pod 'OpenSSL', '3.2.0-fuse-2' +end + diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..3e8b24e --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - OpenSSL (3.2.0-fuse-2) + +DEPENDENCIES: + - OpenSSL (= 3.2.0-fuse-2) + +SPEC REPOS: + https://github.com/breautek/pods.git: + - OpenSSL + +SPEC CHECKSUMS: + OpenSSL: bcb2addba483c1d1bf4c80c69060c345111dd99d + +PODFILE CHECKSUM: 56aef115f2e167bf6d8dc0430bc4f4fecf9333d7 + +COCOAPODS: 1.15.2 diff --git a/ios/README.md b/ios/README.md new file mode 100644 index 0000000..929df63 --- /dev/null +++ b/ios/README.md @@ -0,0 +1,23 @@ + +# Fuse iOS + +This is the iOS Fuse module, providing the platform implementation for the Fuse framework on iOS devices and simulators. + +## Checking out the code + +This module uses git submodules, clone via: + +``` +git clone https://github.com/btfuse/fuse-ios.git --recurse-submodules +``` + +## Building + +To build the XCFramework, run `./build.sh`. Otherwise, open `BTFuse.xcworkspace` in XCode and build for for iOS or iOS Simulator target. + +Note that first time builds will build OpenSSL which will take awhile. + +## Testing + +Run `./test.sh` which will launch tests for all supported iOS versions. +Alternatively you can run the tests for a specific device via XCode. diff --git a/ios/VERSION b/ios/VERSION new file mode 100644 index 0000000..7eff8ab --- /dev/null +++ b/ios/VERSION @@ -0,0 +1 @@ +0.8.12 diff --git a/ios/build.sh b/ios/build.sh new file mode 100755 index 0000000..6b661cd --- /dev/null +++ b/ios/build.sh @@ -0,0 +1,152 @@ + +#!/bin/bash + +# Copyright 2023 Breautek + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Purpose +# +# Builds and prepares the project for release. +# If you're developing or contributing to the Fuse framework, you'll want to open +# the XCWorkspace in XCode instead. +# +# This script will +# 1. Clean your build environment for a fresh build. +# 2. Run tests, this may take awhile. +# 3. Copy files to a dist/ directory. + +source build-tools/assertions.sh +source build-tools/DirectoryTools.sh +source build-tools/Checksum.sh + +assertMac "Mac is required to build Fuse iOS" + +if [ "$CI" != "true" ]; then + if [ -z "$BTFUSE_CODESIGN_IDENTITY" ]; then + echo "BTFUSE_CODESIGN_IDENTITY environment variable is required." + exit 2 + fi +fi + +echo "Building Fuse iOS Framework $(cat ./VERSION)..." + +rm -rf dist +mkdir -p dist + +echo "Cleaning the workspace..." +# Clean the build +# XCode can do a poor job in detecting if object code should recompile, particularly when messing with +# build configuration settings. This will ensure that the produced binary will be representative. +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Release -destination "generic/platform=iOS" clean +assertLastCall +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Debug -destination "generic/platform=iOS Simulator" clean +assertLastCall +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Release -destination "generic/platform=iOS" clean +assertLastCall +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Debug -destination "generic/platform=iOS Simulator" clean +assertLastCall + +echo "Building iOS framework..." +# Now build the iOS platform target in Release mode. We will continue to use Debug mode for iOS Simulator targets. +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Release -destination "generic/platform=iOS" build +assertLastCall +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Release -destination "generic/platform=iOS" build +assertLastCall +echo "Building iOS Simulator framework..." +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Debug -destination "generic/platform=iOS Simulator" build +assertLastCall +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Debug -destination "generic/platform=iOS Simulator" build +assertLastCall + +echo "Building Documentation..." +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Release -destination 'generic/platform=iOS' docbuild +xcodebuild -quiet -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Release -destination 'generic/platform=iOS' docbuild + +iosBuild=$(echo "$(xcodebuild -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Release -sdk iphoneos -showBuildSettings | grep -E '^\s*CONFIGURATION_BUILD_DIR =' | awk -F '= ' '{print $2}' | xargs)") +simBuild=$(echo "$(xcodebuild -workspace BTFuse.xcworkspace -scheme BTFuse -configuration Debug -sdk iphonesimulator -showBuildSettings | grep -E '^\s*CONFIGURATION_BUILD_DIR =' | awk -F '= ' '{print $2}' | xargs)") +iosTestToolsBuild=$(echo "$(xcodebuild -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Release -sdk iphoneos -showBuildSettings | grep -E '^\s*CONFIGURATION_BUILD_DIR =' | awk -F '= ' '{print $2}' | xargs)") +simTestToolsBuild=$(echo "$(xcodebuild -workspace BTFuse.xcworkspace -scheme BTFuseTestTools -configuration Debug -sdk iphonesimulator -showBuildSettings | grep -E '^\s*CONFIGURATION_BUILD_DIR =' | awk -F '= ' '{print $2}' | xargs)") + +mkdir -p dist/docs/intermediates +mkdir -p dist/docs/out +xcrun docc convert ./Overview.docc --fallback-display-name BTFuse --output-dir dist/docs/intermediates/Overview.doccarchive +xcrun docc merge ./dist/docs/intermediates/Overview.doccarchive $iosBuild/BTFuse.doccarchive $iosBuild/BTFuseTestTools.doccarchive --output-path dist/docs/out/ + +# intermediatesDir=$iosBuild/../../Intermediates.noindex/ +# mkdir -p dist/docs/intermediates/ +# cp -r $intermediatesDir/BTFuse.build/Release-iphoneos/BTFuse.build/symbol-graph dist/docs/intermediates +# cp -r $intermediatesDir/BTFuseTestTools.build/Release-iphoneos/BTFuseTestTools.build/symbol-graph dist/docs/intermediates + +# xcrun docc convert --output-dir dist/docs/doc.doccarchive --additional-symbol-graph-dir dist/docs/intermediates/x + +if [ "$CI" == "true" ]; then + echo "Skipping CodeSign (CI Build)" +else + echo "Signing iOS build..." + codesign -s $BTFUSE_CODESIGN_IDENTITY --deep $iosBuild/BTFuse.framework + assertLastCall + codesign -s $BTFUSE_CODESIGN_IDENTITY --deep $iosTestToolsBuild/BTFuseTestTools.framework + assertLastCall + + echo "Verifying iOS Build" + codesign -dvvvv $iosBuild/BTFuse.framework + assertLastCall + codesign -dvvvv $iosTestToolsBuild/BTFuseTestTools.framework + assertLastCall +fi + +cp -r $iosBuild/BTFuse.framework.dSYM ./dist/ +cp -r $iosTestToolsBuild/BTFuseTestTools.framework.dSYM ./dist + +echo "Packing XCFramework..." +xcodebuild -create-xcframework \ + -framework $iosBuild/BTFuse.framework \ + -debug-symbols $iosBuild/BTFuse.framework.dSYM \ + -framework $simBuild/BTFuse.framework \ + -output dist/BTFuse.xcframework +assertLastCall +xcodebuild -create-xcframework \ + -framework $iosTestToolsBuild/BTFuseTestTools.framework \ + -debug-symbols $iosTestToolsBuild/BTFuseTestTools.framework.dSYM \ + -framework $simTestToolsBuild/BTFuseTestTools.framework \ + -output dist/BTFuseTestTools.xcframework +assertLastCall + +spushd dist + zip -r BTFuse.xcframework.zip BTFuse.xcframework > /dev/null + zip -r BTFuse.framework.dSYM.zip BTFuse.framework.dSYM > /dev/null + zip -r BTFuseTestTools.xcframework.zip BTFuseTestTools.xcframework > /dev/null + zip -r BTFuseTestTools.framework.dSYM.zip BTFuseTestTools.framework.dSYM > /dev/null + # tar -czvf dist/docs.tar.gz -C dist/docs . + sha1_compute BTFuse.xcframework.zip + sha1_compute BTFuse.framework.dSYM.zip + sha1_compute BTFuseTestTools.xcframework.zip + sha1_compute BTFuseTestTools.framework.dSYM.zip +spopd + +VERSION=$(cat ./VERSION) +FUSE_CHECKSUM=$(cat ./dist/BTFuse.xcframework.zip.sha1.txt) +TESTTOOLS_CHECKSUM=$(cat ./dist/BTFuseTestTools.xcframework.zip.sha1.txt) + +btfusePodSpecTemplate=$( BTFuse.podspec +echo "$btfuseTestToolsPodSpecTemplate" > BTFuseTestTools.podspec diff --git a/ios/makeRelease.sh b/ios/makeRelease.sh new file mode 100755 index 0000000..a4444d5 --- /dev/null +++ b/ios/makeRelease.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Copyright 2023 Breautek + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source build-tools/assertions.sh +source build-tools/DirectoryTools.sh + +assertMac "Mac is required for publishing" +assertGitRepo +assertCleanRepo + +VERSION="$1" + +assertVersion $VERSION +assetGitTagAvailable $VERSION + +echo $VERSION > VERSION + +spushd BTFuse/configs + echo "// This is an auto-generated file, do not edit!" > version.xcconfig + echo "CURRENT_PROJECT_VERSION = $VERSION" >> version.xcconfig + echo "MARKETING_VERSION = $VERSION" >> version.xcconfig +spopd + +./build.sh +./test.sh + +git add VERSION BTFuse/configs/version.xcconfig +git add VERSION +git commit -m "iOS Release: $VERSION" +git push +git tag -a $VERSION -m "iOS Release: $VERSION" +git push --tags + +gh release create $VERSION \ + ./dist/BTFuse.xcframework.zip \ + ./dist/BTFuse.xcframework.zip.sha1.txt \ + ./dist/BTFuse.framework.dSYM.zip \ + ./dist/BTFuse.framework.dSYM.zip.sha1.txt \ + ./dist/BTFuseTestTools.xcframework.zip \ + ./dist/BTFuseTestTools.xcframework.zip.sha1.txt \ + ./dist/BTFuseTestTools.framework.dSYM.zip \ + ./dist/BTFuseTestTools.framework.dSYM.zip.sha1.txt \ + --verify-tag --generate-notes + +./podPublish.sh diff --git a/ios/podPublish.sh b/ios/podPublish.sh new file mode 100755 index 0000000..546ae6b --- /dev/null +++ b/ios/podPublish.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# Copyright 2023-2024 Breautek + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source build-tools/assertions.sh + +pod spec lint BTFuse.podspec +assertLastCall + +pod spec lint BTFuseTestTools.podspec +assertLastCall + +pod repo push breautek BTFuse.podspec +pod repo push breautek BTFuseTestTools.podspec diff --git a/ios/test.sh b/ios/test.sh new file mode 100755 index 0000000..085e647 --- /dev/null +++ b/ios/test.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# Copyright 2023 Breautek + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ -z "$1" ]; then + # Default Tests + IOS_15=$(python3 ./build-tools/iossim.py "Fuse iOS 15" "iOS 15.5" "iPhone 13") + IOS_16=$(python3 ./build-tools/iossim.py "Fuse iOS 16" "iOS 16.4" "iPhone 14") + IOS_17=$(python3 ./build-tools/iossim.py "Fuse iOS 17" "iOS 17.5" "iPhone 15") + + xcrun simctl boot $IOS_15 > /dev/null + xcrun simctl boot $IOS_16 > /dev/null + xcrun simctl boot $IOS_17 > /dev/null + + ios15Check="0" + ios16Check="0" + ios17Check="0" + + echo "Using the following simulators:" + echo "iOS 15: $IOS_15" + echo "iOS 16: $IOS_16" + echo "iOS 17: $IOS_17" + + xcodebuild -quiet test -workspace BTFuse.xcworkspace -scheme BTFuseTests -enableCodeCoverage YES -destination-timeout 60 -destination "id=$IOS_15" + ios15Check=$? + xcodebuild -quiet test -workspace BTFuse.xcworkspace -scheme BTFuseTests -enableCodeCoverage YES -destination-timeout 60 -destination "id=$IOS_16" + ios16Check=$? + xcodebuild -quiet test -workspace BTFuse.xcworkspace -scheme BTFuseTests -enableCodeCoverage YES -destination-timeout 60 -destination "id=$IOS_17" + ios17Check=$? + + if [ "$ios15Check" -ne "0" ]; then + echo "iOS 15 tests failed." + else + echo "iOS 15 tests passed." + fi + + if [ "$ios16Check" -ne "0" ]; then + echo "iOS 16 tests failed." + else + echo "iOS 16 tests passed." + fi + + if [ "$ios17Check" -ne "0" ]; then + echo "iOS 17 tests failed." + else + echo "iOS 17 tests passed." + fi + + exit $ios15Check || $ios16Check || $ios17Check || 0 +else + # Usage: ./test.sh "Fuse iOS 15" "15.5" "iPhone 13" + SIM_NAME="$1" + SIM_VERSION="iOS $2" + SIM_MODEL="$3" + + SIM=$(python3 ./build-tools/iossim.py "$SIM_NAME" "$SIM_VERSION" "$SIM_MODEL") + echo "Using Sim: $SIM" + + xcrun simctl boot $SIM > /dev/null + + xcodebuild -quiet test -workspace BTFuse.xcworkspace -scheme BTFuseTests -enableCodeCoverage YES -destination-timeout 60 -destination "id=$SIM" + testResult=$? + + if [ "$testResult" -ne "0" ]; then + echo "$SIM_VERSION tests failed." + exit $testResult + else + echo "$SIM_VERSION tests passed." + fi +fi diff --git a/js/.npmignore b/js/.npmignore index 0a8f63b..89eb41a 100644 --- a/js/.npmignore +++ b/js/.npmignore @@ -3,3 +3,4 @@ jest.config.ts *.tgz spec src +/dist diff --git a/js/.npmrc b/js/.npmrc index b452e82..6a0b682 100644 --- a/js/.npmrc +++ b/js/.npmrc @@ -1,3 +1,2 @@ save-exact=true registry=https://registry.npmjs.org - diff --git a/test-app/.gitignore b/test-app/.gitignore index c6938b6..18e1cc6 100644 --- a/test-app/.gitignore +++ b/test-app/.gitignore @@ -12,4 +12,6 @@ assets/* main.js *.map .DS_Store - +/ios/testapp/assets/**/*.js +/ios/testapp/assets/index.html +/ios/testapp/assets/largeFile.txt diff --git a/test-app/.npmrc b/test-app/.npmrc new file mode 100644 index 0000000..9867760 --- /dev/null +++ b/test-app/.npmrc @@ -0,0 +1,3 @@ +package-lock=false +save-exact=true +registry=https://registry.npmjs.org diff --git a/test-app/ios/en.lproj/Localizable.strings b/test-app/ios/en.lproj/Localizable.strings new file mode 100644 index 0000000..452d0d9 --- /dev/null +++ b/test-app/ios/en.lproj/Localizable.strings @@ -0,0 +1,19 @@ + +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +"FUSE_DIALOG_OK_BUTTON_LABEL" = "OKTest"; +"FUSE_DIALOG_CANCEL_BUTTON_LABEL" = "Cancel"; diff --git a/test-app/ios/scripts/build.sh b/test-app/ios/scripts/build.sh new file mode 100755 index 0000000..e3c274a --- /dev/null +++ b/test-app/ios/scripts/build.sh @@ -0,0 +1,54 @@ + +# Copyright 2023 Breautek + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source ../../build-tools/DirectoryTools.sh +source ../../build-tools/assertions.sh + +assetDir="$(pwd)/$1" + +echo "ASSET DIR: $assetDir" + +if [ -z "$assetDir" ]; then + echo "Asset directory argument is required" + exit 1 +fi + +# Build Core Lib +spushd ../../js + ./build.sh + assertLastCall +spopd + +# Build the test echo plugin +spushd ../../echo + ./build.sh + assertLastCall +spopd + +spushd ../../test-app + # Build the test app JS + npm install + assertLastCall + + npm install file:../js/dist/fuse.tgz file:../echo/dist/echo.tgz + + node scripts/generateTestFile.js + assertLastCall + + mkdir -p $assetDir + cp ./largeFile.txt "$assetDir/largeFile.txt" + ASSET_DIR="$assetDir" npx webpack --mode development --config webpack.config.ios.js + assertLastCall +spopd diff --git a/test-app/ios/testapp.xcodeproj/project.pbxproj b/test-app/ios/testapp.xcodeproj/project.pbxproj new file mode 100644 index 0000000..4ca4c09 --- /dev/null +++ b/test-app/ios/testapp.xcodeproj/project.pbxproj @@ -0,0 +1,465 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 941862A72A9A751E00CCFEE1 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 941862A62A9A751E00CCFEE1 /* assets */; }; + 94552C562ACA125000DAE0F4 /* libecho.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94A886DF2A7170460098530D /* libecho.a */; }; + 945A059C2AE585B50042C88A /* BTFuse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 945A059B2AE585B50042C88A /* BTFuse.framework */; }; + 945A059D2AE585B50042C88A /* BTFuse.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 945A059B2AE585B50042C88A /* BTFuse.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9489EBB42AA659820087424D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9489EBB62AA659820087424D /* Localizable.strings */; }; + 94A886972A7146970098530D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A886962A7146970098530D /* AppDelegate.m */; }; + 94A8869A2A7146970098530D /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A886992A7146970098530D /* SceneDelegate.m */; }; + 94A8869D2A7146970098530D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A8869C2A7146970098530D /* ViewController.m */; }; + 94A886A02A7146970098530D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 94A8869E2A7146970098530D /* Main.storyboard */; }; + 94A886A22A7146980098530D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 94A886A12A7146980098530D /* Assets.xcassets */; }; + 94A886A52A7146980098530D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 94A886A32A7146980098530D /* LaunchScreen.storyboard */; }; + 94A886A82A7146980098530D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 94A886A72A7146980098530D /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 945A059E2AE585B50042C88A /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 945A059D2AE585B50042C88A /* BTFuse.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 941862A62A9A751E00CCFEE1 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = assets; sourceTree = ""; }; + 945A059B2AE585B50042C88A /* BTFuse.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BTFuse.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9489EBB52AA659820087424D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 94A886922A7146970098530D /* testapp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testapp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 94A886952A7146970098530D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 94A886962A7146970098530D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 94A886982A7146970098530D /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; }; + 94A886992A7146970098530D /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; }; + 94A8869B2A7146970098530D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 94A8869C2A7146970098530D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 94A8869F2A7146970098530D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 94A886A12A7146980098530D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 94A886A42A7146980098530D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 94A886A62A7146980098530D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 94A886A72A7146980098530D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 94A886DF2A7170460098530D /* libecho.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libecho.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 94A8868F2A7146970098530D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 94552C562ACA125000DAE0F4 /* libecho.a in Frameworks */, + 945A059C2AE585B50042C88A /* BTFuse.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9489EBB12AA659620087424D /* localization */ = { + isa = PBXGroup; + children = ( + 9489EBB62AA659820087424D /* Localizable.strings */, + ); + name = localization; + sourceTree = ""; + }; + 94A886892A7146970098530D = { + isa = PBXGroup; + children = ( + 9489EBB12AA659620087424D /* localization */, + 94A886942A7146970098530D /* testapp */, + 94A886932A7146970098530D /* Products */, + 94A886B02A714E4A0098530D /* Frameworks */, + ); + sourceTree = ""; + }; + 94A886932A7146970098530D /* Products */ = { + isa = PBXGroup; + children = ( + 94A886922A7146970098530D /* testapp.app */, + ); + name = Products; + sourceTree = ""; + }; + 94A886942A7146970098530D /* testapp */ = { + isa = PBXGroup; + children = ( + 941862A62A9A751E00CCFEE1 /* assets */, + 94A886952A7146970098530D /* AppDelegate.h */, + 94A886962A7146970098530D /* AppDelegate.m */, + 94A886982A7146970098530D /* SceneDelegate.h */, + 94A886992A7146970098530D /* SceneDelegate.m */, + 94A8869B2A7146970098530D /* ViewController.h */, + 94A8869C2A7146970098530D /* ViewController.m */, + 94A8869E2A7146970098530D /* Main.storyboard */, + 94A886A12A7146980098530D /* Assets.xcassets */, + 94A886A32A7146980098530D /* LaunchScreen.storyboard */, + 94A886A62A7146980098530D /* Info.plist */, + 94A886A72A7146980098530D /* main.m */, + ); + path = testapp; + sourceTree = ""; + }; + 94A886B02A714E4A0098530D /* Frameworks */ = { + isa = PBXGroup; + children = ( + 945A059B2AE585B50042C88A /* BTFuse.framework */, + 94A886DF2A7170460098530D /* libecho.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 94A886912A7146970098530D /* testapp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 94A886AB2A7146980098530D /* Build configuration list for PBXNativeTarget "testapp" */; + buildPhases = ( + 941862A82A9A75B400CCFEE1 /* Prepare JS */, + 94A8868E2A7146970098530D /* Sources */, + 94A8868F2A7146970098530D /* Frameworks */, + 94A886902A7146970098530D /* Resources */, + 945A059E2AE585B50042C88A /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testapp; + productName = testapp; + productReference = 94A886922A7146970098530D /* testapp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 94A8868A2A7146970098530D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1510; + TargetAttributes = { + 94A886912A7146970098530D = { + CreatedOnToolsVersion = 14.3.1; + }; + }; + }; + buildConfigurationList = 94A8868D2A7146970098530D /* Build configuration list for PBXProject "testapp" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 94A886892A7146970098530D; + productRefGroup = 94A886932A7146970098530D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 94A886912A7146970098530D /* testapp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 94A886902A7146970098530D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9489EBB42AA659820087424D /* Localizable.strings in Resources */, + 94A886A52A7146980098530D /* LaunchScreen.storyboard in Resources */, + 941862A72A9A751E00CCFEE1 /* assets in Resources */, + 94A886A22A7146980098530D /* Assets.xcassets in Resources */, + 94A886A02A7146970098530D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 941862A82A9A75B400CCFEE1 /* Prepare JS */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Prepare JS"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\npwd\n./scripts/build.sh ./testapp/assets\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 94A8868E2A7146970098530D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 94A8869D2A7146970098530D /* ViewController.m in Sources */, + 94A886972A7146970098530D /* AppDelegate.m in Sources */, + 94A886A82A7146980098530D /* main.m in Sources */, + 94A8869A2A7146970098530D /* SceneDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9489EBB62AA659820087424D /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 9489EBB52AA659820087424D /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; + 94A8869E2A7146970098530D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 94A8869F2A7146970098530D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 94A886A32A7146980098530D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 94A886A42A7146980098530D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 94A886A92A7146980098530D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = 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 = ""; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 94A886AA2A7146980098530D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = 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 = ""; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 94A886AC2A7146980098530D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 2; + DEVELOPMENT_TEAM = AF37P8XHYY; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../echo/ios/echo/\""; + INFOPLIST_FILE = testapp/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.5; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse.testapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + 94A886AD2A7146980098530D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 2; + DEVELOPMENT_TEAM = AF37P8XHYY; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GENERATE_INFOPLIST_FILE = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../echo/ios/echo/\""; + INFOPLIST_FILE = testapp/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.5; + PRODUCT_BUNDLE_IDENTIFIER = com.breautek.fuse.testapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 94A8868D2A7146970098530D /* Build configuration list for PBXProject "testapp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94A886A92A7146980098530D /* Debug */, + 94A886AA2A7146980098530D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 94A886AB2A7146980098530D /* Build configuration list for PBXNativeTarget "testapp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 94A886AC2A7146980098530D /* Debug */, + 94A886AD2A7146980098530D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 94A8868A2A7146970098530D /* Project object */; +} diff --git a/test-app/ios/testapp.xcodeproj/xcshareddata/xcschemes/testapp.xcscheme b/test-app/ios/testapp.xcodeproj/xcshareddata/xcschemes/testapp.xcscheme new file mode 100644 index 0000000..aacfe1c --- /dev/null +++ b/test-app/ios/testapp.xcodeproj/xcshareddata/xcschemes/testapp.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-app/ios/testapp/AppDelegate.h b/test-app/ios/testapp/AppDelegate.h new file mode 100644 index 0000000..9c8d35d --- /dev/null +++ b/test-app/ios/testapp/AppDelegate.h @@ -0,0 +1,23 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import + +@interface AppDelegate : UIResponder + + +@end + diff --git a/test-app/ios/testapp/AppDelegate.m b/test-app/ios/testapp/AppDelegate.m new file mode 100644 index 0000000..11740f5 --- /dev/null +++ b/test-app/ios/testapp/AppDelegate.m @@ -0,0 +1,49 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +#pragma mark - UISceneSession lifecycle + + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; +} + + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. +} + + +@end diff --git a/test-app/ios/testapp/Assets.xcassets/AccentColor.colorset/Contents.json b/test-app/ios/testapp/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/test-app/ios/testapp/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/test-app/ios/testapp/Assets.xcassets/AppIcon.appiconset/Contents.json b/test-app/ios/testapp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/test-app/ios/testapp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/test-app/ios/testapp/Assets.xcassets/Contents.json b/test-app/ios/testapp/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/test-app/ios/testapp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/test-app/ios/testapp/Base.lproj/LaunchScreen.storyboard b/test-app/ios/testapp/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/test-app/ios/testapp/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-app/ios/testapp/Base.lproj/Main.storyboard b/test-app/ios/testapp/Base.lproj/Main.storyboard new file mode 100644 index 0000000..808a21c --- /dev/null +++ b/test-app/ios/testapp/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-app/ios/testapp/Info.plist b/test-app/ios/testapp/Info.plist new file mode 100644 index 0000000..81ed29b --- /dev/null +++ b/test-app/ios/testapp/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/test-app/ios/testapp/SceneDelegate.h b/test-app/ios/testapp/SceneDelegate.h new file mode 100644 index 0000000..db6bef1 --- /dev/null +++ b/test-app/ios/testapp/SceneDelegate.h @@ -0,0 +1,24 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow * window; + +@end + diff --git a/test-app/ios/testapp/SceneDelegate.m b/test-app/ios/testapp/SceneDelegate.m new file mode 100644 index 0000000..b4dead9 --- /dev/null +++ b/test-app/ios/testapp/SceneDelegate.m @@ -0,0 +1,66 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). +} + + +- (void)sceneDidDisconnect:(UIScene *)scene { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). +} + + +- (void)sceneDidBecomeActive:(UIScene *)scene { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. +} + + +- (void)sceneWillResignActive:(UIScene *)scene { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). +} + + +- (void)sceneWillEnterForeground:(UIScene *)scene { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. +} + + +- (void)sceneDidEnterBackground:(UIScene *)scene { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. +} + + +@end diff --git a/test-app/ios/testapp/ViewController.h b/test-app/ios/testapp/ViewController.h new file mode 100644 index 0000000..3ca9460 --- /dev/null +++ b/test-app/ios/testapp/ViewController.h @@ -0,0 +1,23 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import + +@interface ViewController : UIViewController + +@end + diff --git a/test-app/ios/testapp/ViewController.m b/test-app/ios/testapp/ViewController.m new file mode 100644 index 0000000..72843d9 --- /dev/null +++ b/test-app/ios/testapp/ViewController.m @@ -0,0 +1,45 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import "ViewController.h" +#import + +@implementation ViewController { + BTFuseViewController* $fuseController; +} + +- (void) onContextReady { + BTFuseContext* context = [$fuseController getContext]; + [context registerPlugin:[[EchoPlugin alloc] init: context]]; +} + +- (void) onWebviewReady { + if (@available(iOS 16.4, *)) { + [[$fuseController getContext] getWebview].inspectable = true; + } +} + +- (void) onBeforeWebviewLoad {} + +- (void) viewDidLoad { + [super viewDidLoad]; + + $fuseController = [[BTFuseViewController alloc] init: self]; + [$fuseController attach: self]; +} + + +@end diff --git a/test-app/ios/testapp/main.m b/test-app/ios/testapp/main.m new file mode 100644 index 0000000..5cf95b1 --- /dev/null +++ b/test-app/ios/testapp/main.m @@ -0,0 +1,27 @@ +/* +Copyright 2023 Breautek + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +}