simplejsble 0.0.38 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
 
13
13
  s.ios.deployment_target = '15.8'
14
- s.osx.deployment_target = '13.0'
15
-
14
+ s.macos.deployment_target = '13.0'
16
15
 
17
16
  s.source = { :path => "." }
18
17
 
@@ -28,16 +28,15 @@
28
28
  <key>HeadersPath</key>
29
29
  <string>Headers</string>
30
30
  <key>LibraryIdentifier</key>
31
- <string>macos-arm64_x86_64</string>
31
+ <string>ios-arm64</string>
32
32
  <key>LibraryPath</key>
33
33
  <string>libsimpleble.a</string>
34
34
  <key>SupportedArchitectures</key>
35
35
  <array>
36
36
  <string>arm64</string>
37
- <string>x86_64</string>
38
37
  </array>
39
38
  <key>SupportedPlatform</key>
40
- <string>macos</string>
39
+ <string>ios</string>
41
40
  </dict>
42
41
  <dict>
43
42
  <key>BinaryPath</key>
@@ -45,15 +44,16 @@
45
44
  <key>HeadersPath</key>
46
45
  <string>Headers</string>
47
46
  <key>LibraryIdentifier</key>
48
- <string>ios-arm64</string>
47
+ <string>macos-arm64_x86_64</string>
49
48
  <key>LibraryPath</key>
50
49
  <string>libsimpleble.a</string>
51
50
  <key>SupportedArchitectures</key>
52
51
  <array>
53
52
  <string>arm64</string>
53
+ <string>x86_64</string>
54
54
  </array>
55
55
  <key>SupportedPlatform</key>
56
- <string>ios</string>
56
+ <string>macos</string>
57
57
  </dict>
58
58
  </array>
59
59
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplejsble",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "React Native Bluetooth Low Energy library using SimpleBLE with Nitro Modules",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -14,6 +14,7 @@
14
14
  "android/",
15
15
  "apple/",
16
16
  "cpp/",
17
+ "scripts/",
17
18
  "simpleble/",
18
19
  "simpledroidbridge/",
19
20
  "cmake/",
@@ -26,6 +27,7 @@
26
27
  "README.md"
27
28
  ],
28
29
  "scripts": {
30
+ "postinstall": "bash scripts/patch-nitro-modules.sh",
29
31
  "prepack": "npm run build && npx nitrogen && bash scripts/prepare-package.sh",
30
32
  "typecheck": "tsc --noEmit",
31
33
  "build": "tsc",
@@ -62,6 +64,9 @@
62
64
  "registry": "https://registry.npmjs.org/",
63
65
  "access": "public"
64
66
  },
67
+ "dependencies": {
68
+ "react-native-nitro-modules": ">=0.20.0"
69
+ },
65
70
  "devDependencies": {
66
71
  "@react-native/eslint-config": "0.82.0",
67
72
  "@types/react": "^19.1.03",
@@ -77,13 +82,7 @@
77
82
  },
78
83
  "peerDependencies": {
79
84
  "react": "*",
80
- "react-native": "*",
81
- "react-native-nitro-modules": ">=0.20.0"
82
- },
83
- "peerDependenciesMeta": {
84
- "react-native-nitro-modules": {
85
- "optional": false
86
- }
85
+ "react-native": "*"
87
86
  },
