React-native-ble-plx: [iOS] add () to forward @autoclosure parameter

Created on 21 Apr 2019  路  6Comments  路  Source: Polidea/react-native-ble-plx

Setup problem

Getting the following error when compiling.

/app/node_modules/react-native-ble-plx/ios/RxBluetoothKit/Logging.swift:90:38: error: add () to forward @autoclosure parameter
        log(with: .verbose, message: message)
                                     ^~~~~~~
                                            ()
/app/node_modules/react-native-ble-plx/ios/RxBluetoothKit/Logging.swift:94:36: error: add () to forward @autoclosure parameter
        log(with: .debug, message: message)
                                   ^~~~~~~
                                          ()
/app/node_modules/react-native-ble-plx/ios/RxBluetoothKit/Logging.swift:98:35: error: add () to forward @autoclosure parameter
        log(with: .info, message: message)
                                  ^~~~~~~
                                         ()
/app/node_modules/react-native-ble-plx/ios/RxBluetoothKit/Logging.swift:102:38: error: add () to forward @autoclosure parameter
        log(with: .warning, message: message)
                                     ^~~~~~~
                                            ()
/app/node_modules/react-native-ble-plx/ios/RxBluetoothKit/Logging.swift:106:36: error: add () to forward @autoclosure parameter
        log(with: .error, message: message)

Context

  • Library version: 1.0.3
  • Platform: iOS
  • Xcode: 10.2.1
  • CocoaPods
setup stale

Most helpful comment

The problem is Xcode now uses Swift 5.0 by default, which requires the @autoclosure tag. The proper solution is to migrate RxBluetoothKit to 5.0 (I think it's already underway in the source repo, just hasn't been ported to this package which has a separate copy of RxBluetoothKit).

For now, it can be fixed by specifying Swift 4.2 as the compiler for this package.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-ble-plx-swift'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.2'
      end
    end
  end
end

All 6 comments

The problem is Xcode now uses Swift 5.0 by default, which requires the @autoclosure tag. The proper solution is to migrate RxBluetoothKit to 5.0 (I think it's already underway in the source repo, just hasn't been ported to this package which has a separate copy of RxBluetoothKit).

For now, it can be fixed by specifying Swift 4.2 as the compiler for this package.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-ble-plx-swift'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.2'
      end
    end
  end
end

in my case app compiles with following code:

if target.pod_name == 'react-native-ble-plx-swift'
  target.native_target.build_configurations.each do |config|
    config.build_settings['SWIFT_VERSION'] = '4.2'
  end
end

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

In case anyone else ends up here, open your ios folder, open the Podfile, add the code provided by petrbela (thank you) to the bottom, then in a terminal switch to the ios folder and run the command 'pod install'

hi
where we have to use this?:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-ble-plx-swift'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.2'
      end
    end
  end
end

@amirhosein5858

Open your ios folder, find the 'Podfile' and add it to the bottom.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulclark94 picture paulclark94  路  3Comments

SlavaInstinctools picture SlavaInstinctools  路  4Comments

alfacommunication-alessandro picture alfacommunication-alessandro  路  4Comments

adyanced picture adyanced  路  5Comments

lenninlc picture lenninlc  路  3Comments