question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] add () to forward @autoclosure parameter

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

13reactions
petrbelacommented, Apr 21, 2019

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
1reaction
stepanstepancommented, May 10, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swift 5 Issue: "Add () to forward @autoclosure parameter" #155
Successfully merging a pull request may close this issue. Fix compilation error in Swift 5 mode Rightpoint/Swiftilities. 1 participant.
Read more >
swift - Closure forwarding without evaluating - Stack Overflow
debug) , but xcode gives me an error: Add () to forward @autoclosure parameter . Will my code above evaluate the closure inside...
Read more >
How to Use Autoclosures and @autoclosure in Swift 3
The first parameter is of type () -> String , a closure that accepts no arguments and returns a string. And the parameter...
Read more >
autoclosure in Swift: Simplify Closure Calls [Examples]
In Swift, an autoclosure lets you omit curly braces from a closure. ... The function example expects a closure of type () ->...
Read more >
Using @autoclosure when designing Swift APIs
Swift's @autoclosure attribute enables us to define an argument that automatically gets wrapped in a closure. It's primarily used to defer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found