react-native-track-player: react native 0.60 swift errors

Installed 2.0.0-rc13 following the advice of this issue I tried adding the dummy.swift in the project but still getting 25 “Swift Compiler Error” below:

Configuration

Run react-native info in your project and share the content.

System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 152.69 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v8.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      API Levels: 19, 22, 23, 24, 25, 26, 27, 28
      Build Tools: 23.0.1, 23.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.0, 27.0.0, 27.0.3, 28.0.1, 28.0.3, 29.0.1
      System Images: android-19 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-25 | Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
      Android NDK: 19.0.5232133
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: ^0.60.4 => 0.60.4 
  npmGlobalPackages:
    react-native-cli: 2.0.1

Issue

Swift Compiler Error Group

node_modules/react-native-track-player/ios/RNTrackPlayer/Vendor/AudioPlayer/SwiftAudio/Classes/AudioSessionController/AudioSessionController.swift:104:70: 'interruptionNotification' has been renamed to 'NSNotification.Name.AVAudioSessionInterruption'

'interruptionNotification' has been renamed to 'NSNotification.Name.AVAudioSessionInterruption'

Type 'AVAudioSession' does not conform to protocol 'AudioSession'

react-native-track-player/ios/RNTrackPlayer/RNTrackPlayer.swift:157:57: Type 'AVAudioSession.Category' (aka 'NSString') has no member 'playback'

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Thanks @hbarylskyi ! I’ve had the same problem. However, I’ve found a better way to do this. Because the version is reset every time you run pod install, add new dependencies, or when you use some CI/CD where you can’t do that change.

Try this:

# ios/Podfile
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ['react-native-track-player'].include? target.name
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '5'
      end
    end
  end
end

Having the following error

[!] Unable to determine Swift version for the following pods:

- `react-native-track-player` does not specify a Swift version and none of the targets (`avid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

with @next version

Wich is fixed by patching the file react-native-track-player.podspec just adding

  s.swift_version = '5.0'

Finally fixed: Pods -> react-native-track-player -> ‘Swift Compiler - Language’ section -> select “Swift 5” from dropdown

I am getting similar errors CompileSwift normal x86_64 /Users/anton/Work/WebDev/PanathinaicStadium/node_modules/react-native-track-player/ios/RNTrackPlayer/Models/Capabilities.swift CompileSwift normal x86_64 /Users/anton/Work/WebDev/PanathinaicStadium/node_modules/react-native-track-player/ios/RNTrackPlayer/RNTrackPlayer.swift CompileSwift normal x86_64 /Users/anton/Work/WebDev/PanathinaicStadium/node_modules/react-native-track-player/ios/RNTrackPlayer/Models/Track.swift CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler