Post

Replies

Boosts

Views

Activity

Page number of PDF in SwiftUI
I create a UIViewRepresentable to show my PDF inside my SwiftUI app. I want to access the current page number using currentPage?.pageRef?.pageNumber. from the view in which I display the pdf. How to make PDFView Created in func makeUIView(context: UIViewRepresentableContext<PDFDisplayRepresentedView>) -> PDFView Available in the view displaying the pdf so I can access its properties to obtain page number. import SwiftUI import PDFKit struct PDFDisplayView: View { @Binding var pdfDocument : PDFDocument? var body: some View { PDFDisplayRepresentedView(pdfDocument: pdfDocument!) } } struct PDFDisplayRepresentedView: UIViewRepresentable { let pdfDocument: PDFDocument init(pdfDocument: PDFDocument) { self.pdfDocument = pdfDocument } func makeUIView(context: UIViewRepresentableContext<PDFDisplayRepresentedView>) -> PDFView { return createPDFViewUsing(document: pdfDocument) } func updateUIView(_ pdfView: PDFView, context: UIViewRepresentableContext<PDFDisplayRepresentedView>) { pdfView.document = pdfDocument } private func createPDFViewUsing(document : PDFDocument) -> PDFView { let pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) pdfView.document = document ... set up pdfView attributes return pdfView } } view showing pdf where I want to know the page number pseudo code … @State private var pdfDisplayView : PDFDisplayView? …. var body: some View { load the pdf into this view. need to access the page number pdfDisplayView }
0
0
1.5k
May ’22
Library Framework WebPrivacy missing MacOS Ventura
Not developer related but I can't find any help with google and trying to send a crash report to apple just causes spinning beachball. So hoping i can find some much needed help in this forum. Safari runs very slow and every time it launches i get an error producing the log below. Any fix suggestions please. Seeing a WebPrivacy library missing leaves me with no confidence using my mac. I had hoped a software update to Ventura 13.6.3 would resolve but no. Path: /Volumes/VOLUME/*/WebPrivacy.framework/Versions/A/XPCServices/com.apple.WebPrivacy.Service.xpc/Contents/MacOS/com.apple.WebPrivacy.Service Identifier: com.apple.WebPrivacy.Service Version: 34 (34.1.1) Build Info: WebPrivacy-34000000000000~249 (617C13) Code Type: X86-64 (Native) Parent Process: launchd [1] Responsible: Safari [5749] User ID: 501 Date/Time: 2023-11-15 09:15:24.5072 +0000 OS Version: macOS 13.6.3 (22G423) Report Version: 12 Anonymous UUID: EC45AED0-4F92-87DE-6EE8-AE74E4A4BD5E Sleep/Wake UUID: 65B3C137-4BC0-476B-9975-503694B76241 Time Awake Since Boot: 150000 seconds Time Since Wake: 88111 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: /System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy Referenced from: <BF03A141-E3B8-3EC8-B0D3-79F9E987841B> /Volumes/VOLUME/*/WebPrivacy.framework/Versions/A/XPCServices/com.apple.WebPrivacy.Service.xpc/Contents/MacOS/com.apple.WebPrivacy.Service Reason: tried: '/System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file), '/System/Volumes/Preboot/Cryptexes/Incoming/OS/System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file), '/System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file, not in dyld cache), '/System/Library/Frameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file, not in dyld cache) (terminated at launch; ignore backtrace) Thread 0 Crashed: 0 dyld 0x7ff812633c52 __abort_with_payload + 10 1 dyld 0x7ff81264dfd7 abort_with_payload_wrapper_internal + 82 2 dyld 0x7ff81264e009 abort_with_payload + 9 3 dyld 0x7ff8125d28f0 dyld4::halt(char const*) + 375 4 dyld 0x7ff8125cfb71 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 4526 5 dyld 0x7ff8125ce3bd start + 1805 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000002000209 rbx: 0x0000000000000000 rcx: 0x00007ff7b8f8a3c8 rdx: 0x00007ff7b8f8a830 rdi: 0x0000000000000006 rsi: 0x0000000000000001 rbp: 0x00007ff7b8f8a410 rsp: 0x00007ff7b8f8a3c8 r8: 0x00007ff7b8f8a430 r9: 0x0000000000000000 r10: 0x0000000000000127 r11: 0x0000000000000246 r12: 0x0000000000000127 r13: 0x00007ff7b8f8a830 r14: 0x0000000000000001 r15: 0x0000000000000006 rip: 0x00007ff812633c52 rfl: 0x0000000000000246 cr2: 0x0000000000000000 Logical CPU: 0 Error Code: 0x02000209 Trap Number: 133 Binary Images: 0x106f74000 - 0x106f8bfff com.apple.WebPrivacy.Service (34) <bf03a141-e3b8-3ec8-b0d3-79f9e987841b> /Volumes/VOLUME/*/WebPrivacy.framework/Versions/A/XPCServices/com.apple.WebPrivacy.Service.xpc/Contents/MacOS/com.apple.WebPrivacy.Service 0x7ff8125c8000 - 0x7ff8126605ef dyld (*) <d963b325-2b69-3e5a-ab79-8ce1662ec8cc> /usr/lib/dyld External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 153 thread_create: 0 thread_set_state: 5851 VM Region Summary: ReadOnly portion of Libraries: Total=171.8M resident=0K(0%) swapped_out_or_unallocated=171.8M(100%) Writable regions: Total=8452K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8452K(100%)
0
0
1.1k
Nov ’23
Issue installing Xcode 15.3 beta
27" intel Mac Ventura 13.6.4 Developer site says MacOS 13.5 or later required for Xcode 15.3 Beta. Download, Expand .xip, Attempt to open application "You can’t use this version of the application “Xcode-beta” with this version of macOS. You have macOS 13.6.4. The application requires macOS 14.0 or later." Developer site clearly says 13.5 or Later which 13.6.4 is. So why on wasting my time downloading and unarchiving dos it now claim to need 14.0??
1
0
1.5k
Jan ’24
Widgets without timeline on WatchOS
TLDR; Can I have a widget without a Timeline? My previous watch app had a complication. Simply so it can be added to the watch face for a quick launch of the app. However now seeing that method is deprecated in favour of widgets. Can I add a widget without the need for all the Timeline as all I want is a button on the watch face to launch into my app. No data is updated over time so no need for all the extra timeline code.
1
0
1.1k
Apr ’24
Show keyboard on button action
How to show the keyboard for textfield on ToolbarItem(placement: .keyboard)? I have a button and it's action I want is to show the keyboard. On top of which is ToolbarItem(placement: .keyboard) { HStack{ Button(...) TextField("", text: $bindingText) .textFieldStyle(RoundedBorderTextFieldStyle()) .keyboardType(.numberPad) .multilineTextAlignment(.trailing) } } I know keyboard shows with a textfield focused. How though to show the keyboard for ToolbarItem(placement: .keyboard) Textfield if can't show it without showing the keyboard?
2
0
796
Mar ’24
speed up creating multiple instances of @Model Class
@Model class modelData { var property1 : String = "" init(property1: string){ ... } } for item in arrayOfManyStrings { let instanceOfModelData = modelData(property1: item) } Trying to create multiple instances of my modelData. I expect the loop to run and create instanceOfModelData 30k times. However it is far too slow. 30-90 seconds depending on device. If I remove the @Model macro, the same loop take < 5 seconds. I obviously need the @Model for swiftData. How to speed up creating instances of instanceOfModelData when using @Model
0
0
672
Mar ’24
Create an Image from PDFPage in SwiftUI
Im trying to duplicate the display of the built in Files app for documents in my app. How do I convert a page in a PDFDocument to an Image to display as an icon like seen here (from Files App) with SwiftUI. SOLVED: Image(uiImage: (document.page(at: 0)?.thumbnail(of: CGSize(width: 100, height: 100), for: .cropBox))!)
0
0
869
Mar ’24
PDF string output differs between simulator & device.
if I get the string contents of a PDF and print to the console in Xcode . when run on simulator it’s fine but on device some words are missing. same PDF, same code. only difference is simulator and physical device. its only a word or two missing from the page. anyone have any experience or suggestions with PDFKit to explain why a string would be missing the odd word ?
0
0
669
Apr ’24
Unknown network connection Xcode instruments
Users have reported unusually high data usage with my app. So to investigate I have profiled in instruments. My app as expected in using minimal data. However in instruments I see an "Unknown" process. Which sends around 1mb of data every 2 seconds. Can anyone explain what unknown process is? Sorry my question is vague but I'm at the beginning of understanding the instruments outputs so your help is so very much appreciated.
3
0
931
May ’24
Is this a SwiftData migration ?
I know if i change existing properties in a @Model it’s a migration. However if I add a new @Model class(es) that has no relationships to any existing is that still a migration or am i free to add? if free to add, should i create a new model container or can I just add the new Model classes ?
0
0
508
May ’24