iOS 14 gives "OS Error: Bad file descriptor, errno = 9" when doing local network broadcasting - flutter

Doing a little Jeopardy style Q&A here.
I'm developing an app in Flutter that uses the udp package for broadcasting on the local network. This has worked fine on Android, Windows, macOS and iOS until I tried on an iOS 14.6 device.
The code flow is mainly like this:
var endPoint = Endpoint.broadcast(port: Port(6000));
var udpFuture = UDP.bind(Endpoint.any(port: Port(6000)));
udpFuture.then((udp) {
udp.listen((datagram) {
handleMessage(datagram.data);
});
udp.send(bytesToSend, endPoint);
}
The error message I'm getting is this: Unhandled Exception: OS Error: Bad file descriptor, errno = 9

Starting from iOS 14 your app needs the Multicast networking entitlement com.apple.developer.networking.multicast to be able to send or receive IP multicast traffic.
To get the entitlement you need to apply using Apple's request form. It took me 4-5 days before I got the request approved.
Then you can follow the instructions on Apple's forums to get up and running.

Related

MoPub for iOS: 'Target is not running or required target entitlement is missing'

I'm trying to monetize my app with MoPub for iOS 14, but my ad is not being shown and I get the following messages in the logs when trying to display an ad:
Initialized OM SDK version: 1.3.4-Mopub
Attempting to load ad
[assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
[ProcessSuspension] 0x10b0b8bc0 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 18829, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
SDK initialized and ready to display ads.
Initialized adapters:
No adapters initialized
Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
In my AppDelegate's application(_: didFinishLaunchingWithOptions:) function, I have the following:
let sdkConfig = MPMoPubConfiguration(adUnitIdForAppInitialization: "TestAdUnitID")
sdkConfig.loggingLevel = .info
MoPub.sharedInstance().initializeSdk(with: sdkConfig, completion:{
GameViewController().showAd()
})
I have a view controller that adheres to the MPAdViewDelegate protocol and loads the ad like this, after the SDK has finished initializing:
self.moPubBannerView = MPAdView.init(adUnitId: "TestAdUnitID")
let adSize = kMPPresetMaxAdSize50Height
let bounds = view.bounds
var adFrame = CGRect.zero
adFrame.size = CGSize(width: 320, height: 50)
adFrame.origin.x = (bounds.size.width-adFrame.size.width)/2
adFrame.origin.y = bounds.size.height - adFrame.size.height
self.moPubBannerView?.frame = adFrame
self.moPubBannerView?.maxAdSize = adSize
self.moPubBannerView?.delegate = self
self.view.addSubview(self.moPubBannerView!)
self.moPubBannerView?.loadAd()
I have set Privacy - Tracking Usage Description in my info.plist. I'm testing on a real device, using the correct MoPub SDK.
Any idea what could be causing this error, and how to fix it? Thank you for your help!
EDIT:
Initially, I had integrated the MoPub SDK manually -- but I tried integrating using cocoa pods, too, and received the same errors/problems.
EDIT #2:
MoPub responded to my support request by telling me that I need to include an entitlement, without telling me which entitlement I need. So, I know I'm missing an entitlement, I just need to know which one.
EDIT #3:
I tried a different advertisement provider's framework and ran into the same error. So, it must be my problem -- not MoPub's. I tried enabling the Access WiFi Information capability (and confirmed that it was added to my App.entitlements) and I also added App Transport Security Settings -> Allow Arbitrary Loads to my Info.plist. But the problem remains.

Flutter - Socket.Connect() - SocketException: OS Error: Connection timed out

When I was working on debug mode (with "flutter run") by using my device (real), Socket.Connect() method doesn't work.
Also I would like to say that this Connect method is in "dart:io" library.
In shortly;
I opened a server (TCP) with Python.
I wrote the Flutter client like below to be able to connecting to the server in Python.
Future den() async {
print("Started");
Socket sock = await Socket.connect("192.168.0.159", 5431);
print("Done +++++++++++++++++++++++++"); }
However, I took a SocketError as Connection time out.
The error message I took:
E/flutter (17655): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.0.159, port = 43836
NOTE:
I tried to change the manifest file by adding INTERNET permission, but it is not working.
It was a strange problem, because there is no problem the code I shared. Windows Defender performed a rule to block to open a port as server. Hence, I started the server on my machine, however, I couldn't connect it from my Android device.
Maybe, the error code that is shown by Flutter isn't clear. If you took a error about socket programming for connection or binding, looking to Defender (or firewall) can be affective method. Unfortunately, as I was just starting to learn Flutter, I thought of checking out Defender afterwards.

iOS Network Extension error creating TUN/TAP interface SIOCGIFMTU failed: device not configured

Currently working on a Network Extension that lets me stablish a connection using a VPN using a .ovpn file, by using OpenVPNAdapter library. I have saved correcly my configuration to the System settings and when running the extension to perform debug my extension status changes from disconnected, stays in connecting for a while and then disconnects. Further inspecting the console logs for the device anf filtering by the network extension I get three main error messages.
Log message from provider: TUN Error: cannot acquire tun interface socket
SIOCGIFMTU failed: Device not configured
NEVirtualInterfaceAdjustReadBufferSize: interface_get_mtu failed (6), defaulting to max mtu
I don't know where to head now as I am debugging the network extension using the Console from the device.
Okay I managed to solve this on my own. I created a Packet Tunnel Network Extension and in my PacketTunnelProvider class came the problems. It did not crash so setting up the debugger in that class was not worth it. I ran my target and started my app and set several NSLogs in the functions so I could see in the device's console what was happening. My problem was that I tried to set a nil value in a dictionary for a key thus terminating the extension. That crash message can easily be seen in the console.
The problem was when extending PacketTunnelProvider with OpenVPNAdapterDelegate in the function to configure the tunnel
func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, configureTunnelWithNetworkSettings networkSettings: NEPacketTunnelNetworkSettings?, completionHandler: #escaping (OpenVPNAdapterPacketFlow?) -> Void) {
networkSettings?.dnsSettings?.matchDomains = [""];
}
Previously I had networkSettings.dnsSettings?.matchDomains = [""]; so networkSettings was unwrapped and it was nil making it crash the extension and the tunnel not being able to get connected.

Gettng Error WLClient onInvokeProcedureFailure:userInfo in WLClient.m

We are getting below error while calling a simple HTTP Adaptor through iOS Apple Watch OS1. We have mobilefirst 6.3 with WorklightAPI iOS deployed on server.
[WL_CLIENT] -[WLClient onInvokeProcedureFailure:userInfo:] in WLClient.m
Status: 0
InvocationResult: (null)
InvocationContext: (null)
Error code: 3
Error message: Procedure invocation error.
It runs fine when we run it on development server. Only difference we see is on Test server TLSv1.2 is enabled while on development it is not.
We defined ATS --> Allow Arbitrary Loads = YES in info.plist
but we are still getting an error.
Any Advice ?
As mentioned multiple times, Apple Watch is not supported. And in any case, since this is Watch OS 1 it means you invoke the code from the "parent" iOS app, no? In which case this was answered in your other question: https://stackoverflow.com/questions/34206002/there-is-no-registered-challenge-handler

Trying to send an email through an iphone app and getting an error using MFMailComposeViewController in iOS 8

I imported the MessageUI.h class and implemented the function in MFMailComposeViewControllerDelegate.
I was following the tutorial on : http://www.appcoda.com/ios-programming-101-send-email-iphone-app/
I am currently using Xcode 6.0.1 and iOS SDK 8.0 to build and run the app on the simulator. The issue is:
On running the app in the simulator, I get the following error
2014-09-26 03:39:07.687 SendMessage[44465:2674263] Mail cancelled
2014-09-26 03:39:07.743 SendMessage[44465:2673753] viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7fe873e01d30 {Message=Service Connection Interrupted}
2014-09-26 03:39:25.172 SendMessage[44465:2674263] <MFMailComposeRemoteViewController: 0x7fe873c389e0> timed out waiting for fence barrier from com.apple.MailCompositionService
Any suggestions on what should be done to get this working?
This is a known error in the simulator. It does not appear when you run on a device. So, try it on a device and if it runs normally, then you should be ok.