Skip to content

Commit

Permalink
Fix iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dimninik committed May 29, 2024
1 parent 2d72c66 commit b241337
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 60 deletions.
25 changes: 17 additions & 8 deletions example/ios/BlePlxExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@
baseConfigurationReference = 5B7EB9410499542E8C5724F5 /* Pods-BlePlxExample-BlePlxExampleTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 457FBQ4469;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -435,7 +436,7 @@
"-lc++",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.intent.BlePlxExample.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BlePlxExample.app/BlePlxExample";
};
Expand All @@ -447,6 +448,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = 457FBQ4469;
INFOPLIST_FILE = BlePlxExampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -459,7 +461,7 @@
"-lc++",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.intent.BlePlxExample.Tests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BlePlxExample.app/BlePlxExample";
};
Expand All @@ -472,7 +474,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = J8TDRBT8NT;
DEVELOPMENT_TEAM = 457FBQ4469;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = BlePlxExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -485,7 +487,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.intent.BlePlxExample;
PRODUCT_NAME = BlePlxExample;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -500,7 +502,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = J8TDRBT8NT;
DEVELOPMENT_TEAM = 457FBQ4469;
INFOPLIST_FILE = BlePlxExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -512,7 +514,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.intent.BlePlxExample;
PRODUCT_NAME = BlePlxExample;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -554,14 +556,15 @@
CXX = "";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -584,6 +587,7 @@
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
Expand Down Expand Up @@ -637,9 +641,13 @@
CXX = "";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -659,6 +667,7 @@
"\"$(inherited)\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "[email protected]",
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"filename" : "AppIcon-29@2x~ipad.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"filename" : "[email protected]",
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"filename" : "AppIcon-40@2x~ipad.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "[email protected]",
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "AppIcon-60@2x~car.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "AppIcon-60@3x~car.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"filename" : "AppIcon~ios-marketing.png",
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
Expand Down
1 change: 0 additions & 1 deletion example/ios/BlePlxExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<!-- Do not change NSAllowsArbitraryLoads to true, or you will risk app rejection! -->
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSAllowsLocalNetworking</key>
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ PODS:
- React-Mapbuffer (0.74.1):
- glog
- React-debug
- react-native-ble-plx (3.1.1):
- react-native-ble-plx (3.1.2):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1429,7 +1429,7 @@ SPEC CHECKSUMS:
React-jsitracing: 233d1a798fe0ff33b8e630b8f00f62c4a8115fbc
React-logger: 7e7403a2b14c97f847d90763af76b84b152b6fce
React-Mapbuffer: 11029dcd47c5c9e057a4092ab9c2a8d10a496a33
react-native-ble-plx: 9cec27d777ad5e3255273168958e7135966cf070
react-native-ble-plx: cd7b99ddaf7c15e652c63f87a12e96c715ee3c80
react-native-safe-area-context: dcab599c527c2d7de2d76507a523d20a0b83823d
React-nativeconfig: b0073a590774e8b35192fead188a36d1dca23dec
React-NativeModulesApple: df46ff3e3de5b842b30b4ca8a6caae6d7c8ab09f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { MainStackParamList } from '../../../navigation/navigators'
import { AppButton, AppText, ScreenDefaultContainer, TestStateDisplay } from '../../../components/atoms'
import { functionsToTest } from './utils'
import { BLEService } from '../../../services'
import { TestStateType } from '../../../types'
import { type TestStateType } from '../../../types'

type DeviceConnectDisconnectTestScreenProps = NativeStackScreenProps<MainStackParamList, 'INSTANCE_DESTROY_SCREEN'>
type TestData = { name: string; response: string | null }
Expand Down Expand Up @@ -79,16 +79,26 @@ export function InstanceDestroyScreen(_props: DeviceConnectDisconnectTestScreenP
await startChain(() => setInstanceExistsCalls(prevState => prevState + 1))
await BLEService.manager
.destroy()
.then(() => setCorrectInstaceDestroy('DONE'))
.catch(() => setCorrectInstaceDestroy('ERROR'))
.then(info => {
console.info('first destroy try - then', info)
setCorrectInstaceDestroy('DONE')
})
.catch(error => {
console.error('first destroy try - catch', error)
setCorrectInstaceDestroy('ERROR')
})
await BLEService.manager
.destroy()
.then(() => setSecondInstaceDestroyFinishedWithError('ERROR'))
.catch(error =>
.then(info => {
console.info('second destroy try - then', info)
setSecondInstaceDestroyFinishedWithError('ERROR')
})
.catch(error => {
console.error('second destroy try - catch', error)
setSecondInstaceDestroyFinishedWithError(
error?.reason?.includes('BleManager has been destroyed') ? 'DONE' : 'ERROR'
)
)
})

await startChain(() => setInstanceDestroyedCalls(prevState => prevState + 1))
}
Expand Down
7 changes: 5 additions & 2 deletions example/src/services/BLEService/BLEService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BLEServiceInstance {

createNewManager = () => {
this.manager = new BleManager()
this.manager.setLogLevel(LogLevel.Verbose)
}

getDevice = () => this.device
Expand Down Expand Up @@ -63,6 +64,8 @@ class BLEServiceInstance {
break
default:
console.error('Unsupported state: ', state)
// resolve()
// subscription.remove()
}
}, true)
})
Expand Down Expand Up @@ -407,10 +410,10 @@ class BLEServiceInstance {
if (Platform.OS === 'ios') {
return true
}
if (Platform.OS === 'android' && PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION) {
if (Platform.OS === 'android') {
const apiLevel = parseInt(Platform.Version.toString(), 10)

if (apiLevel < 31) {
if (apiLevel < 31 && PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION) {
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
return granted === PermissionsAndroid.RESULTS.GRANTED
}
Expand Down
9 changes: 8 additions & 1 deletion example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3000,13 +3000,20 @@ fast-glob@^3.2.9, fast-glob@^3.3.2:
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-xml-parser@^4.0.12, fast-xml-parser@^4.2.4:
fast-xml-parser@^4.0.12:
version "4.3.6"
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.3.6.tgz#190f9d99097f0c8f2d3a0e681a10404afca052ff"
integrity sha512-M2SovcRxD4+vC493Uc2GZVcZaj66CCJhWurC4viynVSTvrpErCShNcDz1lAho6n9REQKvL/ll4A4/fw6Y9z8nw==
dependencies:
strnum "^1.0.5"

fast-xml-parser@^4.2.4:
version "4.4.0"
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.4.0.tgz#341cc98de71e9ba9e651a67f41f1752d1441a501"
integrity sha512-kLY3jFlwIYwBNDojclKsNAC12sfD6NwW74QB2CoNGPvtVxjliYehVunB3HYyNi+n4Tt1dAcgwYvmKF/Z18flqg==
dependencies:
strnum "^1.0.5"

fastq@^1.6.0:
version "1.17.1"
resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.17.1.tgz#2a523f07a4e7b1e81a42b91b8bf2254107753b47"
Expand Down
2 changes: 1 addition & 1 deletion ios/MultiplatformBleAdapter/BleModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class BleClientManager : NSObject {

// Constants
static let cccdUUID = CBUUID(string: "2902")

// MARK: Lifecycle -------------------------------------------------------------------------------------------------

@objc
Expand Down
Loading

0 comments on commit b241337

Please sign in to comment.