From bbb2cbf18fe08e5c96eaf0cbd15e1b4ec121a083 Mon Sep 17 00:00:00 2001 From: Felix Erdmann Date: Fri, 27 Oct 2023 13:04:11 +0200 Subject: [PATCH] feat: ios deployment --- ios/App/App.xcodeproj/project.pbxproj | 59 +++++++++++++----------- ios/App/App/capacitor.config.json | 4 +- ios/App/Podfile.lock | 2 +- src/components/Device/SettingsDrawer.tsx | 24 ++++------ src/lib/SenseBoxDataParser.ts | 57 ++++++++++------------- src/lib/store/useSenseBoxValuesStore.ts | 4 +- src/lib/useSenseBox.ts | 5 +- 7 files changed, 71 insertions(+), 84 deletions(-) diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index c41ccaa..b35614b 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -14,10 +14,11 @@ 504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; }; 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; }; 50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; }; - A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; + DB837AFCFB579D5EF32B767D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B55C2D81B6DE253CADF9E984 /* Pods_App.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 2E5E47F632E4A2346969DF23 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = ""; }; 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -27,9 +28,8 @@ 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; - AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = ""; }; - FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = ""; }; + B55C2D81B6DE253CADF9E984 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + E31F94C6D55731F1094B211B /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -37,19 +37,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */, + DB837AFCFB579D5EF32B767D /* Pods_App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = { + 47CAF83C7FFCA428F6BFD8F4 /* Pods */ = { isa = PBXGroup; children = ( - AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */, + E31F94C6D55731F1094B211B /* Pods-App.debug.xcconfig */, + 2E5E47F632E4A2346969DF23 /* Pods-App.release.xcconfig */, ); - name = Frameworks; + name = Pods; + path = Pods; sourceTree = ""; }; 504EC2FB1FED79650016851F = { @@ -57,8 +59,8 @@ children = ( 504EC3061FED79650016851F /* App */, 504EC3051FED79650016851F /* Products */, - 7F8756D8B27F46E3366F6CEA /* Pods */, - 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */, + 47CAF83C7FFCA428F6BFD8F4 /* Pods */, + BB651A3CDC87929342E2F3EA /* Frameworks */, ); sourceTree = ""; }; @@ -85,13 +87,12 @@ path = App; sourceTree = ""; }; - 7F8756D8B27F46E3366F6CEA /* Pods */ = { + BB651A3CDC87929342E2F3EA /* Frameworks */ = { isa = PBXGroup; children = ( - FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */, - AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */, + B55C2D81B6DE253CADF9E984 /* Pods_App.framework */, ); - name = Pods; + name = Frameworks; sourceTree = ""; }; /* End PBXGroup section */ @@ -101,11 +102,11 @@ isa = PBXNativeTarget; buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; buildPhases = ( - 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */, + A8152DDDEEBA631AB4282E94 /* [CP] Check Pods Manifest.lock */, 504EC3001FED79650016851F /* Sources */, 504EC3011FED79650016851F /* Frameworks */, 504EC3021FED79650016851F /* Resources */, - 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */, + 3C147EBD1C93D6377B44C635 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -167,37 +168,41 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */ = { + 3C147EBD1C93D6377B44C635 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-App-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"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */ = { + A8152DDDEEBA631AB4282E94 /* [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 = ( ); - name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n"; + 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 */ @@ -342,7 +347,7 @@ }; 504EC3171FED79650016851F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */; + baseConfigurationReference = E31F94C6D55731F1094B211B /* Pods-App.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; @@ -363,7 +368,7 @@ }; 504EC3181FED79650016851F /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */; + baseConfigurationReference = 2E5E47F632E4A2346969DF23 /* Pods-App.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; diff --git a/ios/App/App/capacitor.config.json b/ios/App/App/capacitor.config.json index 7b229ae..0cd908d 100644 --- a/ios/App/App/capacitor.config.json +++ b/ios/App/App/capacitor.config.json @@ -2,7 +2,5 @@ "appId": "de.reedu.senseboxbike", "appName": "senseBox:Bike", "webDir": "out", - "server": { - "url": "http://192.168.0.220:3000" - } + "server": {} } diff --git a/ios/App/Podfile.lock b/ios/App/Podfile.lock index 23fcfb7..38ec475 100644 --- a/ios/App/Podfile.lock +++ b/ios/App/Podfile.lock @@ -43,4 +43,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: f2e3708e22e094f8a9b03f2e5f0e3688df829e58 -COCOAPODS: 1.11.3 +COCOAPODS: 1.14.0 diff --git a/src/components/Device/SettingsDrawer.tsx b/src/components/Device/SettingsDrawer.tsx index e6883b7..357fe1d 100644 --- a/src/components/Device/SettingsDrawer.tsx +++ b/src/components/Device/SettingsDrawer.tsx @@ -30,17 +30,11 @@ import { Switch } from '../ui/switch' import { useSettingsStore } from '@/lib/store/useSettingsStore' import { Button } from '../ui/button' import { DialogClose } from '@radix-ui/react-dialog' -import useSenseBox from '@/lib/useSenseBox' +import useSenseBox, { BackgroundGeolocation } from '@/lib/useSenseBox' import { numbersToDataView } from '@capacitor-community/bluetooth-le' -import { registerPlugin } from '@capacitor/core' -import { BackgroundGeolocationPlugin } from '@felixerdy/background-geolocation' import { Drawer } from 'vaul' import { useEffect, useState } from 'react' -const BackgroundGeolocation = registerPlugin( - 'BackgroundGeolocation', -) - const formSchema = z.object({ uploadInterval: z.number().min(1).max(60), switchUseDeviceGPS: z.boolean(), @@ -62,14 +56,14 @@ export default function SettingsDrawer() { }) const handleSubmit = (values: z.infer) => { - send( - '29BD0A85-51E4-4D3C-914E-126541EB2A5E', - '60B1D5CE-3539-44D2-BB35-FF2DAABE17FF', - numbersToDataView([ - values.uploadInterval, - values.switchUseDeviceGPS ? 1 : 0, - ]), - ) + // send( + // '29BD0A85-51E4-4D3C-914E-126541EB2A5E', + // '60B1D5CE-3539-44D2-BB35-FF2DAABE17FF', + // numbersToDataView([ + // values.uploadInterval, + // values.switchUseDeviceGPS ? 1 : 0, + // ]), + // ) useSettingsStore.setState({ uploadInterval: values.uploadInterval, useSenseBoxGPS: values.switchUseDeviceGPS, diff --git a/src/lib/SenseBoxDataParser.ts b/src/lib/SenseBoxDataParser.ts index 97ece30..f07af30 100644 --- a/src/lib/SenseBoxDataParser.ts +++ b/src/lib/SenseBoxDataParser.ts @@ -3,11 +3,6 @@ import { senseBoxDataRecord, useSenseBoxValuesStore, } from './store/useSenseBoxValuesStore' -import { BackgroundGeolocationPlugin } from '@felixerdy/background-geolocation' - -const BackgroundGeolocation = registerPlugin( - 'BackgroundGeolocation', -) export class SenseBoxDataParser { private static instance: SenseBoxDataParser @@ -83,31 +78,31 @@ export class SenseBoxDataParser { b.distance_l !== undefined, ) - const bucketsProcessedLocation = await Promise.all( - buckets.map(async b => { - const processedLocation = await BackgroundGeolocation.processLocation({ - location: { - latitude: b.gps_lat!, - longitude: b.gps_lng!, - speed: b.gps_spd!, - accuracy: 0, - simulated: false, - altitude: null, - bearing: null, - altitudeAccuracy: null, - time: b.timestamp.getTime(), - }, - }) - return { - ...b, - gps_lat: processedLocation.latitude, - gps_lng: processedLocation.longitude, - gps_spd: processedLocation.speed, - } as senseBoxDataRecord - }), - ) - - useSenseBoxValuesStore.getState().addValues(bucketsProcessedLocation) + // const bucketsProcessedLocation = await Promise.all( + // buckets.map(async b => { + // const processedLocation = await BackgroundGeolocation.processLocation({ + // location: { + // latitude: b.gps_lat!, + // longitude: b.gps_lng!, + // speed: b.gps_spd!, + // accuracy: 0, + // simulated: false, + // altitude: null, + // bearing: null, + // altitudeAccuracy: null, + // time: b.timestamp.getTime(), + // }, + // }) + // return { + // ...b, + // gps_lat: processedLocation.latitude ?? 0, + // gps_lng: processedLocation.longitude ?? 0, + // gps_spd: processedLocation.speed ?? 0, + // } as senseBoxDataRecord + // }), + // ) + + useSenseBoxValuesStore.getState().addValues(buckets) const completeTimestamps = buckets.map(b => b.timestamp) @@ -120,8 +115,6 @@ export class SenseBoxDataParser { this.timestampInterval, ), ) - - console.log(this.dataBuffer.length) } pushData(data: Omit) { diff --git a/src/lib/store/useSenseBoxValuesStore.ts b/src/lib/store/useSenseBoxValuesStore.ts index a34c10d..2fa6fad 100644 --- a/src/lib/store/useSenseBoxValuesStore.ts +++ b/src/lib/store/useSenseBoxValuesStore.ts @@ -28,8 +28,6 @@ export const useSenseBoxValuesStore = create(set => ({ setValues: values => set({ values }), addValues: values => set(state => ({ - values: [...state.values, ...values].sort( - (a, b) => a.timestamp.getTime() - b.timestamp.getTime(), - ), + values: [...state.values, ...values], })), })) diff --git a/src/lib/useSenseBox.ts b/src/lib/useSenseBox.ts index ba25438..01f36ea 100644 --- a/src/lib/useSenseBox.ts +++ b/src/lib/useSenseBox.ts @@ -26,9 +26,8 @@ const BLE_DISTANCE_CHARACTERISTIC = 'B3491B60-C0F3-4306-A30D-49C91F37A62B' const BLE_CONFIG_SERVICE = '29BD0A85-51E4-4D3C-914E-126541EB2A5E' const BLE_CONFIG_CHARACTERISTIC = '60B1D5CE-3539-44D2-BB35-FF2DAABE17FF' -const BackgroundGeolocation = registerPlugin( - 'BackgroundGeolocation', -) +export const BackgroundGeolocation = + registerPlugin('BackgroundGeolocation') /** * Parses the data received from the SenseBox and returns an array of values.