Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example iOS app doesn't build - due to missing file? (Cannot find type 'Communications_PbPFtpOperation' in scope) #481

Open
2 of 10 tasks
chrispreee opened this issue Aug 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@chrispreee
Copy link

chrispreee commented Aug 14, 2024

Platform on which you observed the bug:

  • Android
  • iOS
  • Other
  • Platform is not relevant for this bug

Device on which you observed the bug:

  • Polar OH1
  • Polar Verity Sense
  • Polar H10
  • Polar H9
  • Other
  • Device is not relevant for this bug

Describe the bug

  1. I cloned the Polar SDK repo
  2. I ran pod install in the root of the example iOS project polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/
  3. I opened the project in XCode and clicked build

The build fails with: "Cannot find type 'Communications_PbPFtpOperation' in scope"

How to Reproduce
I have done this from a fresh clone.

Prior to the above, I had set up XCode and run:

brew install swift-protobuf
sudo gem install cocoapods
pod setup
pod repo update
arch -x86_64 pod install

I am not aware of anything else out of the ordinary. I am running XCode 15.4 on an M1.

protoc and protoc-gen-swift seem to be installed OK and on my PATH. I tried adding SwiftProtoBuf to the project dependencies. I also tried the steps on the SwiftProtobuf github readme at https://github.com/apple/swift-protobuf . Tried restarting etc. Build still broken.

My Podfile.lock contains:

PODS:
  - PolarBleSdk (5.5.0):
    - RxSwift (~> 6.5.0)
    - SwiftProtobuf (~> 1.0)
  - RxSwift (6.5.0)
  - SwiftProtobuf (1.23.0)

DEPENDENCIES:
  - PolarBleSdk (= 5.5.0)

SPEC REPOS:
  https://github.com/CocoaPods/Specs.git:
    - PolarBleSdk
    - RxSwift
    - SwiftProtobuf

SPEC CHECKSUMS:
  PolarBleSdk: 2551160f3dcba0207723fc466a275e2d3aeda01f
  RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
  SwiftProtobuf: b70d65f419fbfe61a2d58003456ca5da58e337d6

PODFILE CHECKSUM: aa65d965a6f6e7d086dc200b60385c49e57e8f2e

COCOAPODS: 1.15.2

If I unlock the files (which are locked as they are part of the SDK, not part of the example app), and replace both occurrences of Communications_PbPFtpOperation with Protocol_PbPFtpOperation, the project builds and runs. I haven't got far enough to see whether it works, but this seems unlikely to be the solution, as surely someone would have noticed a critical build error in the SDK before me?

I also had to disable user script sandboxing in my project settings to enable rsync writing to .../Build/Products/Debug-iphonesimulator/iosBleSdkTestApp.app/Frameworks/PolarBleSdk.framework/_CodeSignature, as suggested here: https://stackoverflow.com/a/76626156/1308967 These are the lines I had to edit:

https://github.com/polarofficial/polar-ble-sdk/blob/master/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/protobuf/pftp_request.pb.swift#L190
https://github.com/polarofficial/polar-ble-sdk/blob/master/sources/iOS/ios-communications/Sources/iOSCommunications/ble/api/model/gatt/client/psftp/BlePsFtpClient.swift#L339

I have found the definition of Communications_PbPFtpOperation here:

iOS/ios-communications/Sources/iOSCommunications/ble/api/model/protobuf/communications_pftp_request.pb.swift

This suggests that some of the proto definitions have not been built as Swift, and I need to run protoc --swift_out=. my.proto myself. (This is done for you in the Gradle spec on the Android example app.) Copying this into the example app tree iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/iOSCommunications/ble/api/model/protobuf doesn't help, so even if I run protoc --swift_out=. *.proto I don't know what to do with the output.

Proto definitions seem to be homed in the Android app?

polar-ble-sdk/sources/Android/android-communications/library/src/main/proto/communications_pftp_request.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/act_samples.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/dailysummary.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/exercise_rr_samples.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/exercise_samples.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/google/protobuf/descriptor.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/nanopb.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/pftp_error.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/pftp_notification.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/pftp_request.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/pftp_response.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/sleepanalysisresult.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/structures.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/types.proto
polar-ble-sdk/sources/Android/android-communications/library/src/sdk/proto/user_physdata.proto
polar-ble-sdk/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/protobuf/types.proto

Update: I copied in the file to:

polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/iOSCommunications/ble/api/model/protobuf/communications_pftp_request.pb.swift

Then in XCode right-click on the PolarBleSdk Pod then add the file to the project, then it seems to build, although I am not sure if it works, or what else of the above was necessary.

Expected behavior
I expect the example project build.

Screenshots and logs

Full build log:

PolarBleSdk
...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/protobuf/pftp_request.pb.swift
...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/protobuf/pftp_request.pb.swift:190:11 Cannot find type 'Communications_PbPFtpOperation' in scope

...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/PolarBleApiImpl.swift
...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/PolarBleApiImpl.swift:1458:94 'PolarOhrData' is deprecated: renamed to 'PolarPpgData'

...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/PolarBleSdk/sdk/impl/PolarBleApiImpl.swift:1873:33 'PolarOhrData' is deprecated: renamed to 'PolarPpgData'

RxSwift
...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/Pods.xcodeproj The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.5.99.

SwiftProtobuf
...polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/Pods.xcodeproj The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.5.99.
@chrispreee chrispreee added the bug Something isn't working label Aug 14, 2024
@chrispreee chrispreee changed the title Example iOS app raises "Cannot find type 'Communications_PbPFtpOperation' in scope" Example iOS app doesn't build - due to missing file? (Cannot find type 'Communications_PbPFtpOperation' in scope) Aug 16, 2024
@ymatt345
Copy link

ymatt345 commented Sep 9, 2024

I am having the same issue with PolarBleSdk 5.7.0.
I hope this gets fixed soon.

@ymatt345
Copy link

ymatt345 commented Sep 9, 2024

PolarBleSdk 5.7.0 in Pods does not have Communications_PbPFtpOperation.pb.
However, polarBleSdk 5.4.0 in Pods has Communications_PbPFtpOperation.pb.
So Communications_PbPFtpOperation.pb might be missing from polarBleSdk 5.5.0 and later.
How can we include Communications_PbPFtpOperation.pb in polarBleSdk in Pods?
polarBleSdk5 4 0
polarBleSdk5 7 0

@chrispreee
Copy link
Author

chrispreee commented Sep 9, 2024

I copied in the file to:

polar-ble-sdk/examples/example-ios/iosBleSdkTestApp/Pods/PolarBleSdk/sources/iOS/ios-communications/Sources/iOSCommunications/ble/api/model/protobuf/communications_pftp_request.pb.swift

Then in XCode right-click on the PolarBleSdk Pod, then add the file to the project, then it seems to build, and successfully install and record. I have only tested it on an H10 recording ECG, ACC and HR overnight so far.

(For two nights it worked perfectly, on another two nights it stopped recording at some point in the night and only offered small recordings, battery fine on all nights, charging on all but one of the problem nights. I doubt these issues are related.)

I haven't created a PR because someone more experienced than I should confirm that this is all that needs doing or all that is missing. I don't know how packaging/linking works in XCode yet.

@ymatt345
Copy link

ymatt345 commented Sep 9, 2024

Okay, thank you. I'll try to fix it.
However, the bleSDK should be fixed by their developer.

@chrispreee
Copy link
Author

chrispreee commented Sep 9, 2024 via email

@hamletAppsfactory
Copy link

I also have the same issue, is there any solution yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants