The documentation specifies that when Contacts framework returns unified contacts that each fetched unified contact object (CNContact) has its own unique identifier that’s different from any individual contact’s identifier in the set of linked contacts and that when refetching a unified contact, that this identifier should be used.
There is also an analogous identifier within the list of contactRelations, but each of these don't seem to corespondent to the unified contacts. For example, is a new contact (Sheryl Zakroff) is created in the simulator Contacts and their spouse is set to Hank Zakroff. However, the GUID created for the contactRelations identifier does not correlate to the original Hank Zakroff GUID and cannot be searched.
Is this a bug or what is the indent of the contactRelations identifier?
Here's a debug output of walking the unifiedContacts:
Name: Hank Zakroff
2E73EE73-C03F-4D5F-B1E8-44E85A70F170
- Other : (555) 766-4823
- Other : (707) 555-1854
Name: David Taylor
E94CD15C-7964-4A9B-8AC4-10D7CFB791FD
- Other : 555-610-6679
Name: Sheryl Zakroff
DE783BC8-7917-4138-93F6-3AF0FD4CE083
- Other : (707) 555-1854
- Spouse: <CNContactRelation: 0x60000000dd60: name=Hank M. Zakroff>
- 534B467D-CA00-46D3-897C-16EEA782C9CF
- Looking for ["534B467D-CA00-46D3-897C-16EEA782C9CF"]
[]
Frameworks
RSS for tagAsk questions about APIs that can drive features in your apps.
Posts under Frameworks tag
194 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
My Xcode project has the following configuration:
1 iOS app target
1 Xcode framework target (mach-o-type "Dynamic Library")
5 static libraries
Dependencies:
All the static libraries are target dependencies of the framework.
The framework is the only target dependency of the iOS app.
For the iOS app target, within the General tab > Frameworks, Libraries & Embedded content, I've set the framework as "Do not embed"
So now I have a dynamic framework which won't be copied to the .app bundle in the build output.
As per my understanding, this should result in a runtime error, dyld should not be able to find the framework files as they were not embedded in the final .app bundle.
But regardless, my app runs without any errors, using all the methods exposed by the framework.
What is the correct understanding here?
What exactly does Embed/Do not embed mean (apart from excluding the files from .app bundle)
When both settings are specified, is there any priority or precedence of one setting over the other?
I was exploring the scenarios where an NWListener or NWConnection can be invalidated or reclaimed by the OS itself.
I came across the document TN2277: Networking and Multitasking, which discusses situations where iOS can reclaim the underlying socket descriptor.
The document states:
while the app is suspended the system may choose to reclaim resources out from underneath a network socket used by the app, thereby closing the network connection represented by that socket.
From this, I understand that when the app is in a suspended state, the OS may reclaim the socket descriptor.
My questions are:
In what scenarios does the OS not reclaim the socket descriptor while the app is suspended, and in which cases does it reclaim it?
When reclamation occurs, does the OS reclaim 'a' single NWListener/NWConnection, or does it reclaim 'all' NWListener/NWConnections opened by the application?
Thanks.
I am encountering a critical issue where a custom background image on a UIToolbar fails to display when the app is built with Xcode 26 and run on iOS 26 beta. The exact same implementation works perfectly on iOS 18 and earlier versions.
We first attempted to use the legacy setBackgroundImage method, which fails to render the image on iOS 26:
// 1. Get Navigation Bar and set basic properties
UINavigationBar* navBar = self.navigationBar;
navBar.hidden = NO;
navBar.translucent = NO;
// 2. Setup the UIToolbar instance
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:navBar.bounds];
toolBar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
// 3. Set the resizable image (This image does not appear on iOS 26)
UIImage* imagePortrait = [UIImage imageNamed:@"nav_bg"];
UIEdgeInsets insets = UIEdgeInsetsMake(0.f, 6.f, 0.f, 6.f);
[toolBar setBackgroundImage:[imagePortrait resizableImageWithCapInsets:insets]
forToolbarPosition:UIToolbarPositionAny
barMetrics:UIBarMetricsDefault];
We then migrated to the recommended modern UIToolbarAppearance to solve this, but the issue persists:
// 1. Prepare Image
UIImage* imagePortrait = [UIImage imageNamed:@"nav_bg"];
// Insets are applied via resizableImageWithCapInsets: (not shown in this snippet but implied)
// 2. Configure UIToolbarAppearance
UIToolbarAppearance *appearance = [[UIToolbarAppearance alloc] init];
appearance.backgroundImage = imagePortrait; // The image is correctly loaded (not nil)
// 3. Apply the Appearance
toolBar.standardAppearance = appearance;
// We also applied to scrollEdgeAppearance and compactAppearance.
Any information or recommended workarounds for displaying a custom background image on UIToolbar in the latest iOS 26 would be highly appreciated.
We are unable to access images from an Asset catalog that is part of a dynamic framework that is mergeable, on Debug configuration, when running on an actual device under certain circumstances when using Xcode 16.4 and targeting iOS.
If anywhere in the app we call the Bundle(identifier:) initializer for whatever ID, subsequent calls to UIImage(named:in:with:) for images in the framework's bundle return nil. We have verified that the bundle (path) and the name of image & assets target memberships are correct, and that Assets.car has the images.
Additionally the only way to make UIImage(named:in:with:) work is to use Bundle(for:) where BundleFinder is part of the mergeable library, non private NSObject class. Anything else and the re-exported bundle is returned which has no assets.
Hi everybody,
I use a very old photo software called Snapseed v 1.2.1 on 2 MacBook, one runs with El Capitan and the second runs with Mojave. These app has no language selection during install, and no preferences language choice in menu when running.
When I execute app on El Capitan, all menus and topics are translate in French, but on Mojave no translation is done.
I looked Contents of app and found differents languages files (structured as xx.po where xx=country) located in Resources folder. I deduced translation was executed after getting language param. I checked values on both systems and there are same (LANG=fr_FR.UTF-8).
So I tried to change Info.plist file to force code langage to 'fr' in CFBundleLocalizations key. Result is same.
Does somebody has a idea of reason of issue and how to solve it ?
Snapseed release was 2012, El Capitan 2015 and Mojave 2018, it seems framework used to code app runs differently and can't get language value.
We are in the process of updating our legacy Spotlight MDImporter to the new macOS Spotlight App Extension.
The transition works well for standard attributes such as title, textContent, and keywords.
However, we encounter an issue when adding custom attributes to the CSSearchableItemAttributeSet.
These custom attributes are not being persisted, which means they cannot be queried using a Spotlight NSMetadataQuery.
Has anyone an idea on how to append custom attributes so that they are included in the indexed file status, as displayed by the shell command mdimport -t -d3 <path>
A sample project illustrating the problem is available here: https://www.dropbox.com/scl/fi/t8qg51cr1rpwouxdl900b/2024-09-04-Spotlight-extAttr.zip?rlkey=lg6n9060snw7mrz6jsxfdlnfa&dl=1
I have an Xcode project setup as follows:
3 static libraries
1 framework target, whose Mach-O type is set to Dynamic Library
main app target (iOS app)
The target dependencies are as follows:
In framework's build phase [Link with libraries], I have the 3 libs statically linked.
In the main app's build phase [Link with libraries], I have only the framework, which is dynamically linked.
As per my understanding:
The libs are statically linked to the framework. So, the framework binary would contain code from all the libs.
The framework is dynamically linked to the main app (iOS app in this case). So, the main app's binary only has a reference to the framework's binary, which would be loaded in the memory at runtime.
Assuming my understanding is correct, I'm stuck with the following problem:
All 3 libs build successfully
The framework builds successfully
The main app target doesn't build. The compilation is successful, but the build fails with linker errors.
Please let me know if I am doing something incorrectly, or if a configuration is missing. Below are more details:
The linker gives the following error:
Undefined symbols for architecture arm64:
"StringUtils.GetStr() -> Swift.String", referenced from:
dynamic_fw.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: [__C.UIApplicationLaunchOptionsKey : Any]?) -> Swift.Bool in AppDelegate.o
"TWUtils.GetNum() -> Swift.Int", referenced from:
dynamic_fw.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: [__C.UIApplicationLaunchOptionsKey : Any]?) -> Swift.Bool in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And the command shown in the logs for linking phase is:
Ld /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator/dynamic-fw.app/dynamic-fw normal (in target 'dynamic-fw' from project 'dynamic-fw')
cd /Users/raunit.shrivastava/Desktop/dynamic-fw
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios17.5-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk -O0 -L/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator -L. -L./StringUtils -L./TWFramework -L./TWUtils -L./dynamic-fw -F/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator -F. -F./StringUtils -F./TWFramework -F./TWUtils -F./dynamic-fw -filelist /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic-fw.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker ./\*\* -dead_strip -Xlinker -object_path_lto -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic-fw_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic_fw.swiftmodule -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/dynamic-fw.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/dynamic-fw.app-Simulated.xcent.der -framework TWFramework -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic-fw_dependency_info.dat -o /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator/dynamic-fw.app/dynamic-fw
I'm adapting my app on iOS 26, and I just found out withAnimation fuction's completion not called in some cases. The same code on iOS 18 was fine. The problem is very fatal, When you check the api, it saids "The completion callback will always be fired exactly one time",but this time it doens't work.
I'm using the Xcode Version 26.0 (17A321) RC1,still not test on a real devcie yet.
Has anyone encountered a situation like mine below? I’ve submitted feedback, but it seems like I’ll have to wait for a while.
ContactProviderManager Fails with Custom domainIdentifier, Works Only with "defaultDomain"
Category: Developer Tools / Frameworks
Subcategory: ContactProvider Framework
Reproducibility: Always
iOS Version: iOS 18.0 (and later)
Xcode Version: Xcode 16.0 (or later)
Description:
When initializing a ContactProviderManager with a custom ContactProviderDomain using any identifier other than "defaultDomain", the initializer throws a ContactProviderError.domainNotRegistered error. The documentation for ContactProviderDomain (https://developer.apple.com/documentation/contactprovider/contactproviderdomain) does not provide any method to register custom identifiers, making it impossible to use ContactProviderManager with a desired custom identifier. The only successful case is when the identifier is "defaultDomain". print("Error: (error)") // No error, initialization succeeds
Steps to Reproduce:
Create a Contact Provider Extension in an iOS app targeting iOS 18.0.
In host app, Attempt to initialize a ContactProviderManager with a custom ContactProviderDomain identifier:
import ContactProvider
func enableExtensionExample() async {
do {
// The app creates a contact provider manager with custom domain.
let manager = try ContactProviderManager(domainIdentifier: "com.mycompany.customdomain")
// May prompt the person to enable the custom domain.
try await manager.enable()
} catch {
print("Error: \(error)") // Prints ContactProviderError.domainNotRegistered
}
}
Try the same with the default identifier:
import ContactProvider
func enableExtensionExample() async {
do {
// The app creates a contact provider manager with a default domain.
let manager = try ContactProviderManager(domainIdentifier: "defaultDomain")
// May prompt the person to enable the default domain.
try await manager.enable()
} catch {
print("Error: \(error)") // No error, initialization succeeds
}
}
Build and run the app on a device or simulator running iOS 18.0 or later.
Observe that the initializer fails with domainNotRegistered for any identifier other than "defaultDomain".
Expected Behavior:
The ContactProviderManager should initialize successfully with any valid ContactProviderDomain identifier, provided the domain is properly configured or registered, allowing developers to use custom identifiers for organizing contacts (e.g., for different categories or sources).
Actual Behavior:
The ContactProviderManager initializer throws ContactProviderError.domainNotRegistered for any ContactProviderDomain identifier other than "defaultDomain". Only the "defaultDomain" identifier succeeds, limiting the ability to use custom domains.
Impact:
Developers cannot use custom identifiers to categorize or manage contacts in separate domains, restricting the ContactProvider framework’s flexibility. This forces reliance on the "defaultDomain" identifier, which may not suit use cases requiring distinct contact groups (e.g., personal vs. business contacts).
Suggested Fix:
Provide an API to register custom ContactProviderDomain identifiers, such as a ContactProviderManager.register(domain:) method. Update the ContactProviderDomain and ContactProviderManager documentation to clarify how to use custom identifiers or explicitly state if only "defaultDomain" is supported. If custom identifiers are not intended to be supported, document this limitation clearly to avoid developer confusion.
Feedback :
FB20104001 (ContactProviderManager Fails with Custom domainIdentifier, Works Only with "defaultDomain")
Hey!
I am developing a macOS application with the help of an external vendor, who is supplying me with a closed-source XCFramework.
In Xcode, when I import their XCFramework bundle, when running the app, or opening a SwiftUI preview, or interacting with the app in any form, I get the familiar dialog:
"[SDK name].framework" Not Opened - Apple could not verify "[SDK name].framework" is free from malware that may harm your Mac or compromise privacy.
(Regardless, the application can run on my machine.)
But indeed, their cross-platform iOS/macOS XCFramework is not notarized at all (using spctl -a -t install), plus the macOS binary embedded is not code signed correctly (using codesign -d). The XCFramework itself is production code signed with a Developer ID certificate, however I believed the above issues to be valid.
Now, I asked the vendor to provide a correctly distributed (so code signed and notarized) framework, however they pointed out that "when I embed and sign the product in my app, it will be re-signed anyways". I understand this is true, but I believe this to be an important security boundary. If I were to re-sign under my name a closed source binary - previously unchecked for malware by Apple Notary Service -, I would put myself up for embedding potentially malicious code in my app, which could only be traced back to me - which would in turn mean a security issue would hinder my reputation here.
Am I being over-protective here, or is this a valid concern? I have no way to see the source code, so I strongly believe this XCFramework should be notarized correctly. I understand that an in-house XCFramework is fine unnotarized, given that I know its origin, but this seems like a unique case where notarization should be enforced from my side on the vendor.
How can you distribute an XCFramework via Swift Package Manager when it has dependencies on other Swift packages? We accomplished this with CocoaPods in order to distribute our closed source SDK that has dependencies, but need to migrate to SPM. Note none of the types from the dependencies are used as part of our module’s public interface - usage is purely internal.
I’ve made a lot of progress following these steps for a simple example:
Create Framework Project
Create a new iOS Framework project in Xcode and name it WallpaperKit
In the project settings select the target and verify in Build Settings that Build Libraries for Distribution is Yes then set Skip Install to No
Create a new UIViewController subclass, name it WallpaperPreviewViewController, make it public, and add some functionality to it to show a UIImageView
Add a new Package Dependency in the project settings, for this example we’ll use https://github.com/onevcat/Kingfisher, and specify exact version 8.5.0
Add internal import Kingfisher and use it in WallpaperPreviewViewController to download and show an image from the web
Close the WallpaperKit project
Create Hosting App Project (this makes it easier to develop the framework functionality and test it in an app with Xcode building both in the same workspace)
Create a new iOS app project and name it WallpaperApp
Create a new workspace named WallpaperApp
Close the WallpaperApp project
Drag and drop WallpaperApp.xcodeproj into the workspace’s sidebar
Drag and drop WallpaperKit.xcodeproj into the workspace’s sidebar
Switch the scheme to WallpaperKit and build
Select WallpaperApp project, then with WallpaperApp target selected, in the General tab under Frameworks, Libraries, and Embedded Content, click + and add WallpaperKit.framework
In ViewController.swift, import WallpaperKit and add functionality to present an instance of WallpaperPreviewViewController
Run the app and verify it works
Create XCFramework
In Terminal, cd into WallpaperKit and run xcodebuild archive -scheme WallpaperKit -configuration Release -destination 'generic/platform=iOS' -archivePath './build/WallpaperKit.framework-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES DEFINES_MODULE=YES
Run xcodebuild archive -scheme WallpaperKit -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath './build/WallpaperKit.framework-iphonesimulator.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES DEFINES_MODULE=YES
Run xcodebuild -create-xcframework -framework './build/WallpaperKit.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/WallpaperKit.framework' -framework './build/WallpaperKit.framework-iphoneos.xcarchive/Products/Library/Frameworks/WallpaperKit.framework' -output './build/WallpaperKit.xcframework'
Open the build folder and retrieve the XCFramework
Create Swift Package
Create a new package in Xcode, select Library, and name it WallpaperKitDist
Drag and drop WallpaperKit.xcframework into Sources
Create a new directory in Sources called WallpaperKitDependencies
Create a new Swift file in WallpaperKitDependencies called WallpaperKitDependencies (SPM requires a Swift file to recognize WallpaperKitDependencies as a valid target and fetch dependencies)
Open Package.swift and change it to
import PackageDescription
let package = Package(
name: "WallpaperKit",
platforms: [
.iOS(.v18)
],
products: [
.library(
name: "WallpaperKit",
targets: ["WallpaperKit", "WallpaperKitDependencies"]
),
],
dependencies: [
.package(
url: "https://github.com/onevcat/Kingfisher.git",
exact: "8.5.0"
)
],
targets: [
.binaryTarget(
name: "WallpaperKit",
path: "./Sources/WallpaperKit.xcframework"
),
.target(
name: "WallpaperKitDependencies",
dependencies: [
"Kingfisher"
],
path: "./Sources/WallpaperKitDependencies"
)
]
)
Create Test App (to simulate a third-party app using the package)
Create a new iOS app project and name it TestApp
Add a new Local package selecting the WallpaperKitDist directory that contains Package.swift
Import WallpaperKit and use it to present a WallpaperPreviewViewController
This works! Though the console logs
objc[39953]: Class _TtC10KingfisherP33_6AA794C9C370CDB07604B4D8B99AEAA312BundleFinder is implemented in both /Users/Name/Library/Developer/Xcode/DerivedData/TestApp-capvhjiqxrdgdnbevpkajicnjpcs/Build/Products/Debug-iphonesimulator/WallpaperKit.framework/WallpaperKit (0x100e8bbf8) and /Users/Name/Library/Developer/CoreSimulator/Devices/E0AF13C2-874C-47B9-B864-72AF3E4D5D4B/data/Containers/Bundle/Application/AF32011A-92E7-4E26-9A97-9F0C25C07863/TestApp.app/TestApp.debug.dylib (0x101a543b0). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.
I thought using internal import Kingfisher (or @_implementationOnly import Kingfisher) would have resolved this, but seems to make no difference compared to just import Kingfisher. I suspect it might not be an issue as long as the Kingfisher version number specified in the distribution Package.swift matches the version used in the framework project (and the app does not add a different version as a dependency), but not positive.
Can these warnings be resolved, or is it not a concern in this setup? Is this the best solution to distribute an XCFramework via Swift Package Manager that has dependencies on other Swift packages for now or is there a better approach? Thanks!
UIBarButtonItem setting isEnabled = false, but the item is still tappable and animating. Is this a new UI behavior or an issue?
Do the following steps:
On tapping on a UIBarButtonItem, disable by setting isEnabled = false and setting hidesSharedBackground = true
Enable the button by setting isEnabled = true and setting hidesSharedBackground = false
=> The button appears with bigger shared background
is this an issue?
please find the attachments for more details.
ViewController.swift.txt
Hi All,
I am currently working on a Network Extension App for MacOS using 3 types of extensions provided by Apple's Network Extension Framework.
Content Filter, App Proxy (Want to get/capture/log all HTTP/HTTPS traffic), DNS Proxy (Want to get/capture/log all DNS records).
Later parse into human readable format.
Is my selection of network extension types correct for the intended logs I need?
I am able to run with one extension:
Main App(Xcode Target1) <-> Content Filter Extension. Here there is a singleton class IPCConnection between App(ViewController.swift) which is working fine with NEMachServiceName from Info.plist of ContentFilter Extension(Xcode Target2)
However, when I add an App Proxy extension as a new Xcode Target3, I think the App and extension's communication getting messed up and App not getting started/Crashing. Here, In the same Main App, I am adding new separate IPCConnection for this extension.
Here is the project organization/folder structure.
MyNetworkExtension
├──MyNetworkExtension(Xcode Target1)
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── Info.plist
│ ├── MyNetworkExtension.entitlement
│ | ── Main
│ |-----ViewController.swift
│ └── Base.lproj
│ └── Main.storyboard
├── ContentFilterExtension(Xcode Target2)
│ ├── ContentFilterExtension.entitlement
│ │ ├── FilterDataProvider.swift
│ │ ├── Info.plist
│ │ ├── IPCConnection.swift
│ │ └── main.swift
├── AppProxyProviderExtension(Xcode Target3)
│ ├── AppProxyProviderExtension.entitlement
│ │ ├── AppProxyIPCConnection.swift
│ │ ├── AppProxyProvider.swift
│ │ ├── Info.plist
│ │ └── main.swift
└── Frameworks
├── libbsm.tbd
└── NetworkExtension.framework
Is my Approach for creating a single Network Extension App with Multiple extensions correct or is there any better approach of project organization that will make future modifications/working easier and makes the maintenance better?
I want to keep the logic for each extension separate while having the same, single Main App that manages everything(installing, activating, managing identifiers, extensions, etc).
What's the best approach to establish a Communication from MainApp to each extension separately, without affecting one another? Is it good idea to establish 3 separate IPC Connections(each is a singleton class) for each extension?
Are there any suggestions you can provide that relates to my use case of capturing all the network traffic logs(including HTTP/HTTPS, DNS Records, etc), especially on App to Extension Communication, where my app unable to keep multiple IPC Connections and maintain them separately?
I've been working on it for a while, and still unable to make the Network Extension App work with multiple extensions(each as a new Xcode target).
Main App with single extension is working fine, but if I add new extension, App getting crashed. I suspect it's due to XPC/IPC connection things!
I really appreciate any support on this either directly or by any suggestions/resources that will help me get better understand and make some progress.
Please reach out if in case any clarifications or specific information that's needed to better understand my questions.
Thank you very much
Topic:
App & System Services
SubTopic:
Networking
Tags:
Frameworks
Network Extension
System Extensions
I created 2 iOS projects in Xcode:
Project 1:
4 targets (main app + 3 app extensions)
4 static libraries
the main app's target dependencies include - 3 app extensions and the 4 libs.
the main app's binary is linked to all 4 libs
similarly, each extension is linked to all 4 libs
Project 2:
5 targets (main app + 3 app extensions + 1 framework)
4 static libraries
the main app's target dependencies include - 3 app extensions and the framework
each extension is dependent only on the framework
the framework's target dependencies include all the 4 static libs
As per my understanding, the app bundle size for Project 2 should be less than that of Project 1, since we eliminate duplicating the static libs for each target by using a framework instead.
However, I have found that the bundle size is more for Project 2 as compared to the bundle size of project 1.
I do not understand, why?
Hello,
I have a Cocoa application from which I fork a new process (helper sort of) and it crashes on fork due to some cleanup code probably registered with pthreads_atfork() in Network framework.
This is crash from the child process:
Application Specific Information:
*** multi-threaded process forked ***
BUG IN CLIENT OF LIBPLATFORM: os_unfair_lock is corrupt
Abort Cause 258
crashed on child side of fork pre-exec
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_platform.dylib 0x194551238 _os_unfair_lock_corruption_abort + 88
1 libsystem_platform.dylib 0x19454c788 _os_unfair_lock_lock_slow + 332
2 Network 0x19b1b4af0 nw_path_shared_necp_fd + 124
3 Network 0x19b1b4698 -[NWConcrete_nw_path_evaluator dealloc] + 72
4 Network 0x19af9d970 __nw_dictionary_dispose_block_invoke + 32
5 libxpc.dylib 0x194260210 _xpc_dictionary_apply_apply + 68
6 libxpc.dylib 0x19425c9a0 _xpc_dictionary_apply_node_f + 156
7 libxpc.dylib 0x1942600e8 xpc_dictionary_apply + 136
8 Network 0x19acd5210 -[OS_nw_dictionary dealloc] + 112
9 Network 0x19b1beb08 nw_path_release_globals + 120
10 Network 0x19b3d4fa0 nw_settings_child_has_forked() + 312
11 libsystem_pthread.dylib 0x100c8f7c8 _pthread_atfork_child_handlers + 76
12 libsystem_c.dylib 0x1943d9944 fork + 112
(...)
I'm trying to create a child process with boost::process::child which does basically just a fork() followed by execv() and I do it before the - [NSApplication run] is called.
Is it know bug or behavior which I've run into? Also what is a correct way to spawn child processes in Cocoa applications? As far as my understanding goes the basically all the available APIs (e.g. posix, NSTask) should be more or less the same thing calling the same syscalls. So forking the process early before main run loop starts and not starting another NSApplication in forked child should be ok ...or not?
We are implementing a feature that uses PKPassLibrary.requestAutomaticPassPresentationSuppression to prevent the Wallet from appearing when unlocking a lock. We have already completed the approval process for the entitlement to enable Pass Presentation Suppression.
In most cases, our code snippet works as expected, and the result is .success. However, we are also encountering other results, such as .denied, .alreadyPresenting, and .cancelled or .notSupported, which cause the Wallet to appear for users.
Here's the code snippet we're using:
PKPassLibrary.requestAutomaticPassPresentationSuppression { result in
logger.log(
.info,
"PKPassLibrary suppression result: \(result.description)",
LogContext.homeFeature
)
}
I would appreciate clarification on the following points:
What's the meaning of each result type (.denied, .alreadyPresenting, .cancelled, .notSupported) beyond what is mentioned in the documentation? The documentation here does not provide additional details.
What is the recommended handling for these specific result states? Should we be taking different actions or retries based on each case?
Thank you very much for your help.
Best, Ramiro.
The NSTextViewportLayoutControllerDelegate.textViewportLayoutControllerDidLayout(_:) documentation states that
Layout information on textViewportLayoutController is up-to-date at the point of this call.
however it is easy to put the NSTextViewportLayoutController in a state where after calling textViewportLayoutControllerDidLayout, the value of viewportRange is nil (unexpected) and value of the property viewportBounds is .zero
The TextKit2 sample application found at https://developer.apple.com/documentation/uikit/using-textkit-2-to-interact-with-text makes that assumption as well, and in few places force unwrap the value of viewportRange, that leads to runtime crashes.
This behavior is also discussed in Developer Forum thread about TextKit2 viewport relocation: https://developer.apple.com/forums/thread/761364?answerId=800516022#800516022
How to reproduce:
Run Mac target of LayoutWithTextKit2 sample project found at https://developer.apple.com/documentation/uikit/using-textkit-2-to-interact-with-text
locate menu.rtf file and duplicate its content several times - the goal is to increase the length of the layout text
quickly resize application window - that results in viewport layouts - that result in out-of-bound viewport - that results ina crash
OR quickly scroll down/up to the end of the document using scroller bar on the right side of the window
Reproducible 100%
The situation occurs when the document is not fully laid out, the estimated size (height) of the content exceeds the final (correct) height, and the layoutViewport() function is executed quickly. Resulting in partial viewport layout, and once the viewport moves outside of the document's total height, the viewportLayoutController starts to report viewportRange = nil.
FB19698121
Why does it happen? Is it expected? How to recover from that state? And most importantly, how to make the NSTextLayoutManager display the portion of the document that is currently scrolled to. and how to do it without for ce layout the full document on each viewportLayout()
When I added the ExcelIO library to my app and compiled it, the following error occurred:
Framework 'SwiftSpreadsheet' not found
Linker command failed with exit code 1 (use -v to see invocation)
I added the following to my Podfile and installed it, but the error persists. (No errors occurred during pod install.)
platform :ios, '9.0'
Pods for medical_expense
target 'medical_expense' do
Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'SwiftyTesseract', '~ 2.0'
pod 'SwiftSpreadsheet'
end
Pods for Petty_staff
target 'Petty_staffTests' do
inherit! :search_paths
pod 'ReachabilitySwift'
Pods for testing
end
target 'Petty_staffUITests' do
inherit! :search_paths
Pods for testing
end
Note that "SwiftSpreadsheet" exists in
/Users/ymdakr/MyAppli/Medical_Expense/Pods/Target Support Files/Pods-medical_expense/Pods-medical_expense.debug.xcconfig
and
/Users/ymdakr/MyAppli/Medical_Expense/Pods/Target Support Files/Pods-medical_expense/Pods-medical_expense.release.xcconfig
Only in [Files/Pods-medical_expense/Pods-medical_expense.debug.xcconfig]
What should I do?
I am seeking assistance with how to properly handle / save / reuse NWConnections when it comes to the NWBrowser vs NWListener.
Let me give some context surrounding why I am trying to do what I am.
I am building an iOS app that has peer to peer functionality. The design is for a user (for our example the user is Bob) to have N number of devices that have my app installed on it. All these devices are near each other or on the same wifi network. As such I want all the devices to be able to discover each other and automatically connect to each other. For example if Bob had three devices (A, B, C) then A discovers B and C and has a connection to each, B discovers B and C and has a connection to each and finally C discovers A and B and has a connection to each.
In the app there is a concept of a leader and a follower. A leader device issues commands to the follower devices. A follower device just waits for commands. For our example device A is the leader and devices B and C are followers. Any follower device can opt to become a leader. So if Bob taps the “become leader” button on device B - device B sends out a message to all the devices it’s connected to telling them it is becoming the new leader. Device B doesn’t need to do anything but device A needs to set itself as a follower. This detail is to show my need to have everyone connected to everyone.
Please note that I am using .includePeerToPeer = true in my NWParameters. I am using http/3 and QUIC. I am using P12 identity for TLS1.3. I am successfully able to verify certs in sec_protocal_options_set_verify_block. I am able to establish connections - both from the NWBrowser and from NWListener. My issue is that it’s flaky. I found that I have to put a 3 second delay prior to establishing a connection to a peer found by the NWBrowser. I also opted to not save the incoming connection from NWListener. I only save the connection I created from the peer I found in NWBrowser. For this example there is Device X and Device Y. Device X discovers device Y and connects to it and saves the connection. Device Y discovers device X and connects to it and saves the connection. When things work they work great - I am able to send messages back and forth. Device X uses the saved connection to send a message to device Y and device Y uses the saved connection to send a message to device X.
Now here come the questions.
Do I save the connection I create from the peer I discovered from the NWBrowser?
Do I save the connection I get from my NWListener via newConnectionHandler?
And when I save a connection (be it from NWBrowser or NWListener) am I able to reuse it to send data over (ie “i am the new leader command”)?
When my NWBrowser discovers a peer, should I be able to build a connection and connect to it immediately?
I know if I save the connection I create from the peer I discover I am able to send messages with it. I know if I save the connection from NWListener - I am NOT able to send messages with it — but should I be able to?
I have a deterministic algorithm for who makes a connection to who. Each device has an ID - it is a UUID I generate when the app loads - I store it in UserDefaults and the next time I try and fetch it so I’m not generating new UUIDs all the time. I set this deviceID as the name of the NWListener.Service I create. As a result the peer a NWBrowser discovers has the deviceID set as its name. Due to this the NWBrowser is able to determine if it should try and connect to the peer or if it should not because the discovered peer is going to try and connect to it.
So the algorithm above would be great if I could save and use the connection from NWListener to send messages over.