react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

Compile fails in Swift 5.5 and Xcode beta

Open bostnis opened this issue 5 years ago • 16 comments

I am running the latest version - 2.0.2 I've installed xcode 13 beta and tried to compile the project which includes react-native-ble-plx@^2.0.2 and the build constantly fails due to MultiplatformBleAdapter Pods dependency.

I could see there was already PR in this link - https://github.com/dotintent/MultiPlatformBleAdapter/pull/80

It would be great if you can merge this PR and publish new version. Warm Regards

bostnis avatar Jul 27 '21 08:07 bostnis

Can you tell any other way possible to run without these changes in ios 15 device as application is not able to run in ios 15 or can you tell when new version would come with these changes.

aditya23jaitly avatar Sep 21 '21 07:09 aditya23jaitly

Does somebody have a patch-package in place? I can't get it to run.

JaapWeijland avatar Sep 21 '21 12:09 JaapWeijland

I'd really love to see this fixed, either by a patch-package or a new version released

As a work around i downloaded the version 12.5.1 of xCode

arelstone avatar Sep 22 '21 05:09 arelstone

Source

For the time being, issue can be fixed by making the following changes to your Pods.

⚠️ Temporary fix and should be made every time pod-install is called!

Pods/MultiplatformBleAdapter/RestoredState.swift line: 68

peripheral: RxCBPeripheral(peripheral: $0.service.peripheral))

to

peripheral: RxCBPeripheral(peripheral: $0.service.peripheral!))

Pods/MultiplatformBleAdapter/RxCBCharacteristic.swift line: 59

return RxCBService(service: characteristic.service)

to

return RxCBService(service: characteristic.service!)

Pods/MultiplatformBleAdapter/RcCBDescriptor line: 43

return RxCBCharacteristic(characteristic: descriptor.characteristic)

to

return RxCBCharacteristic(characteristic: descriptor.characteristic!)

Tadejo9 avatar Sep 22 '21 07:09 Tadejo9

If you prefer doing this by patch-package, you need two changes. Firstly, the following patch to be made by patch-packages:

diff --git a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
index def210f..91c6eca 100644
--- a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
+++ b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
   s.compiler_flags = '-DMULTIPLATFORM_BLE_ADAPTER'
 
   s.dependency 'React'
-  s.dependency 'MultiplatformBleAdapter', '0.1.7'
+  s.dependency 'MultiplatformBleAdapter', '0.1.8'
 end

Then change your Podfile (once) as follows:

+  # Force update to MultiplatformBleAdapter for iOS 15 SDK
+  pod 'MultiplatformBleAdapter', git: "https://github.com/dotintent/MultiPlatformBleAdapter", commit: "669e438acb384eee74f3f1ada3ba259cf7b7965b"

Obviously, usual caveats around using unreleased software apply. Very much a hack - thanks Apple for the breaking changes.

ball-hayden avatar Sep 22 '21 07:09 ball-hayden

@ball-hayden Thanks for your response. I did that as well but cocoapods is not picking up the reference to the branch correctly, so it's just installing v0.1.8.

JaapWeijland avatar Sep 22 '21 08:09 JaapWeijland

If you prefer doing this by patch-package, you need two changes. Firstly, the following patch to be made by patch-packages:

diff --git a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
index def210f..91c6eca 100644
--- a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
+++ b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
   s.compiler_flags = '-DMULTIPLATFORM_BLE_ADAPTER'
 
   s.dependency 'React'
-  s.dependency 'MultiplatformBleAdapter', '0.1.7'
+  s.dependency 'MultiplatformBleAdapter', '0.1.8'
 end

Then change your Podfile (once) as follows:

+  # Force update to MultiplatformBleAdapter for iOS 15 SDK
+  pod 'MultiplatformBleAdapter', git: "https://github.com/dotintent/MultiPlatformBleAdapter", commit: "669e438acb384eee74f3f1ada3ba259cf7b7965b"

Obviously, usual caveats around using unreleased software apply. Very much a hack - thanks Apple for the breaking changes.

Will this be compatible with older versions of xCode too?

arelstone avatar Sep 22 '21 08:09 arelstone

MultiplatformBleAdapter has one merge request which should increase version of this dependency to 0.1.9 https://github.com/dotintent/MultiPlatformBleAdapter/pull/84

This is the issue with iOS15 CoreBluetooth https://github.com/dotintent/MultiPlatformBleAdapter/pull/80

zardazare avatar Sep 22 '21 08:09 zardazare

