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

Created on 22 Jul 2019  路  15Comments  路  Source: react-native-kit/react-native-track-player

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'

iOS

Most helpful comment

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

All 15 comments

Having the same issue. react-native 0.60.4, react-native-track-player 2.0.0-rc13

Finally fixed:
Pods -> react-native-track-player -> 'Swift Compiler - Language' section -> select "Swift 5" from dropdown

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

I am using this same hack of setting the SWIFT_VERSION to 5, but I still get the following Swift errors. Any thoughts?

The following build commands failed:
    CompileSwift normal x86_64 /Users/d/workspace/geofencing/node_modules/react-native-track-player/ios/RNTrackPlayer/Vendor/AudioPlayer/SwiftAudio/Classes/AudioSessionController/AudioSession.swift
    CompileSwift normal x86_64 /Users/d/workspace/geofencing/node_modules/react-native-track-player/ios/RNTrackPlayer/Vendor/AudioPlayer/SwiftAudio/Classes/AudioSessionController/AudioSessionController.swift
    CompileSwift normal x86_64 /Users/d/workspace/geofencing/node_modules/react-native-track-player/ios/RNTrackPlayer/Vendor/AudioPlayer/SwiftAudio/Classes/AVPlayerWrapper/AVPlayerWrapper.swift
    CompileSwift normal x86_64 /Users/d/workspace/geofencing/node_modules/react-native-track-player/ios/RNTrackPlayer/RNTrackPlayer.swift
    CompileSwift normal x86_64 /Users/d/workspace/geofencing/node_modules/react-native-track-player/ios/RNTrackPlayer/Models/SessionCategories.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(6 failures)

Reason for failure: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

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

I'm getting the exact same set of errors as @4nt0n

CompileSwift normal x86_64 /Users/blabel/WTBU-App/node_modules/react-native-track-player/ios/RNTrackPlayer/Models/Capabilities.swift
CompileSwift normal x86_64 /Users/blabel/WTBU-App/node_modules/react-native-track-player/ios/RNTrackPlayer/RNTrackPlayer.swift
CompileSwift normal x86_64 /Users/blabel/WTBU-App/node_modules/react-native-track-player/ios/RNTrackPlayer/Models/Track.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler

I can put the exact Swift errors but since they're all unrecognized type/uninitilized variable type stuff I think something's not being linked right or something. I've gone through all the steps so much though I don't know what more I can do.

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'

with 'react-native-track-player@next' I'm having the following error,

react-native-track-player does not specify a Swift version and none of the targets (app and app-tvOS) 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.

i've added @jvandenaardweg podfile code but the error persist

Same issue @ciseducarnet02, I already added the code snippet from @jvandenaardweg but the error still remains

@nenjamin2405, I resolve the issue adding s.swift_version = '5.0' on react-native-track-player.podspec in react-native-track-player node_module folder.
but the issue come back every time i use npm i, so on app center the app build keep failing

# 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

@ciseducarnet02 Use snippet above or use https://www.npmjs.com/package/patch-package to patch any node_module.

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

Good solution. Besides the version of swift, I also want to exclude a file to make app build successfully. Do you how to set "exclude_file" in Podfile?

//podspec:
s.exclude_files = ["ios/RNTrackPlayer/Vendor/AudioPlayer/Example"]

Thank you for your help.

# 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

@ciseducarnet02 Use snippet above or use https://www.npmjs.com/package/patch-package to patch any node_module.

Good solution. Besides the version of swift, I want to set "exclude_files" in Podfile. Do you how to do it?
//podspec:
s.exclude_files = ["ios/RNTrackPlayer/Vendor/AudioPlayer/Example"]

//Podfile: (try to set "exclude_files" in Podfile)
#config.build_settings['EXCLUDE_FILES'] = '../node_modules/react-native-track-player/ios/RNTrackPlayer/Vendor/AudioPlayer/Example'

image

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

Please can you explain how i can use this code

@allindeveloper that code goes in your main project Podfile.

swift_version is now in the podspec.

Was this page helpful?
0 / 5 - 0 ratings