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

Post

Replies

Boosts

Views

Activity

dateFromString results in nil
In a completely new project using Objective-C, when using "NSDateFormatter" under the conditions mentioned, setting initWithLocaleIdentifier to "NSCalendarIdentifierGregorian" results in "dateFromString" returning nil. This issue is occurring specifically in iOS 18 beta 1 and 2, and it's causing me significant trouble. This process works correctly on iOS 17 and earlier versions. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setTimeStyle:NSDateFormatterFullStyle]; [formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:NSCalendarIdentifierGregorian]]; [formatter setDateFormat:formatStr]; NSDate *date = [formatter dateFromString:formatStr]; "date" is nil.
4
2
675
Jun ’24
Exclude C runtime library from linking?
Hi, I am writing my own little toy programming language and when I try to link the binary object file (.o file) it requires a _main symbol. I wonder if there is a way to exclude this, presumably, a C runtime requirement? Is it safe to provide a stub _main symbol, or provide a the _main as the entry point to my own little runtime? What is the correct way to invoke the linker with the appropriate flags?
2
0
464
Jul ’24
Create code at runtime on iOS: possible any more?
I'm the developer of 8th (https://8th-dev.com), which compiles the program at run-time, on the device. There used to be an iOS version which worked, but it seems things have changed since then. I'm trying to distribute an iOS version of an app written in 8th, and am encountering "SIGKILL - CODESIGNING" when trying to execute freshly compiled code. I am doing the 'sys_icache_invalidate' thing after writing into a mmap'ed bit of memory (rwx). I'm not writing into memory that was codesigned, so I don't know why the error is that. Anyway, the question is: is it possible any more to do what I used to be able to do?
5
1
738
Jul ’24
gfortran error
I am getting an following error while compiling the Fortran file with "gfortran TEST_1_fortran_only_fixed.f" ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libSystem.tbd' for architecture x86_64 collect2: error: ld returned 1 exit status Please help me to solve this issue
1
0
363
Jul ’24
Objective-C++ confuses two private classes with the same name
I think I found a bug in the Objective-C++ compiler, linker, or runtime. Here’s the scenario: We have a macOS app written in Swift. To control hardware from a 3rd party manufacturer, we use a couple SDKs provided by the manufacturer. The SDKs use dynamically loaded libraries and the interface is defined in C++ headers. To bridge between our Swift code and the C++ APIs we have a private Cocoapod that wraps the 3rd party interface with Objective-C++ classes. The two SDKs each provide an interface for discovering attached devices using a callback class that the programmer provides. By accident we named both callback implementations DiscoveryCallback, but this was not a compiler error because neither class was publicly declared, and each was defined in the .mm file where it was used. However, the problem we’re seeing is this: We want to discover Videohub devices, so we register a new instance of DiscoveryCallback (defined in the same .mm file as this code) with the Videohub SDK. A Videohub device is connected and the SDK calls a method on our callback. Surprise! The callback we registered in step 1 was actually the one intended for Decklink devices, defined in a completely different .mm file. This violates all sorts of assumptions and our app quickly crashes. The funny thing is, the two implementations of DiscoveryCallback have completely different method names. The Videohub SDK is supposed to be calling NewVideohubDevice, yet somehow it successfully calls DeckLinkDeviceArrived on an instance of a class it shouldn’t even know about. So the compiler has checked that our intended DiscoveryCallback matches the protocol that the SDK expects, but at runtime the compiled code instantiates a completely different implementation of DiscoveryCallback and somehow doesn’t immediately fail; we still call a method on it that doesn’t even share a name with the intended target. I imagine at this point the method names are long forgotten and are just pointers in a table. I don’t know if this is a bug in the compiler, the Objective-C++ runtime, or if this is just “working as designed” undefined behavior that I should have avoided by not giving two private classes the same name. I know it’s possible to use a private API simply by redeclaring it in my own code, and this seems related to that, but I feel like the compiler or linker should have warned me that I had two implementations of the same class, or if that is not an error, then the runtime should have instantiated the class that was privately defined in the same source file where it was used. Obviously I can’t share our entire project; I’d like to provide some sample code that replicates the issue, but I don’t have time to do that right now. I’m posting this to see if other developers have had a similar experience.
2
1
559
Jul ’24
OTA-updates for objective-c application
Hello! I have an application written in Objective-c/C++ and I would like it to have support for OTA updates. I implemented the logic through two executable files, one of which was responsible for launching and updating the first, but this option did not pass Apple's review. Could you tell me how this functionality can be implemented and so that it meets the requirements of the App Store.
1
0
359
Jul ’24
TestIDs on iOS concatenated - React Native
Hey guys, so I have a problem regarding the testIDs on my react native that is reproducible only on iOS DOM meaning that I set the ids individually on the elements on a page but the problem is that somehow the ids are concatenated between them and inherits all the ids under the parent. As you can see and imagine in the accessibility inspector, this is what my DOM looks like. I want to point out that the problem does not reproduce on Android, only on iOS. Can somebody help me with this and tell me if there is a way to disable this concatenation? What's relevant to tell you it's the fact that I need each element to have an unique ID for browserstack automated tests. But as you can see in the image an element contains all IDs concatenated for some reason. And here is the code for the page with this issue
0
0
457
Jul ’24
Does objc_setAssociatedObject() work reliably when used with "bridgeable" Core Foundation types?
I'm investigating an odd problem that surfaced with macOS Sequoia related to CoreGraphics (CGColorSpaceCreateWithICCData()). I couldn't find a reliable way to track the lifetime (retain/releases) of a CGColorSpaceRef (any pointers appreciated) so I was hoping to use objc_setAssociatedObject() to attach an instance of my own class that would be deallocated when the "owning" CGColorSpaceRef is deallocated. In this way I could set a breakpoint on my own code, presumably invoked when the CGColorSpaceRef is itself going away. While objc_setAssociatedObject() does seem to work, the results don't seem deterministic. Is it because objc_setAssociatedObject() simply won't work reliably with CF types?
6
0
614
Aug ’24
Can't find Python.h anywhere on Mac
I am trying to embed a python file that uses a python library in c, to do this I need to include python.h but I don't see it anywhere on my mac. Right now when I try to compile I just get a missing Python.h compile error. I tried using the search bar to find it in /usr and /library. Neither had the file. I tried doing #include <Python/python.h> and that doesn't change anything. Is trying to setup a virtual env the issue?
2
0
528
Aug ’24
NSKeyedUnarchiver.unarchivedObject(ofClass: , from: ) doesn't work with custom UIButton
My app creates dynamic copies of UI controls that are based on a custom UIButton subclass using this legacy approach: let archivedButton = try NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: false) guard let buttonDuplicate = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(archivedButton) as? UIWagerButton else {return nil } I am currently trying to work passed the deprecation of NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data: Data) Per the guidance, I should be replacing that line with the following and ensuring that the custom class implements NSSecureCoding guard let buttonDuplicate = try NSKeyedUnarchiver.unarchivedObject(ofClass: UIWagerButton.self, from: archivedButton) else {return nil} However, while the code does compile and run, decoding the data reference throws the following error: value for key 'UIButtonStatefulContent' was of unexpected class 'NSMutableDictionary' I can only assume that if I get passed this specific property, there will be other properties that are also problematic. Question: Is this a bug? Or, am I now responsible for navigating the underlying property matrix of this UIControl to specifically, manually, handle the encoding and decoding of each of it's properties?
0
0
407
Aug ’24
Applescript seems to run in Rosetta on M2
When calling a perl script from an apple script (by dropping a file on it), I get the error: Can't load '/Library/Perl/5.34/darwin-thread-multi-2level/auto/Encode/Encode.bundle' for module Encode: dlopen(/Library/Perl/5.34/darwin-thread-multi-2level/auto/Encode/Encode.bundle, 0x0001): tried: '/Library/Perl/5.34/darwin-thread-multi-2level/auto/Encode/Encode.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Perl/5.34/darwin-thread-multi-2level/auto/Encode/Encode.bundle' (no such file), '/Library/Perl/5.34/darwin-thread-multi-2level/auto/Encode/Encode.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) at /System/Library/Perl/5.34/XSLoader.pm line 96. at /Library/Perl/5.34/darwin-thread-multi-2level/Encode.pm line 12. When I call the script manually from terminal, it runs fine. Why is Applescript running as X86 on M2?
2
0
420
Sep ’24
xcode not showing output
Hi I was using Xcode for c++ (for competitive programming purposes, not sure if this is the standard choice but using it anyway) I included a &lt;bits/stdc++.h&gt; to the include file for XCode.app and they didn't show any error. But then when I ran my code, it showed "Build Succeeded" although no output was visible.
1
0
382
Sep ’24
Undefined symbol: _c2i_ASN1_INTEGER when building my projec for iOS 18
Note that I am trying to build my project for IOS 18 using XCode version 16 Beta 6. I have version 18.0 of the iOS beta installed on my iPhone. My project includes pods for Firebase and GRPC-Core. I ran pod update and it installed Firebase (11.1.0), BoringSSL-GRPC 0.0.36, OpenSSL-Universal 3.3.1000, and gRPC-Core 1.65.5. When I try to build my project I encounter the following error: Undefined symbol: _c2i_ASN1_INTEGER This symbol is not referenced in my code. It's unclear which pod references this symbol - although Firebase is a likely candidate. Is anyone else encountering this issue? I'm wondering if I could safely go back to a version of Firebase that does, as the previous version I had installed (10.22.0) didn't have this issue.
2
0
445
Sep ’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
818
Sep ’24