88
87
  "eslintConfig": {
89
88
  "root": true,
@@ -0,0 +1,63 @@
1
+ #!/bin/bash
2
+ #
3
+ # Patches NitroModules.podspec to use standard CocoaPods deployment_target syntax.
4
+ #
5
+ # Problem: react-native-nitro-modules uses non-standard `s.platforms = {...}` syntax
6
+ # which doesn't properly propagate deployment targets, causing build errors like:
7
+ # "Property with 'retain (or strong)' attribute must be of object type"
8
+ #
9
+ # Solution: Replace with standard `s.ios.deployment_target = ...` syntax.
10
+ #
11
+
12
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+ SCRIPT_NAME="[simplejsble]"
14
+
15
+ # Possible locations for NitroModules.podspec
16
+ PATHS=(
17
+ "$SCRIPT_DIR/../../../react-native-nitro-modules/NitroModules.podspec"
18
+ "$SCRIPT_DIR/../../../../node_modules/react-native-nitro-modules/NitroModules.podspec"
19
+ )
20
+
21
+ PODSPEC_PATH=""
22
+ for path in "${PATHS[@]}"; do
23
+ if [ -f "$path" ]; then
24
+ PODSPEC_PATH="$path"
25
+ break
26
+ fi
27
+ done
28
+
29
+ if [ -z "$PODSPEC_PATH" ]; then
30
+ echo "$SCRIPT_NAME NitroModules.podspec not found, skipping patch"
31
+ exit 0
32
+ fi
33
+
34
+ # Check if already patched
35
+ if grep -q "s\.ios\.deployment_target" "$PODSPEC_PATH" || grep -q "s\.macos\.deployment_target" "$PODSPEC_PATH"; then
36
+ echo "$SCRIPT_NAME NitroModules.podspec already using standard syntax"
37
+ exit 0
38
+ fi
39
+
40
+ # Check if has the old syntax
41
+ if ! grep -q "s\.platforms" "$PODSPEC_PATH"; then
42
+ echo "$SCRIPT_NAME NitroModules.podspec format not recognized, skipping patch"
43
+ exit 0
44
+ fi
45
+
46
+ # Create the replacement
47
+ NEW_SYNTAX="s.ios.deployment_target = min_ios_version_supported
48
+ s.macos.deployment_target = '13.0'
49
+ s.tvos.deployment_target = '13.4'
50
+ s.visionos.deployment_target = '1.0'"
51
+
52
+ # Use sed to replace the s.platforms = {...} block
53
+ # This handles multiline replacement
54
+ sed -i.bak '/s\.platforms.*=.*{/,/}/c\
55
+ s.ios.deployment_target = min_ios_version_supported\
56
+ s.macos.deployment_target = '"'"'13.0'"'"'\
57
+ s.tvos.deployment_target = '"'"'13.4'"'"'\
58
+ s.visionos.deployment_target = '"'"'1.0'"'"'' "$PODSPEC_PATH"
59
+
60
+ # Remove backup file
61
+ rm -f "${PODSPEC_PATH}.bak"
62
+
63
+ echo "$SCRIPT_NAME ✓ Patched NitroModules.podspec deployment targets"
@@ -0,0 +1,190 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Get script directory and calculate paths
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ PACKAGE_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
7
+ REPO_ROOT="$(cd "${PACKAGE_DIR}/../../.." && pwd)"
8
+ APPLE_DIR="${PACKAGE_DIR}/apple"
9
+
10
+ # Deployment targets
11
+ IOS_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET:-13.4}"
12
+ MACOS_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET:-10.13}"
13
+
14
+ # Directories to clean before packing (native build artifacts only, not lib/)
15
+ DIRS_TO_CLEAN=(
16
+ "android/build"
17
+ "android/.cxx"
18
+ "android/.gradle"
19
+ "apple/build"
20
+ )
21
+
22
+ # Directories/files to copy from repo root
23
+ ITEMS_TO_COPY=(
24
+ "simpleble"
25
+ "simpledroidbridge"
26
+ "cmake"
27
+ "dependencies"
28
+ "VERSION"
29
+ )
30
+
31
+ echo "Preparing package for npm publish..."
32
+ echo "Package dir: ${PACKAGE_DIR}"
33
+ echo "Repo root: ${REPO_ROOT}"
34
+
35
+ # Clean build artifacts first
36
+ echo ""
37
+ echo "Cleaning build artifacts..."
38
+ for dir in "${DIRS_TO_CLEAN[@]}"; do
39
+ dir_path="${PACKAGE_DIR}/${dir}"
40
+ if [ -d "${dir_path}" ]; then
41
+ rm -rf "${dir_path}"
42
+ echo "✓ Cleaned: ${dir}"
43
+ fi
44
+ done
45
+ echo ""
46
+
47
+ # Copy items from repo root
48
+ for item in "${ITEMS_TO_COPY[@]}"; do
49
+ src="${REPO_ROOT}/${item}"
50
+ dest="${PACKAGE_DIR}/${item}"
51
+
52
+ if [ ! -e "${src}" ]; then
53
+ echo "Warning: ${src} does not exist, skipping..."
54
+ continue
55
+ fi
56
+
57
+ # Remove existing copy if it exists
58
+ if [ -e "${dest}" ]; then
59
+ rm -rf "${dest}"
60
+ fi
61
+
62
+ # Copy directory or file
63
+ if [ -d "${src}" ]; then
64
+ cp -R "${src}" "${dest}"
65
+ echo "✓ Copied directory: ${item}"
66
+ else
67
+ cp "${src}" "${dest}"
68
+ echo "✓ Copied file: ${item}"
69
+ fi
70
+ done
71
+
72
+ # =============================================================================
73
+ # Build SimpleBLE XCFramework for iOS and macOS
74
+ # =============================================================================
75
+
76
+ echo ""
77
+ echo "Building SimpleBLE XCFramework..."
78
+ echo "iOS deployment target: ${IOS_DEPLOYMENT_TARGET}"
79
+ echo "macOS deployment target: ${MACOS_DEPLOYMENT_TARGET}"
80
+
81
+ # Build for iOS platforms (iphoneos, iphonesimulator)
82
+ build_for_ios_platform() {
83
+ local PLATFORM=$1 # iphoneos or iphonesimulator
84
+ local ARCH=$2 # arm64 or x86_64
85
+
86
+ local BUILD_DIR="${APPLE_DIR}/build_${PLATFORM}_${ARCH}"
87
+ local INSTALL_DIR="${APPLE_DIR}/simpleble_${PLATFORM}_${ARCH}"
88
+
89
+ echo ""
90
+ echo "Building SimpleBLE for ${PLATFORM} (${ARCH})..."
91
+
92
+ cmake -B "${BUILD_DIR}" -S "${APPLE_DIR}" \
93
+ -DCMAKE_BUILD_TYPE=Release \
94
+ -DCMAKE_SYSTEM_NAME=iOS \
95
+ -DCMAKE_OSX_SYSROOT="${PLATFORM}" \
96
+ -DCMAKE_OSX_ARCHITECTURES="${ARCH}" \
97
+ -DCMAKE_OSX_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET}" \
98
+ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
99
+ -DBUILD_SHARED_LIBS=OFF \
100
+ -DSIMPLEBLE_EXCLUDE_C=ON
101
+
102
+ cmake --build "${BUILD_DIR}" --config Release --parallel
103
+ cmake --install "${BUILD_DIR}" --config Release
104
+
105
+ echo "Installed to ${INSTALL_DIR}"
106
+ }
107
+
108
+ # Build for macOS platforms
109
+ build_for_macos_platform() {
110
+ local ARCH=$1 # arm64 or x86_64
111
+
112
+ local BUILD_DIR="${APPLE_DIR}/build_macosx_${ARCH}"
113
+ local INSTALL_DIR="${APPLE_DIR}/simpleble_macosx_${ARCH}"
114
+
115
+ echo ""
116
+ echo "Building SimpleBLE for macOS (${ARCH})..."
117
+
118
+ cmake -B "${BUILD_DIR}" -S "${APPLE_DIR}" \
119
+ -DCMAKE_BUILD_TYPE=Release \
120
+ -DCMAKE_SYSTEM_NAME=Darwin \
121
+ -DCMAKE_OSX_SYSROOT="macosx" \
122
+ -DCMAKE_OSX_ARCHITECTURES="${ARCH}" \
123
+ -DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET}" \
124
+ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
125
+ -DBUILD_SHARED_LIBS=OFF \
126
+ -DSIMPLEBLE_EXCLUDE_C=ON
127
+
128
+ cmake --build "${BUILD_DIR}" --config Release --parallel
129
+ cmake --install "${BUILD_DIR}" --config Release
130
+
131
+ echo "Installed to ${INSTALL_DIR}"
132
+ }
133
+
134
+ # Build for iOS device
135
+ build_for_ios_platform "iphoneos" "arm64"
136
+
137
+ # Build for iOS simulator (Apple Silicon)
138
+ build_for_ios_platform "iphonesimulator" "arm64"
139
+
140
+ # Build for macOS (Apple Silicon)
141
+ build_for_macos_platform "arm64"
142
+
143
+ # Build for macOS (Intel)
144
+ build_for_macos_platform "x86_64"
145
+
146
+ # Create universal macOS library
147
+ echo ""
148
+ echo "Creating universal macOS library..."
149
+ MACOS_UNIVERSAL_DIR="${APPLE_DIR}/simpleble_macosx_universal"
150
+ mkdir -p "${MACOS_UNIVERSAL_DIR}/lib"
151
+ cp -r "${APPLE_DIR}/simpleble_macosx_arm64/include" "${MACOS_UNIVERSAL_DIR}/"
152
+ lipo -create \
153
+ "${APPLE_DIR}/simpleble_macosx_arm64/lib/libsimpleble.a" \
154
+ "${APPLE_DIR}/simpleble_macosx_x86_64/lib/libsimpleble.a" \
155
+ -output "${MACOS_UNIVERSAL_DIR}/lib/libsimpleble.a"
156
+
157
+ # Create XCFramework from the static libraries (iOS + macOS)
158
+ echo ""
159
+ echo "Creating XCFramework..."
160
+ XCFRAMEWORK_PATH="${APPLE_DIR}/SimpleBLE.xcframework"
161
+ rm -rf "${XCFRAMEWORK_PATH}"
162
+
163
+ xcodebuild -create-xcframework \
164
+ -library "${APPLE_DIR}/simpleble_iphoneos_arm64/lib/libsimpleble.a" \
165
+ -headers "${APPLE_DIR}/simpleble_iphoneos_arm64/include" \
166
+ -library "${APPLE_DIR}/simpleble_iphonesimulator_arm64/lib/libsimpleble.a" \
167
+ -headers "${APPLE_DIR}/simpleble_iphonesimulator_arm64/include" \
168
+ -library "${MACOS_UNIVERSAL_DIR}/lib/libsimpleble.a" \
169
+ -headers "${MACOS_UNIVERSAL_DIR}/include" \
170
+ -output "${XCFRAMEWORK_PATH}"
171
+
172
+ echo ""
173
+ echo "SimpleBLE build complete!"
174
+ echo "XCFramework created at: ${XCFRAMEWORK_PATH}"
175
+
176
+ # Clean up intermediate build directories to reduce package size
177
+ echo ""
178
+ echo "Cleaning up intermediate build directories..."
179
+ rm -rf "${APPLE_DIR}/build_iphoneos_arm64"
180
+ rm -rf "${APPLE_DIR}/build_iphonesimulator_arm64"
181
+ rm -rf "${APPLE_DIR}/build_macosx_arm64"
182
+ rm -rf "${APPLE_DIR}/build_macosx_x86_64"
183
+ rm -rf "${APPLE_DIR}/simpleble_iphoneos_arm64"
184
+ rm -rf "${APPLE_DIR}/simpleble_iphonesimulator_arm64"
185
+ rm -rf "${APPLE_DIR}/simpleble_macosx_arm64"
186
+ rm -rf "${APPLE_DIR}/simpleble_macosx_x86_64"
187
+ rm -rf "${APPLE_DIR}/simpleble_macosx_universal"
188
+
189
+ echo ""
190
+ echo "Package preparation complete!"