SwiftUI ShareLink Exporting Issues with Custom CSV UTType

Hello!

I'm working on an app that generates CSV files in memory and allows users to export them through a ShareLink. I am using a custom UTType for my CSV files as .commaSeparatedText exports a .txt file, and a custom UTType was proposed as a workaround here: https://www.hackingwithswift.com/forums/swiftui/sharelink-problem-with-csv-file/21194.

The app works on a development build, albeit with a lot of entitlement and sandboxing errors, but fails in production (sideloaded archive). Development errors are as follow:

Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "(originator doesn't have entitlement com.apple.runningboard.primitiveattribute AND originator doesn't have entitlement com.apple.runningboard.assertions.frontboard AND target is not running or doesn't have entitlement com.apple.runningboard.trustedtarget AND Target not hosted by originator)" UserInfo={NSLocalizedFailureReason=(originator doesn't have entitlement com.apple.runningboard.primitiveattribute AND originator doesn't have entitlement com.apple.runningboard.assertions.frontboard AND target is not running or doesn't have entitlement com.apple.runningboard.trustedtarget AND Target not hosted by originator)}>

(501) personaAttributesForPersonaType for type:0 failed with error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.mobile.usermanagerd.xpc was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.mobile.usermanagerd.xpc was invalidated: failed at lookup with error 159 - Sandbox restriction.}

Received port for identifier response: <> with error:Error Domain=RBSServiceErrorDomain Code=1 "Client not entitled" UserInfo={RBSEntitlement=com.apple.runningboard.process-state, NSLocalizedFailureReason=Client not entitled, RBSPermanent=false}

The additional production error I'm encountering is the following:

Type "com.sunkensplashstudios.VRCRoboScout.csv" was expected to be declared and exported in the Info.plist of App.app, but it was not found.

I have, to the best of my knowledge, declared these data types properly:

Relevant code is below:

extension UTType {
    static var CSVData: UTType { UTType(exportedAs: "com.sunkensplashstudios.VRCRoboScout.csv") }
}

struct CSVData: Transferable {
    var csv_string: String
    static var transferRepresentation: some TransferRepresentation {
        DataRepresentation(exportedContentType: .CSVData) { csv in
            csv.csv_string.data(using: .utf8)!
        }
    }
}

ShareLink(item: CSVData(csv_string: csv_string), preview: SharePreview("VRC RoboScout Scouting Data.csv", image: Image(systemName: "tablecells"))) {
    Text("Download").padding(10)
        .background(settings.accentColor())
        .foregroundColor(.white)
        .cornerRadius(20)
}

Any ideas?

Type "com.sunkensplashstudios.VRCRoboScout.csv" was expected to be declared and exported in the Info.plist of App.app, but it was not found.

I believe, this describes the problem. Looks like declaration is not included into the Info.plist file of the application bundle. One of the reasons could be that the application is multi platform, and Xcode displays the screenshotted interface for another platform. Make sure that the declaration is present in the resulting Info.plist file.

That seems like it could be it. The keys are not present in the Info.plist within the archived app package. Why would this happen? I cannot find anywhere else to set the keys for the type. Additionally, when I try to manually create the keys in the Custom iOS Target Properties, they are not saved and disappear if I reopen the project file.

I've updated the packaging configuration in the build settings to point to the Info.plist for "Any SDK" under release. This seems to have fixed the error with the app finding the types, but the entitlement error still persists and the ShareLink comes up but does not display any options for saving the file.

SwiftUI ShareLink Exporting Issues with Custom CSV UTType
 
 
Q