我想在Flutter中实现实时Socket.IO。我已经下载了Adhara套接字软件包,但它不能在iOS上工作,这使得我的构建在Android Studio和xCode上都失败了。库链接:https://pub.dev/packages/adhara_socket_io
下面是我的pubsec.yaml文件:
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
#Checkboxes Library
grouped_buttons: ^1.0.4
#Google Maps Library.
google_maps_flutter: ^0.5.28+1
#Flutter Map Picker
google_map_location_picker: ^3.3.3
#Flutter GeoLocator
geolocator: 5.3.2+2
#Flutter Permissions
permission: ^0.1.7
#Flutter Lottie Animations
lottie: ^0.5.1
#Flutter Inner Navigation Drawer
flutter_inner_drawer: ^0.5.6+1
#Flutter Native Navigation Drawer
drawerbehavior: ^1.0.3
#Flutter Numeric Keyboard
numeric_keyboard: ^1.0.0
#Flutter Curved Navigation Drawer
curved_navigation_bar: ^0.3.3
#Flutter BLOC
flutter_bloc: ^6.0.1
#Flutter EQUATABLE
equatable: ^1.0.2
#Flutter DIO
dio: ^3.0.9
#Json Serialization
json_annotation: ^3.0.1
#Flutter Validator
validators: ^2.0.0+1
#Flutter SharedPrefs
shared_preferences: ^0.5.8
#Flutter Poly Lines
flutter_polyline_points: ^0.2.2
#FLutter Location Library
location: ^2.3.5
#Flutter Map PolyLine
google_map_polyline:
#Flutter Google Fonts
google_fonts: ^1.1.0
#Flutter Progress Dialog
progress_dialog: ^1.2.4
#Flutter Toast
toast: ^0.1.5
#rxDart
rxdart: ^0.24.1
#GET NAVIGATOR
get: ^3.5.1
#FLUTTER OFFLINE
flutter_offline: "^0.3.0"
#FLUTTER WEB SOCKET
adhara_socket_io: ^0.4.2+1
dev_dependencies:
flutter_test:
sdk: flutter下面是我的包实现:
try{
SocketIOManager manager = SocketIOManager();
SocketIO socket = await manager.createInstance(SocketOptions('http://192.168.8.187:3000',nameSpace: '/',enableLogging: true,path: null)); //TODO change the port accordingly
socket.onConnect((data){
print("connected...");
});
// socket.on('test-channel:Socket', (data){ //sample event
// print("accessed channel");
// });
socket.connect();
socket.on('Driver.${9}:new_order', (data) {print("fuck");});
}
catch(e){
print(e.toString());
}颤动医生输出:
[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.6 19G2021, locale en)
• Flutter version 1.20.2 at /Users/mackbookpro/Downloads/flutter
• Framework revision bbfbf1770c (3 weeks ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/mackbookpro/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.3
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 48.1.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[!] IntelliJ IDEA Ultimate Edition (version 2020.1.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[!] VS Code (version 1.48.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• HD1901 (mobile) • b255e813 • android-arm64 • Android 10 (API 29)
• iPhone SE (2nd generation) (mobile) • 5402105E-CC55-4173-9598-64DEF04BB3B5 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)构建日志:
** BUILD FAILED **
Xcode's output:
↳
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:59:25: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
return try data.withUnsafeBytes { (bytes:UnsafePointer<UInt8>) -> Data in
^
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:29: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
^~~~~~~
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
^
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:33: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
^~~~~~~
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
^
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/Compression.swift:140:14: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
data.withUnsafeBytes { (ptr:UnsafePointer<UInt8>) -> Void in
^
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:282:30: warning: 'withUnsafeMutableBytes' is deprecated: use `withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R` instead
let _ = peerName.withUnsafeMutableBytes { (peerNamePtr: UnsafeMutablePointer<Int8>) in
^
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1326:14: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) }
^
/Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Starscream/Sources/Starscream/WebSocket.swift:1327:16: warning: 'init(bytes:)' is deprecated: use `init(_:)` instead
return Data(bytes: digest).base64EncodedString()
^
/Users/mackbookpro/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/adhara_socket_io-0.4.2+1/ios/Classes/AdharaSocket.swift:85:38: warning: expression implicitly coerced from 'String?' to 'Any'
"reqId": reqId
^~~~~
/Users/mackbookpro/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/adhara_socket_io-0.4.2+1/ios/Classes/AdharaSocket.swift:85:38: note: provide a default value to avoid this warning
"reqId": reqId
^~~~~
?? <#default value#>
/Users/mackbookpro/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/adhara_socket_io-0.4.2+1/ios/Classes/AdharaSocket.swift:85:38: note: force-unwrap the value to avoid this warning
"reqId": reqId
^~~~~
!
/Users/mackbookpro/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/adhara_socket_io-0.4.2+1/ios/Classes/AdharaSocket.swift:85:38: note: explicitly cast to 'Any' with 'as Any' to silence this warning
"reqId": reqId
^~~~~
as Any
/Users/mackbookpro/Library/Developer/Xcode/DerivedData/Runner-eubpodhclpglohfjgqiizvunrhxh/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Script-8260F2EAAE9F274664AABFD4.sh: line 2: /Users/mackbookpro/Desktop/Tiger Taxi/new_tiger_driver/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh: Permission denied
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description有没有希望解决这个问题:'(
发布于 2021-02-11 12:04:24
我修复了这个问题,将命名空间参数设置为"/“而不是null,因为在swift库中它是不可空的,这就是导致我这个问题的原因。快乐的编码社区!
https://stackoverflow.com/questions/63704342
复制相似问题