Dive into the world of programming languages used for app development.

Post

Replies

Boosts

Views

Activity

Best way to convert HTML to PDF in a C# app on macOS?
I'm working on a cross-platform C# application that converts HTML content to PDF. The goal is to render dynamic HTML pages (including CSS and JavaScript) as high-quality, printable PDF files. Additionally, I need to support features like adding headers/footers, securing PDFs with passwords, and controlling user permissions. While everything works well on Windows, I need some help rendering consistency and handling permissions on MacOS.
0
0
63
1d
macOS 15.1 MFMailComposeViewController.canSendMail() returns false always
In my Catalyst app I use func setupMailComposer() { // Check if the device can send email guard MFMailComposeViewController.canSendMail() else { print("Mail services are not available") showMailErrorAlert() return } // Create and configure the mail composer let mailComposeVC = MFMailComposeViewController() mailComposeVC.mailComposeDelegate = self // Set the email details mailComposeVC.setToRecipients(["example@example.com"]) mailComposeVC.setSubject("Subject for your email") mailComposeVC.setMessageBody("This is the body of the email.", isHTML: false) // Attach a file (optional) if let filePath = Bundle.main.path(forResource: "example", ofType: "pdf"), let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) { mailComposeVC.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "example.pdf") } // Present the mail composer self.present(mailComposeVC, animated: true, completion: nil) } Since I have updated to macOS 15.1 the canSendMail() function returns false although I have configured Apple Mail (like before in 15.0 where it worked flawlessly).
0
0
36
3d
Xcode Arm vector assembly error
Every time a (valid) vector instruction is added to the .s file, xcode report an error (without vector instruction the .s file compile correctly) By example vand q8, q8, q10 found in https://developer.apple.com/forums/thread/104424 give an error What I am missing to tell xcode to accept vector instruction ?
9
0
151
3d
Is this right way to use NSString BytesNoCopy ?
In my project, i am initialising bytes with some character in cpp function, func CreateByteWithVal (), and passing to a function, func CreateNSStringFromCString(_ pPtr : UnsafeMutableRawPointer, _ pLength : Int), in swift using Swift-Cpp interop. CreateByteWithVal () allocates bytes on heap with value "AAAAAAAAAA", also calls swift function CreateNSStringFromCString. And func CreateNSStringFromCString (_ pPtr : UnsafeMutableRawPointer, _ pLength : Int) creates a NSString instance using NSString's BytesNoCopy initialiser using the bytes (pPtr) passed to it in parameter. Cpp code: void CppClass::CreateByteWithVal () { char * bytesForString = (char *) malloc (10); memset (bytesForString, 65, 10); Interop_Swift::CreateNSStringFromCString (bytesForString, 10); } Swift code: public func CreateNSStringFromCString (_ pPtr : UnsafeMutableRawPointer, _ pLength : Int) { let ns_string:NSString = NSString (bytesNoCopy: pPtr, length: pLength, encoding: String.Encoding.utf8.rawValue, freeWhenDone: false) } If we modify the byte values in memory from C++ directly, the NSString instance, which is supposed to be immutable by nature, reflects these changes. Is this approach appropriate, or is there something we're overlooking or need to address? In our project, we are mutating the byte values directly like this, and the changes are being reflected in the NSString instance : memset (bytesForString, 66, 5); Essentially, I want to confirm whether we can use this method to modify values through C++ without directly mutating the NSString instance. For the UI, we'll be reading the NSString instance by creating a native Swift String instance from it, like this: let str:String = ns_string as String Will the value of str remain consistent as long as we ensure that the correct bytes are provided by C++?
2
0
213
1w
Missing libclang_rt.osx.a library on OSX
I tried to install the flang-new compiler from Homebrew on Sequoia OSX. Complex division is broken because file divdc3 is missing. This file comes from libclang_rt.osx.a, a standard LLVM library. This library is missing on OSX. program test integer, parameter :: n=2 complex(kind=8), dimension(n,n) :: V complex(kind=8) :: PER V(1,1)=cmplx(4.0,2.0) V(2,2)=cmplx(5.0,3.0) V(1,2)=0.0 V(2,1)=0.5 PER=cmplx(1.2,1.2) V(:,:)=V(:,:)/PER end program test alainhebert@Alains-MacBook-Air-2 test_complex % flang-new test.f90 Undefined symbols for architecture arm64: “___divdc3”, referenced from: __QQmain in test-fc2bb3.o ld: symbol(s) not found for architecture arm64 flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
2
0
197
3w
using Swift Library from c++ code - calllbacks ?
Hello, Im developing an app entirely with C++, and I need to call various swift functions because it requires the Swift library. Ive seen several posts on forums about C++ callbacks and honestly I dont understand how its done exactly. I get the general idea but I am not able to understand it and make it work. I feel like people throw vague ideas and weird function names and everything gets confusing. Could anyone give me the smallest example that works please ? Just to make sure you know what I mean, here is an example of what I want to do, but you dont have to generate the code exactly for this, I want an example that I can understand please, but the swift code has to depend on a swift library. I dont want to simply call a swift function that returns x*2 ... {1} notif.swift file : coded in swift language include <UserNotifications/UserNotifications.h> function A that show notification in swift code. {2} mainwindow.cpp file : coded in C++ language import notif.swift ?? button connected to slot/function mybuttonclicked. MainWindow::mybuttonclicked(){ std::string my_result = call function A_from_swift_file(argument_1); } --The end --- I wrote the notif.swift with '?' because I dont know how you include the swift file from your cpp code and I could not find that anywhere. Maybe it is obvious, but I would really appreciate getting some help on this, Thank you everyone
4
0
355
Nov ’24
clang multiarch doens't work with precompiled headers
So I found out clang can do multiarch compiles (-arch arm64 -arch x86_64). But Apple seems to have left precompiled header support out. So I built the pch separately for each arch. That all works. The next problem is that one needs to specify -include-pch foo.x64.pch and -include-pch foo.arm64.pch on the command line. This doesn't work on the compile line, since it tries to prepend arm64 AST to a x64 .o file, and vice versa. So there is -Xarch_arm64 and -Xarch_x86_64 . But that option is limited to one argument. But "-include-pch foo.x64.pch" is two arguments. More details of failed attempts here: https://github.com/llvm/llvm-project/issues/114626 And no splitting out the builds isn't the same, because then -valid_arch I don't think skips the other build. This are all libraries being built by Make, and then the universal app built using an Xcode project from the libraries.
2
0
276
Nov ’24
Is it possible to execute machine code on iOS with permission
When Xcode is connected to the mobile phone for debugging, the app that contains the logic of executing machine code runs normally, but if Xcode is disconnected and the app is run alone, it will crash. First use the xcode-run execution function to start the app The machine code logic executes normally Disconnect the phone from xcode Start the app 5.Crash Here is the test code:https://gitee.com/FanChiang_admin/demo.git
1
0
231
Nov ’24
Token is not a valid binary operator in a preprocessor subexpression
I have a relatively unique project layered with file types (top to bottom) SwiftUI, Swift, Objective C, and C. The purpose of this layering is that I have a C language firmware application framework for development of firmware on custom electronic boards. Specifically, I use the standard C preprocessor in specific ways to make data driven structures, not code. There are header files shared between the firmware project and the Xcode iPhone app to set things like the BLE protocol and communication command/reply protocols, etc. The app is forced to adhere to that defined by the firmware, rather than rely a design to get it right. The Objective C code is mainly to utilize the Bluetooth stack provided by iOS. I specifically use this approach to allow C files to be compiled. Normally, everything has worked perfectly, but a serious and obtuse problem just surfaced a couple days ago. My important project was created long ago. More recently, I started a new project using most of the same technology, but its project is newer. Ironically, it continues to work perfectly, but ironically the older project stopped working. (Talking about the Xcode iOS side.) Essentially, the Objective C handling of the C preprocessor is not fully adhering to the standard C preprocessing in one project. It's very confusing because there is no code change. It seems Xcode was updated, but looks like the project was not updated, accordingly? I'm guessing there is some setting that forces Objective C to adhere to the standard C preprocessor rules. I did see a gnu compiler version that did not get updated compared to the newer project, but updating that in the Build Settings did not fix the problem. The error is in the title: Token is not a valid binary operator in a preprocessor subexpression. The offending macro appears in a header file, included in several implementation files. Compiling a single implementation files isolates the issue somewhat. An implementation with no Objective C objects compiles just fine. If there are Objective C objects then I get the errors. Both cases include the same header. It seems like the Objective C compiler, being invoked, uses a different C preprocessor parser, rather than the standard. I guess I should mention the bridging header file where these headers exist, as well. The offending header with the problem macro appears as an error in the bridging header if a full build is initiated. Is there an option somewhere, that forces the Objective C compiler to honor the standard C processor? Note, one project seems to. #define BLE_SERVICE_BLANK( enumTag, uuid, serviceType ) #define BLE_CHARACTERISTIC_BLANK( enumTag, uuid, properties, readPerm, writePerm, value) #define BLE_SERVICE_ENUM_COUNTER( enumTag, uuid, serviceType) +1 #define BLE_CHARACTERISTIC_ENUM_COUNTER( enumTag, uuid, properties, readPerm, writePerm, value) +1 #if 0 BLE_SERVICE_LIST(BLE_SERVICE_ENUM_COUNTER, BLE_CHARACTERISTIC_BLANK) &gt; 0 #define USING_BLE_SERVICE ... #if 0 BLE_SERVICE_LIST(BLE_SERVICE_BLANK, BLE_CHARACTERISTIC_ENUM_COUNTER) &gt; 0 #define USING_BLE_CHARACTERISTIC ... token is not a valid binary operator in a preprocessor subexpression refers to the comparison. BLE_SERVICE_LIST() does a +1 for each item in the list. There is no further expansion. One counts services. The other counts characteristics. The errors are associated with the comparisons.
8
0
427
Nov ’24
Crash due to missing symbols from libc++ [macOS 11.7.10] [Big Sur]
We are seeing a crash on Big Sur 11.7.10 after switching the build system to use Xcode 15 Excerpt from crash Time Awake Since Boot: 1700 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: DYLD, [0x4] Symbol missing Application Specific Information: dyld: launch, loading dependent libraries Dyld Error Message: Symbol not found: __ZNSt3__17codecvtIDiDu11__mbstate_tE2idE Referenced from: /Applications/SecureworksTaegis.app/Contents/MacOS/com.secureworks.agent.daemon.app/Contents/MacOS/com.secureworks.agent.daemon Expected in: /usr/lib/libc++.1.dylib in /Applications/SecureworksTaegis.app/Contents/MacOS/com.secureworks.agent.daemon.app/Contents/MacOS/com.secureworks.agent.daemon Build system has the following specs : ProductName: macOS ProductVersion: 14.3.1 BuildVersion: 23D60 Xcode 15.2 Build version 15C500b CMAKE PROPS set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
5
0
465
Oct ’24
Trace/BPT trap in very simple C code compiled with clang
I wonder if this is correct behavior. I was surprised to get this result when compiling and running the following C code with Apple clang version 14.0.0 (clang-1400.0.29.102) target arm64-apple-darwin21.6.0 on a M1 Pro 12.7.6 with cc -O2 file.c: #include <stdio.h> #include <stdlib.h> unsigned long long factorial(int n) { unsigned long long fac = 1; while (n > 0) fac *= n; return fac; } int main() { return factorial(1); } Compiling with -O2 and running this code gives "Trace/BPT trap". Checking with LLDB: $ lldb ./a.out (lldb) target create "./a.out" Current executable set to '/Users/engelen/Projects/Euler/a.out' (arm64). (lldb) run Process 79580 launched: '/Users/engelen/Projects/Euler/a.out' (arm64) Process 79580 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x100003fb4) frame #0: 0x0000000100003fb4 a.out`main at 20.c:9:3 [opt] 6 unsigned long long fac = 1; 7 while (n > 0) 8 fac *= n; -> 9 return fac; 10 } 11 12 int main() The loop is non-terminating. But a breakpoint trap is triggered at the return statement. The code should just hang in the loop IMO, not trap, because it never updates variable n (a correct factorial function should decrement n). Never seen this before (not since I started wiring C code in the 80s.) If I change the update *= into += then there is no trap.
1
0
318
Oct ’24
Is there any way to write a screensaver for macOS using Python Pygame?
I want to be able to write a cross-platform screensaver that works on both Windows and macOS using the Pygame 2D graphics library in Python. On Windows, this is super easy - you just write your program with three possible command line arguments: /p for preview mode, /c for the configuration dialog mode, and /s for the actual full-screen screensaver mode. Then you just use pyinstaller to build an .exe file and rename the extension to .scr, and you're good to go. However, it seems that making a screensaver on macOS is a pretty convoluted process, and there was stuff about specific Objective-C functions that you had to write, and I didn't really understand the documentation. Could you please tell me if there is any way to simply get my Python Pygame program to build as a proper .saver file? Thanks!
1
0
318
Oct ’24
Why is there a problem passing parameters from Swift to the shared Kotlin class when developing iOS applications using Kotlin Multiplayer Development in Android Studio
I use Kotlin Multiplayer Development to develop iOS applications. I access the methods in the Kotlin class of the shared module in the ContentView.swift file. Functions without parameters can be used normally, but functions with parameters cannot. For example, the 78th line of code on the left side of the screenshot works, but the 79th line does not. Can someone please tell me the reason? Thank you!
1
0
465
Oct ’24
C++
Hi To All. I have recently started a course that will teach me how to use C++ coding, so I can improve my career prospects. I have come across an obstacle when it comes to downloading a programming tool and that is, they are not compatible with Sequoia 1.15.1. This includes Xcode, Clion, Codelite and Vs, I am at a crossroads in my decision making on how to overcome this problem please. Can someone help withme with a solution please. Thank you.
2
0
366
Oct ’24
Undefined symbols for architecture x86_64:
I am developing a simple camera JNI interface program in Objc. I managed to compile. But I get the following link error. I use the following command. Is there anything I can add to solve this problem? Note that I use Intel MacMini. g++ -framework Foundation -framework AVFoundation CameraMacOS.m Undefined symbols for architecture x86_64: "_CMVideoFormatDescriptionGetDimensions", referenced from: _openCamera in CameraMacOS-517c44.o _listWebcamNamesAndSizes in CameraMacOS-517c44.o "_CVPixelBufferGetBaseAddress", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferGetBytesPerRow", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferGetHeight", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferGetWidth", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferLockBaseAddress", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o "_CVPixelBufferUnlockBaseAddress", referenced from: -[CaptureDelegate captureOutput:didFinishProcessingPhoto:error:] in CameraMacOS-517c44.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
2
0
435
Oct ’24
Applescript text item delimiters not working
I have a string of the form “Mon 22nd April”. I’m trying to extract the day (i.e. Mon), the date (i.e. 22nd) and the month (i.e. April) using this Applescript: set originalDateString to “Mon 22nd April” -- Extract the components by splitting the string set AppleScript's text item delimiters to " " set dayOfWeekAbbrev to text item 1 of originalDateString set dayOfMonth to text item 2 of originalDateString set monthName to text item 3 of originalDateString When I run this on its own it works as expected: dayOfWeekAbbrev is set to “Mon” dayOfMonth is set to “22nd” monthName is set to “April” When I run this inside a bigger script involving Numbers, the text item delimiters fails to work, no compile or run time errors occur and I end up with: dayOfWeekAbbrev is set to “M” dayOfMonth is set to “o” monthName is set to “n” I.e the first three characters of the string. If I replace originalDateString with the literal string “Mon 22nd April” I get the same result. In other words, text items and being recognized as individual characters, no delimiter (or delimiter is null). Totally confused.
5
0
484
Oct ’24
Application doesn't start: Namespace DYLD, Code 1 Library missing
I have a multi-platform application made with Delphi which uses FTDI D2XX drivers. All is well in other platforms but i have this issue in MacOS when i try to start the application: Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: libftd2xx.dylib Referenced from: <CD2148C0-F76F-35D5-8E65-2BE51F201302> /Users/USER/*/USB_Editor.app/Contents/MacOS/USB_Editor Reason: tried: 'libftd2xx.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibftd2xx.dylib' (no such file), 'libftd2xx.dylib' (no such file), '//libftd2xx.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS//libftd2xx.dylib' (no such file), '//libftd2xx.dylib' (no such file) (terminated at launch; ignore backtrace) If i try to run the executable i get a similar error which includes the users/user folder in the paths specified above. So if i copy libftd2xx.dylib to users/user the app can start from the executable and the USB library works well. The library is bundled in Contents/Framework as this seems to be the best (or only) accepted practice. Btw the app only starts during deployment if the library is found in Contents/MacOS. Library version is the most recent from FTDI site for the ARM architecture and followed their instructions to install. If i try the otool command on the library i get this: otool -L libftd2xx.dylib libftd2xx.dylib: libftd2xx.dylib (compatibility version 1.1.0, current version 1.4.30) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1) /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2202.0.0) I'm a Mac user since last week so my knowledge of the system is not so good yet (:
2
0
434
Oct ’24
Flutter barcode_scan2: ^4.3.3 non funziona bene su iOS
Stiamo sviluppando una App per iOS con Flutter, usiamo: Flutter barcode_scan2: ^4.3.3. Gli smartphone iOS cercano di riconoscere il tipo di codice a barre letto. Se il sistema crede che il codice sia gtin13 ma le cifre risultano 12, aggiunge uno zero iniziale. Come potremmo risolvere ? Grazie Settore sviluppo App Firenze Web Division
1
0
295
Oct ’24
How to use Xcode's provided tkinter module ?
Hi there, I’m having issue with the python3 installation provided by Xcode’s toolchain. I’m currently writing a LLDB plugin, using the LLDB python API, to allow the user to visualize audio data from the current debugged program in a GUI, using tkinter and matplotlib. I'm using those because I'm developing a cross-platform plugin, as I'm initially a Linux developer who wants to make this available to my fellow Apple audio devs. My issue arise at least on two setups MacOS 12.7.6 Monterey with Xcode 14.2 MacOS 14 with Xcode 15.4 (not my machine) Because I wanna support Xcode’s toolchain, I want to use Xcode’s lldb. Xcode’s lldb uses Xcode’s provided python, which I’m having issues with when loading tkinter.The issue can be reproduced like this : > xcrun python3 -c "import tkinter;tkinter._test()" macOS 12 (1207) or later required, have instead 12 (1206) ! zsh: abort xcrun python3 -c "import tkinter;tkinter._test()" On MacOS 14 the version numbers are : macOS 14 (1407) or later required, have instead 14 (1406) ! You can see it fails to load tkinter. From what I understood so far, it looks like the tkinter/tcl/tk version distributed with Xcode is not supported by MacOS ?I checked and the imported tkinter module is definitely the one provided by Xcode’s toolchain : # Checking where tkinter is installed > fd "^tkinter$" /Applications/Xcode.app /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/tkinter/ /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/ /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages/future/moves/tkinter/ # Checking that Xcode python uses the right module - it matches > xcrun python3 -c "import tkinter;print(tkinter.sys.modules['tkinter'])" <module 'tkinter' from '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py'> I can get a working tkinter working by installing it using homebrew or macports, but I’m not able to use it with Xcode’s python installation. I tried overwriting sys.path to force Xcode’s python to import homebrew’s tkinter module, but it still loads Xcode’s tkinter .so. In the crash report I can see it indeed loads tcl/tk 8.5 and loads _tkinter.cpython-39-darwin.so from Xcode. I could disable the SIP (System Integrity Protection) to force to load another version of the library, but that wouldn’t be something I can ask the users. On the LLDB forum, they advise against using another python interpreter that the one provided by the toolchain. So is there a way to get the provided tkinter/tcl/tk installation to work ? If not I’m confused about why it’s provided in the first place. Thanks a lot for your time and please tell me if you have any questions. PS: if possible i'll post the head of the crash report in the comment of this post
5
1
1.1k
Sep ’24