@JaapWeijland indeed. You need to also update your Podfile as I directed. A pod update MultiplatformBleAdapter should then behave.

@arelstone no idea.

ball-hayden avatar Sep 22 '21 09:09 ball-hayden

@ball-hayden Seems to be working with xCode 12.5.1 👏 Thanks a lot

arelstone avatar Sep 22 '21 09:09 arelstone

@ball-hayden I did exactly that, changing both the podspec and the Podfile. This is my patch-package:

diff --git a/node_modules/react-native-ble-plx/ios/Podfile b/node_modules/react-native-ble-plx/ios/Podfile
index b6d8923..982a6e9 100644
--- a/node_modules/react-native-ble-plx/ios/Podfile
+++ b/node_modules/react-native-ble-plx/ios/Podfile
@@ -6,5 +6,8 @@ target 'BleClient' do
   use_frameworks!
 
   # Pods for BleClient
-  pod 'MultiplatformBleAdapter', '~> 0.1.7'
+  # pod 'MultiplatformBleAdapter', '~> 0.1.7'
+  # Force update to MultiplatformBleAdapter for iOS 15 SDK
+  pod 'MultiplatformBleAdapter', git: "https://github.com/dotintent/MultiPlatformBleAdapter", commit: "669e438acb384eee74f3f1ada3ba259cf7b7965b"
+
 end
diff --git a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
index def210f..dc81e8b 100644
--- a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
+++ b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
   s.compiler_flags = '-DMULTIPLATFORM_BLE_ADAPTER'
 
   s.dependency 'React'
-  s.dependency 'MultiplatformBleAdapter', '0.1.7'
+  s.dependency 'MultiplatformBleAdapter', '0.1.8'
 end
\ No newline at end of file

Running pod install and pod update MultiplatformBleAdapter in ./ios does not seem to work even then. Am I overlooking something?

JaapWeijland avatar Sep 22 '21 10:09 JaapWeijland

@ball-hayden I did exactly that, changing both the podspec and the Podfile. This is my patch-package:

diff --git a/node_modules/react-native-ble-plx/ios/Podfile b/node_modules/react-native-ble-plx/ios/Podfile
index b6d8923..982a6e9 100644
--- a/node_modules/react-native-ble-plx/ios/Podfile
+++ b/node_modules/react-native-ble-plx/ios/Podfile
@@ -6,5 +6,8 @@ target 'BleClient' do
   use_frameworks!
 
   # Pods for BleClient
-  pod 'MultiplatformBleAdapter', '~> 0.1.7'
+  # pod 'MultiplatformBleAdapter', '~> 0.1.7'
+  # Force update to MultiplatformBleAdapter for iOS 15 SDK
+  pod 'MultiplatformBleAdapter', git: "https://github.com/dotintent/MultiPlatformBleAdapter", commit: "669e438acb384eee74f3f1ada3ba259cf7b7965b"
+
 end
diff --git a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
index def210f..dc81e8b 100644
--- a/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
+++ b/node_modules/react-native-ble-plx/react-native-ble-plx.podspec
@@ -17,5 +17,5 @@ Pod::Spec.new do |s|
   s.compiler_flags = '-DMULTIPLATFORM_BLE_ADAPTER'
 
   s.dependency 'React'
-  s.dependency 'MultiplatformBleAdapter', '0.1.7'
+  s.dependency 'MultiplatformBleAdapter', '0.1.8'
 end
\ No newline at end of file

Running pod install and pod update MultiplatformBleAdapter in ./ios does not seem to work even then. Am I overlooking something?

You should make the changes your own Podfile. It's located in the ios folder.

What I did to make it work:

  • Add pod 'MultiplatformBleAdapter', git: "https://github.com/dotintent/MultiPlatformBleAdapter", commit: "669e438acb384eee74f3f1ada3ba259cf7b7965b" to my Podfile
  • Add the patch file in ./patches
  • ran yarn patch-package
  • Profit

arelstone avatar Sep 22 '21 10:09 arelstone

Works! Thanks alot for the help!

JaapWeijland avatar Sep 22 '21 11:09 JaapWeijland

So as I understand it, we're just waiting on dotintent/MultiPlatformBleAdapter to make a release of their CoreBluetooth update before we can make a PR here?

mattahorton avatar Sep 22 '21 17:09 mattahorton

That is correct

JaapWeijland avatar Sep 22 '21 19:09 JaapWeijland

Hi ✋

This issue is already fixed in 2.0.3 💪 so I am gonna close this ticket

mciechanowicz avatar Dec 07 '21 15:12 mciechanowicz