On iOS 16 and below, the Apple logo is not displayed (Leagal labe is displayed).
On iOS 17, both logo and legal are displayed.
I have not specified layoutMergin for MKMapView.
Map View attribute inspector has specified standard settings
Why is only Apple Logo is not displayed ?
Thank you
Delve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am a developer based in Ireland. I updated an iPhone 12 to iOS18.1 Beta 4 in order to investigate the Call Record Feature. We have a VoIP App and I wanted to see if there is any interaction with this new Call Record feature. However there is no option appearing for me under Settings ->Apps->Phone for Call RECORD
My suspicion is that this is because I am in Europe and Apple Intelligence is not available here.
We have our Apps available in the USA so is there anyway that I can enable Call record for some testing.
Alternatively does anybody know if Call record should work with Callkit VoIP Apps?
Hello, I don't know much about AppleScript, but I found this script on a Raycast site that dismisses Notification Center notifications. It worked great on Sonoma but has stopped working in Sequoia. Here is the code:
tell application "System Events"
tell process "NotificationCenter"
if not (window "Notification Center" exists) then return
set alertGroups to groups of first UI element of first scroll area of first group of window "Notification Center"
repeat with aGroup in alertGroups
try
perform (first action of aGroup whose name contains "Close" or name contains "Clear")
on error errMsg
log errMsg
end try
end repeat
-- Show no message on success
return ""
end tell
end tell
When using this to attempt to dismiss notifications, it returns the following error:
Can’t get scroll area 1 of group 1 of window "Notification Center" of process "NotificationCenter". Invalid index. (-1719)
Please help me fix it so it will run in Sequoia! This script was super useful.
It’s taking longer to get direction after you put the addres.
Topic:
App & System Services
SubTopic:
Maps & Location
We are developing an app where we want iPhone to iPhone communication via bluetooth. We are using the core bluetooth API. One iPhone acts as the peripheral and the other as the central. When both apps are on screen they successfully find each other and can connect. However when the peripheral is in background the central can't find it. To be clear the central is still in foreground. I have consulted this page: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
and other resources. From my understanding the service UUID should be moved to the manufacturer data. This makes it difficult for non-iOS devices to detect the service but the documentation says that my central should be able to find the peripheral. I have added the required keys to the pList and am explicitly searching for the mentioned service UUID. When using a third party BLE Tool I'm able to find and communicate with the peripheral even when it is in background mode. I know that some option-keys will be ignored but from my understanding they should still find each other at least once. This was tested with two iOS 18 iPhones. Here is the code im using:
import UIKit
import CoreBluetooth
class ViewController: UIViewController {
private var centralManager: CBCentralManager!
private var peripheralManager: CBPeripheralManager!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func btnPeripheral(_ sender: Any) {
peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil)
}
@IBAction func btnCentral(_ sender: Any) {
print("central go")
centralManager = CBCentralManager(delegate: self, queue: nil)
}
}
extension ViewController: CBCentralManagerDelegate {
func centralManagerDidUpdateState(_ central: CBCentralManager) {
print("central state: \(central.state)")
switch central.state {
case .poweredOn:
print("central powered on")
centralManager.scanForPeripherals(withServices: [CBUUID(string:"db9acb1e-1ac4-4f70-b58c-3b3dcea84703")], options: [CBCentralManagerScanOptionAllowDuplicatesKey: true])
default:
print("central not powered on")
}
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
print("Dicovered \(peripheral)")
}
}
extension ViewController: CBPeripheralManagerDelegate {
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
print("peripheral state: \(peripheral.state)")
if peripheral.state == .poweredOn {
print("powered on")
let uuid = CBUUID(string: "db9acb1e-1ac4-4f70-b58c-3b3dcea84703")
let service = CBMutableService(type: uuid, primary: true)
peripheralManager.add(service)
peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [uuid], CBAdvertisementDataLocalNameKey: "MyService"])
}
}
}
We have developed an iOS app in objective-C and added integrations for shortcuts app - more specific the "automation" part of the app.
Basically, user opens shortcuts app, select automation and when scanning NFC tag, user can select an action and our app shows 3 different actions. User select action, opens the app and action is executed. That all done in Obj-C and was working very well with no complaints till users start to update to iOS18.
Now, when user starts to add automation, only thing they can do is select "open app". Our app actions are not showing any more. Is there something new in iOS 18 we have to update our app.
I know Obje-C is considered "old", but the cost of upgrading an existing app and time is not available at the moment.
Here's a code snippet of our shortcutIntent:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.lw.grp1</string>
<string>group.lw.grp2</string>
</array>
</dict>
</plist>
Shortcut Info-plist
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IntentsRestrictedWhileLocked</key>
<array/>
<key>IntentsRestrictedWhileProtectedDataUnavailable</key>
<array/>
<key>IntentsSupported</key>
<array>
<string>LockIntent</string>
<string>TrunkIntent</string>
<string>UnlockIntent</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.intents-service</string>
<key>NSExtensionPrincipalClass</key>
<string>IntentHandler</string>
</dict>
</dict>
</plist>
IntentHandler
-(id)init{
self = [super init];
self.started = false;
self.handler = [[AppIntentHandler alloc] init];
self.handler.userInfo = [[NSMutableDictionary alloc] init];
return self;
}
- (id)handlerForIntent:(INIntent *)intent {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
if(!self.started){
self.started = YES;
if([intent isKindOfClass:[LockIntent class]]){
NSLog(@"*intent lock selected*");
self.handler.userInfo = [self assignUserInfo:@"lock"];
}else if([intent isKindOfClass:[UnlockIntent class]]){
NSLog(@"*intent unlock selected*");
self.handler.userInfo = [self assignUserInfo:@"unlock"];
}else if([intent isKindOfClass:[TrunkIntent class]]){
NSLog(@"*intent trunk selected*");
self.handler.userInfo = [self assignUserInfo:@"trunk"];
}
}else{
self.started = NO;
}
return self.handler;
}
A custom class to handle each intent
@implementation AppIntentHandler
#pragma mark - response handlers
- (void)handleLock:(nonnull LockIntent *)intent completion:(nonnull void (^)(LockIntentResponse * _Nonnull))completion {
LockIntentResponse *response = [[LockIntentResponse alloc] initWithCode:LockIntentResponseCodeContinueInApp userActivity:[self lockUserActivity]];
completion(response);
}
- (void)handleUnlock:(nonnull UnlockIntent *)intent completion:(nonnull void (^)(UnlockIntentResponse * _Nonnull))completion {
UnlockIntentResponse *response = [[UnlockIntentResponse alloc] initWithCode:UnlockIntentResponseCodeContinueInApp userActivity:[self unlockUserActivity]];
completion(response);
}
- (void)handleTrunk:(nonnull TrunkIntent *)intent completion:(nonnull void (^)(TrunkIntentResponse * _Nonnull))completion {
TrunkIntentResponse *response = [[TrunkIntentResponse alloc] initWithCode:TrunkIntentResponseCodeContinueInApp userActivity:[self trunkUserActivity]];
completion(response);
}
What have changed and what needs to be done to make our app's actions show in shortcuts app again. Could anyone point me to the right direction, documentations, blog post or code snippet?
Thanks in advance for taking the time to help!
Hello,
I’m struggling to go from unversioned data model in SwiftData, to starting to version it.
Some FYI:
I’m using CloudKit
I’m using a widget, where I also pass in my data model and setup my container, this is shared over a group container/app group.
My migration is very simple, I’m adding a property which is not optional ( has default value set, and a default value in initialiser ).
Model:
@Model
class NicotineModel {
var nicotineType: NicotineType = NicotineType.snus
var startDate: Date = Date() + 30
var spendingAmount: Int = 0
var nicotinePerDay: Int = 0
var quittingMethod: QuittingMethod = QuittingMethod.coldTurkey // this is the change in the model, V1 doesn't have the quittingMethod property
var setupComplete: Bool = false
I’ve tried with:
static let migrateV1toV2 = MigrationStage.lightweight(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self
)
But also
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: nil,
didMigrate: {
context in
let nicotineModels2 = try context.fetch(FetchDescriptor<SchemaV2.NicotineModel>())
let nicotineModels = try context.fetch(FetchDescriptor<SchemaV1.NicotineModel>())
for model in nicotineModels {
let newModel = SchemaV2.NicotineModel(
nicotineType: model.nicotineType,
startDate: model.startDate,
spendingAmount: model.spendingAmount,
nicotinePerDay: model.nicotinePerDay,
setupComplete: model.setupComplete,
quittingMethod: .coldTurkey
)
context.insert(newModel)
context.delete(model)
}
try context.save()
}
)
and simply
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: nil,
didMigrate: { context in
let nicotineModels = try context.fetch(FetchDescriptor<SchemaV2.NicotineModel>())
for model in nicotineModels {
model.quittingMethod = .coldTurkey
}
try context.save()
}
)
This gives me the error on startup
SwiftData/ModelCoders.swift:1762: Fatal error: Passed nil for a non-optional keypath \NicotineModel.quittingMethod
On https://icloud.developer.apple.com I can see that the record doesn't include my quittingMethod.
I'm loosing my mind, what am I doing wrong?
Trying to migrate to Swift 6.
However getting this error when using SwiftUI StoreKit purchase environment.
Sending main actor-isolated value of type 'PurchaseAction' with later accesses to nonisolated context risks causing data races
@Environment(\.purchase) private var purchase
let result = try await purchase(product)
Since the iOS 18 and Xcode 16, I've been getting some really strange SwiftData errors when passing @Model classes around.
SwiftData/BackingData.swift:409: Fatal error: This model instance was destroyed by calling ModelContext.reset and is no longer usable. PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://D0F0E233-8D1D-4020-924B-BA56959140FD/ListModel/p10), implementation: SwiftData.PersistentIdentifierImplementation)
The same issue also happens when I try to retrieve a model from the ModelContext using its PersistentIdentifier and try to do anything with it. I have no idea what could be causing this.
This is my actor
@ModelActor
actor ListCrudOperations:ObservableObject{
func add(list:ListModel){
modelContext.insert(list)
try? modelContext.save()
}
func delete(identifier:PersistentIdentifier){
guard let list = self[identifier, as: ListModel.self] else {
print("error")
return
}
if list.listType == .task{
list.reminders!.forEach { reminder in
TaskModel.delete(modelContext: modelContext, reminder: reminder)
NotificationService.deleteReminders(name: reminder.title!, Id: reminder.id)
}
}
else if list.listType == .subscription {
list.subscription!.forEach({ sub in
Subscription.delete(modelContext: modelContext, subscription: sub)
NotificationService.deleteReminders(name: sub.ServiceName, Id: sub.id)
})
}
else if list.listType == .link {
list.links!.forEach ({link in
Links.delete(modelContext: modelContext, link: link)
NotificationService.deleteNotificationForLink(title: link.name, linkID: link.id)
}
)
}
modelContext.delete(list)
try? modelContext.save()
}
func addReminder(reminder:TaskModel, identifier:PersistentIdentifier){
guard let list = self[identifier, as: ListModel.self] else {
print("error")
return
}
list.reminders!.append(reminder)
reminder.list = list
try? modelContext.save()
}
func addSubscription(subscription:Subscription, identifier:PersistentIdentifier){
guard let list = self[identifier, as: ListModel.self] else {
print("error")
return
}
list.subscription!.append(subscription)
subscription.list = list
try? modelContext.save()
}
func addLink(link:Links, identifier: PersistentIdentifier) {
guard let list = self[identifier, as: ListModel.self] else {
print("error")
return
}
list.links?.append(link)
link.list = list
try? modelContext.save()
}
func fetchListByType(type:ListType) -> [ListModel] {
let type = SwiftTaskSchemaV8.ListModel.ListType(rawValue: type.rawValue)!
let fetchDescriptor = FetchDescriptor<ListModel>()
do {
let list = try modelContext.fetch(fetchDescriptor)
let list2 = try list.filter(#Predicate { $0.listType == type })
return list2
}catch{
return []
}
}
func fetchListsForMultipleTypes(_ types: [ListType]) -> [ListModel] {
return types.flatMap { type in fetchListByType(type: type) }
}
func fetchAllList() -> [ListModel] {
let fetchDescriptor = FetchDescriptor<ListModel>(sortBy: [.init(\.createdDate)])
do {
let list = try modelContext.fetch(fetchDescriptor)
return list
}catch{
return []
}
}
}```
and this is how i am calling it
@Environment(.modelContext) private var context
let listOperation = ListCrudOperations(modelContainer: context.container)
let list = ListModel(name: name, color: self.color, icon: self.icon, listType: ListModel.ListType(rawValue: picked.rawValue)!)
Task {
await listOperation.add(list: list)
await MainActor.run{
withAnimation(.bouncy){
self.list.append(list)
}
CrashServices.shared.addLogs(message: "folder added")
}
}
I'm a font developer. In the development process, I will revise a font and overwrite the OTF file that is currently enabled (registered) with macOS.
If I then launch an app, it will immediately use the revised version of the font; while apps that are already loaded will continue to use the old version.
This suggests that each app is loading new and separate font data, rather than getting it from some existing cache in memory. Yet macOS does have a "font cache" of some sort.
Some apps, like TextEdit, seem to only load the fonts that they need to use. However, other apps, like Pages, load every enabled (registered) font on the OS!! (According to the Open Files list in Activity Monitor.)
Given that /System/Library/Fonts/ is 625 Mb, and we can't disable any of it, isn't that a lot of data to be repeating? How many fonts is too many fonts?
I can't find much documentation about the process.
I have a MKMapView with a MKScaleView.
If I visualise a generic map I have the scale in km.
When I change the MKMapRect using visibleMapRect, the scale doesn't change.
If I use setVisibleMapRect(_ mapRect: MKMapRect, animated animate: Bool), the scale change but not to the correct one. For example, it shows a scale saying one inch corresponds to 250 m while it is 150 m.
The same issue of I use MKCoordinateRegion.
Instead, if I zoom in or zoom out pinching on the map, the scale updates correctly.
Am I doing something wrong? How can I fix this?
Sample code:
import UIKit
import MapKit
let CORNER_RADIUS: CGFloat = 8.0
let METERS_PER_MILE: Double = 1609.344
class PIAnnotation: NSObject, MKAnnotation {
var coordinate: CLLocationCoordinate2D
private(set) var title: String?
private(set) var subtitle: String?
init(location: CLLocationCoordinate2D,
title: String? = nil, subtitle: String? = nil) {
coordinate = location
self.title = title
self.subtitle = subtitle
}
}
class PISimpleMapView: MKMapView {
private let HALF_MAP_SIDE_MULTIPLIER: Double = 1.4
private let pinIdentifier = "pinIdentifier"
private var scaleView: MKScaleView?
typealias PinAnnotationView = MKMarkerAnnotationView // MKPinAnnotationView
required init?(coder: NSCoder) {
super.init(coder: coder)
inizialize()
}
override init(frame: CGRect) {
super.init(frame: frame)
inizialize()
}
func inizialize() {
layer.cornerRadius = CORNER_RADIUS
register(PinAnnotationView.self,
forAnnotationViewWithReuseIdentifier: pinIdentifier)
addScale()
}
private func addScale() {
let scale = MKScaleView(mapView: self)
scale.translatesAutoresizingMaskIntoConstraints = false
scale.scaleVisibility = .visible // always visible
addSubview(scale)
let guide = safeAreaLayoutGuide
NSLayoutConstraint.activate([
scale.leftAnchor.constraint(equalTo: guide.leftAnchor, constant: 16.0),
scale.rightAnchor.constraint(equalTo: guide.centerXAnchor),
scale.topAnchor.constraint(equalTo: guide.topAnchor),
scale.heightAnchor.constraint(equalToConstant: 20.0)
])
scaleView?.removeFromSuperview()
scaleView = scale
}
func displayPinOnMap(location: CLLocation) {
let annotation = PIAnnotation(location: location.coordinate,
title: "Sample", subtitle: nil)
addAnnotation(annotation)
// Position the map so that all overlays and annotations are visible on screen.
visibleMapRect = visibleArea(from: annotation)
// setVisibleMapRect(visibleArea(from: annotation), animated: true)
// region = MKCoordinateRegion(visibleArea(from: annotation))
}
private func visibleArea(from annotation: PIAnnotation) -> MKMapRect {
let annotationPoint = MKMapPoint(annotation.coordinate)
return MKMapRect(x: annotationPoint.x - HALF_MAP_SIDE_MULTIPLIER * METERS_PER_MILE,
y: annotationPoint.y - HALF_MAP_SIDE_MULTIPLIER * METERS_PER_MILE,
width: HALF_MAP_SIDE_MULTIPLIER * 2.0 * METERS_PER_MILE,
height: HALF_MAP_SIDE_MULTIPLIER * 2.0 * METERS_PER_MILE)
}
}
Requirement:- Crash my MacOs laptop such that my crashes get collected in the /Library/Logs/DiagnosticReports folders. But the crash shouldn't hamper my laptop's performace.
I read that we had an approach to cause a kernel panic, but I'm really concerned about the state that this would put my device in. Any advice would be helpful, thanks.
I developed a network filter using system extensions and placed the system extension program in a container app. I activated the extension and enabled the network filter in the/Applications directory through the container app. After that, my container app process exited, and only the system extension program process in the/Library/SystemExtensions directory was running. After booting up and upgrading the macOS system, the system extension program will be launched, and I learned from the link below that the system extension will be launched with the system at startup: https://developer.apple.com/forums/thread/701986 . But I haven't learned from the official documentation of System Extensions and NetworkExtension why system extensions start with the system and what their principles are. Because the container app under the activation system extension/Application did not start. Has the network filter developed for system expansion been registered in the system related files or frameworks? Ensure that it will start after each startup
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags:
System Extensions
Network Extension
Hi everyone,
I'm currently developing an app that installs eSIM profiles directly within the app and checks if the device supports eSIM. For this functionality, I understand that I need the eSIM entitlement for the Core Telephony API.
I submitted a request for the eSIM entitlement to Apple about three weeks ago, but I haven't received a response yet. Has anyone experienced a similar situation? What would be the best course of action to follow up on this?
Any guidance or suggestions would be greatly appreciated.
Thank you!
Topic:
App & System Services
SubTopic:
Core OS
After update to IOS18, my app crashed. following is the exception got from xcode:
Trapped uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager createDirectoryAtURL:withIntermediateDirectories:attributes:error:]: URL is nil'
(
0 CoreFoundation 0x0000000194a79098 47427277-EE15-3C17-AD68-6886B0380B5E + 540824
1 libobjc.A.dylib 0x0000000191d7b2e4 objc_exception_throw + 88
2 Foundation 0x0000000193741f48 12E17A7A-B65F-35EE-82D7-CBC31004E223 + 1154888
3 CFNetwork 0x0000000195eeb2bc FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 164540
4 CFNetwork 0x0000000195eeac7c FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 162940
5 libdispatch.dylib 0x000000010342a71c _dispatch_client_callout + 20
6 libdispatch.dylib 0x000000010343bf04 _dispatch_lane_barrier_sync_invoke_and_complete + 176
7 CFNetwork 0x0000000195eeaa88 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 162440
8 CFNetwork 0x0000000195ee9b20 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 158496
9 CFNetwork 0x0000000195ee95f4 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 157172
10 CFNetwork 0x0000000195ee907c FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 155772
11 CFNetwork 0x0000000195ee34b0 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 132272
12 CFNetwork 0x0000000195f942c4 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 856772
13 CFNetwork 0x0000000195f94214 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 856596
14 CFNetwork 0x0000000195f9330c FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 852748
15 libdispatch.dylib 0x0000000103428a30 _dispatch_call_block_and_release + 32
16 libdispatch.dylib 0x000000010342a71c _dispatch_client_callout + 20
17 libdispatch.dylib 0x00000001034325e8 _dispatch_lane_serial_drain + 828
18 libdispatch.dylib 0x0000000103433394 _dispatch_lane_invoke + 460
19 libdispatch.dylib 0x0000000103434b20 _dispatch_workloop_invoke + 2264
20 libdispatch.dylib 0x00000001034405f0 _dispatch_root_queue_drain_deferred_wlh + 328
21 libdispatch.dylib 0x000000010343fc00 _dispatch_workloop_worker_thread + 580
22 libsystem_pthread.dylib 0x000000021bddfc7c _pthread_wqthread + 288
23 libsystem_pthread.dylib 0x000000021bddc488 start_wqthread + 8
)
This app works fine until ios 18 appear. Could you help me? thanks
I tried building some app logic around NetworkMonitor.isConnected in my watch app (I want to trigger an update when the user opens the app and isConnected == true, otherwise observe NetworkMonitor.isConnected until it changes to true), and I found out that on a real device, NetworkMonitor.isConnected is always false.
This does not seem to be documented anywhere. Am I right in assuming NetworkMonitor is not to be trusted on the watch? watchOS version is 18.
I found an old post where eskimo argues that NWPathMonitor is not useful on the watch (which is also not documented), is it the same for NetworkMonitor?
https://forums.developer.apple.com/forums/thread/127080
In macOS Sequoia, there are up to 3 locations where an end user can enable or disable a Network Extension.
In order of appearance in the System Settings.app application:
Network > Filters
General > Login Items & Extensions (1)
General > Login Items & Extensions > Network Extensions
a) it's quite difficult for an end user (and even a developer) to understand why there are 3 different locations and whether we are dealing with the same unique item or not. e.g. why would an end user have a clue about the difference between a Network Extension and a (Packet | Content) Filter?
b) it's not possible for an end user to figure out what the consequences of disabling an item in one of these 3 locations is going to be, because, in each case, the consequences appear to be different, undocumented or not detailed clearly in the UI. (2)
[Q] Is there a clear, complete and detailed documentation for Network Extensions UX controls in macOS Sequoia? For either end users or developers?
I could't find one when searching inside www.apple.com or developer.apple.com.
(1) not sure why a Network Extension also appears here as it's not a launchd daemon controlled by a 3rd party launchd plist. And not sure to understand why it's there since there's now the Network Extensions panel.
(2) it does not help that the output of the systemextensionsctl command line tool, in most cases, reports that the extension is still activated and enabled.
How can I resolve the error(Code=65 "No route to host).
Xcode 16(SDK ios18): We invoke GCDAsyncUdpSocket to send UDP data to the broadcast address,then get Error Domain=NSPOSIXErrorDomain Code=65 "No route to host"
Xcode 16.1 beta 2(SDK ios18.1): We invoke GCDAsyncUdpSocket to send UDP data to the broadcast address,then it work fine.
Xcode 15.4(SDK ios17.5): We invoke GCDAsyncUdpSocket to send UDP data to the broadcast address,then it work fine.
Notes:
Privacy - Local Network Usage Description and the multicast entitlement has been added.
Bonjour services has been added _http._tcp、_http._udp
Code:
GCDAsyncUdpSocket *gcdUdpSearchSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
NSError *error = nil;
if (![gcdUdpSearchSocket enableBroadcast:YES error:&error]){
NSLog(@"gcdUdpSearchSocket enableBroadcast Error binding: %@", error);
return;
}
if (![gcdUdpSearchSocket bindToPort:UDP_PORT error:&error])
{
NSLog(@"GCDUdp Error binding: %@", error);
return;
}
if (![gcdUdpSearchSocket beginReceiving:&error])
{
NSLog(@"GCDUdp Error receiving: %@", error);
return;
}
Hi!
I am new to Apple app development so please bear with me.
I am trying to design an app that can mimic some of the functionality of iptables routing. The crux of it is I would like to redirect local traffic bound for a specific port to a different port and then redirect any outgoing traffic on that port back to the original port:
outgoing packet bound for IP:1234 -> 127.0.0.1:2345
outgoing packet bound for IP:2345 -> IP:1234
I tried to implement this behavior with a packet tunnel but have not made any substantial progress. Is this the right approach?
Here is my implementation:
private func handleConnection(_ connection: NWConnection) {
connection.receive(minimumIncompleteLength: 1, maximumLength: 65536) { [weak self] data, context, isComplete, error in
if let data = data, !data.isEmpty {
self?.processData(data, from: connection)
}
if let error = error {
print("Connection error: \(error)")
}
if isComplete {
connection.cancel()
} else {
self?.handleConnection(connection) // Continue to receive data
}
}
connection.start(queue: .main)
}
private func processData(_ data: Data, from connection: NWConnection) {
switch connection.endpoint {
case .hostPort(let host, let port):
let portNumber = port.rawValue
let hostDescription = host.debugDescription
print("Received data from host: \(hostDescription) on port: \(portNumber)")
if portNumber == 1234 {
// Rule 1: Redirect traffic from port 1234 to 127.0.0.1:2345
redirectTraffic(data, to: "127.0.0.1", port: 2345)
print("Redirecting traffic from 1234 to 2345")
} else if portNumber == 2345 {
// Rule 2: Redirect traffic from port 2345 to the original IP address but port 1234
redirectTraffic(data, to: hostDescription, port: 1234)
print("Redirecting traffic from 2345 back to 1234")
}
case .service(name: _, type: _, domain: _, interface: _):
print("Received bonjour service")
case .unix(path: _):
print("Received unix domain path")
case .url(_):
print("Received url")
case .opaque(_):
print("Opaque?")
@unknown default:
fatalError("Unknown endpoint type")
}
}
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.URLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024
diskCapacity:100 * 1024 * 1024
diskPath:@"myCache"];
if (!configuration) {
NSLog(@"Failed to create session configuration.");
return;
}
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
if (!session) {
NSLog(@"Failed to create session.");
return;
}
NSURL *url = [NSURL URLWithString:@"https://example.com"];
if (!url) {
NSLog(@"Invalid URL.");
return;
}
NSURLRequest *request = [NSURLRequest requestWithURL:url];
if (!request) {
NSLog(@"Failed to create request.");
return;
}
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
} else {
NSLog(@"Data received: %@", data);
}
}];
if (!dataTask) {
NSLog(@"Failed to create data task.");
return;
}
dataTask.priority = NSURLSessionTaskPriorityDefault;
[dataTask resume];
error message
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager createDirectoryAtURL:withIntermediateDirectories:attributes:error:]: URL is nil'
*** First throw call stack:
(0x1848bd08c 0x181bbf2e4 0x183585f48 0x185d2f2bc 0x185d2ec7c 0x10709271c 0x1070a3f04 0x185d2ea88 0x185d2db20 0x185d2d5f4 0x185d2d07c 0x185d274b0 0x185dd82c4 0x185dd8214 0x185dd730c 0x107090a30 0x10709271c 0x10709a5e8 0x10709b394 0x10709cb20 0x1070a85f0 0x1070a7c00 0x20bc27c7c 0x20bc24488)
libc++abi: terminating due to uncaught exception of type NSException