How to install react-native-track-player
我尝试在裸机(仅是react-native init)应用中安装react-native-track-player。
之后
1 2 3 4 | yarn add react-native-track-player yarn add react-native-swift cd ios pod instal |
我收到消息:
-
[!] CocoaPods找不到Pod" react-native-track-player"兼容版本:
在Podfile中:
react-native-track-player(来自../node_modules/react-native-track-player )
找到满足react-native-track-player (from ../ node_modules / react-native-track-player) 依赖性的规范,但它们需要更高的最低部署目标。
所以我更改了podfile
1 | platform :ios, '9.0' to: platform :ios, '10.0' |
再一次
1 | pod install |
这导致出现消息:
-
[!]无法确定以下Pod的Swift版本:
react-native-track-player 没有指定Swift版本,并且集成它的目标(mist )都没有设置SWIFT_VERSION 属性。请与作者联系或在集成此pod的至少一个目标中设置SWIFT_VERSION 属性。
下一步,我将s.swift_version ='4.0'添加到node_modules中的react-native-track-player.podspec文件中。
现在,react-native-track-player pod发出警告:
- [!] [Xcodeproj]生成了重复的UUID:
1 2 3 4 5 6 7 8 9 10 11 12 13 | PBXBuildFile -- Pods.xcodeproj/targets/buildConfigurationList:buildConfigurations:baseConfigurationReference:|,buildSettings:|,displayName:|,isa:|,name:|,,baseConfigurationReference:|,buildSettings:|,displayName:|,isa:|,name:|,,defaultConfigurationIsVisible:0,defaultConfigurationName:Release,displayName:ConfigurationList,isa:XCConfigurationList,,buildPhases:buildActionMask:2147483647,displayName:Headers,files:|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,isa:PBXHeadersBuildPhase,runOnlyForDeploymentPostprocessing:0,,buildActionMask:2147483647,displayName:Sources,files:|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,|,isa:PBXSourcesBuildPhase,runOnlyForDeploymentPostprocessing:0,,buildActionMask:2147483647,displayName:Frameworks,files:,isa:PBXFrameworksBuildPhase,runOnlyForDeploymentPostprocessing:0,,buildActionMask:2147483647,displayName:Copy generated compatibility header,files:,inputFileListPaths:,inputPaths:|,|,|,isa:PBXShellScriptBuildPhase,name:Copy generated compatibility header,outputFileListPaths:,outputPaths:|,|,|,runOnlyForDeploymentPostprocessing:0,shellPath:/bin/sh,shellScript:COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h" MODULE_MAP_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap" ditto"${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h""${COMPATIBILITY_HEADER_PATH}" ditto"${PODS_ROOT}/Headers/Public/react_native_track_player/react-native-track-player.modulemap""${MODULE_MAP_PATH}" ditto"${PODS_ROOT}/Headers/Public/react_native_track_player/react-native-track-player-umbrella.h""${BUILT_PRODUCTS_DIR}" printf"\ \ module ${PRODUCT_MODULE_NAME}.Swift {\ header "${COMPATIBILITY_HEADER_PATH}"\ requires objc\ }\ ">>"${MODULE_MAP_PATH}" ,,buildRules:,dependencies:displayName:React,isa:PBXTargetDependency,,displayName:react-native-track-player,isa:PBXNativeTarget,name:react-native-track-player,packageProductDependencies:,productName:react-native-track-player,productReference:displayName:libreact-native-track-player.a,explicitFileType:archive.ar,includeInIndex:0,isa:PBXFileReference,name:libreact-native-track-player.a,path:libreact-native-track-player.a,sourceTree:BUILT_PRODUCTS_DIR,,productType:com.apple.product-type.l ............ |
因此我在Podfile中添加了" install!'cocoapods',:deterministic_uuids => false"
现在pod安装可以在没有警告的情况下运行,但是xcode或react-native run-ios中的构建因错误而崩溃
- 命令CompileSwiftSources失败,退出代码非零
这是我的配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | System: OS: macOS 10.15.3 CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz Memory: 68.81 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.8.0 - /usr/local/bin/node Yarn: 1.22.0 - /usr/local/bin/yarn npm: 6.13.7 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.3 System Images: android-28 | Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom IDEs: Android Studio: 3.6 AI-192.7142.36.36.6200805 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: ^16.12.0 => 16.12.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: react-native-cli: 2.0.1 |
和packages.json文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | { "name":"first", "version":"0.0.1", "private": true, "scripts": { "android":"react-native run-android", "ios":"react-native run-ios", "start":"react-native start", "test":"jest", "lint":"eslint ." }, "dependencies": { "react":"16.9.0", "react-native":"0.61.5", "react-native-swift":"^1.2.2", "react-native-track-player":"^1.2.2" }, "devDependencies": { "@babel/core":"^7.8.4", "@babel/runtime":"^7.8.4", "@react-native-community/eslint-config":"^0.0.7", "babel-jest":"^25.1.0", "eslint":"^6.8.0", "jest":"^25.1.0", "metro-react-native-babel-preset":"^0.58.0", "react-test-renderer":"16.9.0" }, "jest": { "preset":"react-native" } } |
和ios / podfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | platform :ios, '10.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' install! 'cocoapods', :deterministic_uuids => false use_frameworks! target 'neu' do # Pods for neu pod 'FBLazyVector', :path =>"../node_modules/react-native/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path =>"../node_modules/react-native/Libraries/FBReactNativeSpec" pod 'RCTRequired', :path =>"../node_modules/react-native/Libraries/RCTRequired" pod 'RCTTypeSafety', :path =>"../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' pod 'React-Core', :path => '../node_modules/react-native/' pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/' pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' pod 'ReactCommon/jscallinvoker', :path =>"../node_modules/react-native/ReactCommon" pod 'ReactCommon/turbomodule/core', :path =>"../node_modules/react-native/ReactCommon" pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga' pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' target 'neuTests' do inherit! :search_paths # Pods for testing end use_native_modules! end target 'neu-tvOS' do # Pods for neu-tvOS target 'neu-tvOSTests' do inherit! :search_paths # Pods for testing end end |
我受困了!任何想法有什么问题吗?
对于React Native版本
运行
这些附加步骤必须完成,因为模块的iOS部分是用Swift而不是Objective-C编写的。而且React Native不支持开箱即用Swift编写的桥接模块。
但是对于大于