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

Post

Replies

Boosts

Views

Activity

Check if my app has a new version on AppStore
I would like to manually check if there are new updates for my app while the user is in it, and prompt him to download the new version. Can I do this by checking the version of my app in the app store - programatically?I found a solution by Checking response of my app itunesRL, i want to confirm if there is an official method, if not can i use this methode safely.https://stackoverflow.com/questions/6256748/check-if-my-app-has-a-new-version-on-appstore
4
0
23k
Feb ’19
iOS cpu/gpu/battery temperature readings
Good day! I'm interested in if there is any way to query CPU/GPU/Battery temperature values on recent iOS systems? I've tried to search forums for "cpu temp", "ios temperature", "battery temperature" etc., but didn't find anything. There was only mentioned some old private API which was supposed to work somehow for iOS<10. All the examples I've found didn't even compile. All the requests and suggestions are pretty old and seems irrelevant. So I decided to bump this topic. Are there any updates? Any hints and suggestions are highly appreciated! Best regards!
4
0
5.1k
Dec ’21
Called endBackgroundTask but not working
When my app enter to background, I start a background task, and when Expiration happens, I end my background task. The code likes below: backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ if (backgroundTask != UIBackgroundTaskInvalid) { [[UIApplication sharedApplication] endBackgroundTask:backgroundTask]; backgroundTask = UIBackgroundTaskInvalid; [self cancel]; } }); }]; When the breakpoint is triggered at the endBackgroundTask line, I also get the following log: [BackgroundTask] Background task still not ended after expiration handlers were called: <UIBackgroundTaskInfo: 0x282d7ab40>: taskID = 36, taskName = Called by MyApp, from MyMethod, creationTime = 892832 (elapsed = 26). This app will likely be terminated by the system. Call UIApplication.endBackgroundTask(:) to avoid this. The log don't appear every time, so why is that? Is there something wrong with my code?
2
0
1.7k
May ’23
objc: Class MyClass is implemented in both dylibs
I have a static library staticLib.a which is witten mostly in C++ with one additional obj-C class MyClass. There are two dynamic libs, dynamicLib_A. dylib and dynamicLib_B.dylib are linked with the static lib. When starting the application which loads the dynamic libs at runtime it comes out the following warning: objc[15078]: Class MyClass is implemented in both /path/to/libdynamicLib_A.dylib (0x104f03f90) and /path/to/libdynamicLib_B.dylib (0x10dbf3f48). One of the two will be used. Which one is undefined. It can be found that the C++ names are mangled. For instance, both libdynamicLib_A.dylib and libdynamicLib_B contains string: __ZN18MyClassBC2Ev It looks like the obj-c class name is not mangled. Both libdynamicLib_A.dylib and libdynamicLib_B contains string: 00000000012b7f48 S OBJC_CLASS$_MyClass Question: How to avoid this warning? Why it complains only about the obj-c class but not the C++ class? Is this issue related to name mangling?
2
0
547
Aug ’23
Dictionary objectForKey Crashing on Older Devices After Software Update
My apps were working fine and suddenly started crashing on older devices. I have iPhone 7 Plus to test and after updating it to 15.7.8, the installed apps which were working before started crashing. The specific code where they are crashing is if([testStats objectForKey:TEST_STATS_ARRAY]) { statArray = [testStats objectForKey:TEST_STATS_ARRAY]; } else { statArray = [[NSMutableArray alloc] init]; [testStats setValue:statArray forKey:TEST_STATS_ARRAY]; }
2
0
424
Aug ’23
how to use Live Acitivity in objective-c project?
I have a history objective-c project, and now i want to use Live Acitivity feature in that objc project. first i implement a live activity in swift project, and it works well on iphone devices. then i copy same codes from swift project to objective-c project, build and run on same iphone device, no error or warning generates, but Live Activity UI can't seen. can someone tell me how to fix it ? and only swift project can support Live Activity ?
1
1
467
Aug ’23
dispatch_once weird behavior
Hi! I have a xcode workspace with first objectiveC framework (let’s call it framework#1). This framework has some singletons (+(instancetype)shared using the dispatch_once idiom. This code is pretty straight forward and used everywhere : + (instancetype)shared { static dispatch_once_t onceToken; static OGAKeyManager *instance = nil; dispatch_once(&onceToken, ^{ instance = [[self alloc] init]; }); return instance; } I have a second framework (framework#2) in Swift that uses theses singletons (the framework#1 is added as do not embeed in the framework settings). And I have an application that uses both frameworks. If I make a breakpoint inside the dispatch_once alloc/init, I see that I enter 2 times : once when the shared method is called from framework#1 and another one when it’s called from framework#2. How is that even possible ? Isn't dispatch_once supposed to handle this ? I asked chatGPT, it points out to some objC/Swift interoperability, but honestly, I don't see what I can do to make it work correctly. There is no circular dependency (framwork#2 uses framwork#1, but framwork#1 has no clue of framwork#2 existence) Maybe it has something to do with sandbox, but I don't see how can it be. Does anyone experienced some weird behavior like this ? Thanks
7
0
875
Sep ’23
Using VoiceOver's accessibilityCustomActions and supporting Voice Control for the group subviews
Hi, My app supports VoiceOver and VoiceControl, and I find it hard or perhaps even impossible to support both when it comes to grouping accessibility elements. I have an element containing multiple subviews, and I want to define it as a group of accessibility custom actions to enhance VoiceOver navigation. (So that the user can focus on the entire element, and just swipe up or down if they want to activate one of its subviews as a custom action). To do that, I'm setting isAccessibilityElement to YES and I'm using accessibilityCustomActions where I create a custom action for each of this element's subviews. This works fine and presents the accessibility custom actions as expected. The struggle comes when I try to combine it with Voice Control. Since the element contains multiple subviews, I want each of these subviews to be accessible when using Voice Control with item numbers, for example. Instead, Voice Control is setting a number only on the entire element, ignoring its subviews. This is not functional because each of these subviews performs a different action when activating it. I found that VoiceControl is only numbering subviews when the parent's isAccessibilityElement is set to NO. And indeed, when changing to NO, the subviews are getting numbered, but the custom actions group break, and VoiceOver treats each element as a separate accessibility element. So I can't use accessibilityCustomActions AND supporting VoiceControl. Is this an intended behavior defined by Apple? Or, is there anyway I can support them both?
0
0
334
Oct ’23
Get the number of Apple Silicon performance cores in Python
Simple question, I want to determine the number of performance cores in an Python script (better a Python app frozen with PyInstaller, which could make a difference). there are some ways to get the number of CPUs/cores like os.cpu_count(), multiprocessing.cpu_count() or psutil.cpu_count() (the later allowing discrimination between physical and virtual cores). However, Apple Silicon CPUs are separated into performance and efficiency cores, which you can get with (e.g.) sysctl hw.perflevel0.logicalcpu_max for performance and sysctl hw.perflevel1.logicalcpu_max for efficiency cores. Is there any way to get this in Python besides running sysctl and get the shell output? Maybe using the pyobjc package?
0
0
628
Nov ’23
TLS1.3 connection Restriction
I created one application using Websocket when TLS version was 1.2 connection establishment working fine but when server team update TLS1.2 to TLS1.3 due to security enhancement in my project i am getting SSL Handshake fails with code 9836. and NSOSStatusErrorDomain with code 9836. here is my info.plist NSAppTransportSecurity NSAllowsArbitraryLoads NSExceptionDomains myserver.com NSIncludesSubdomains NSExceptionMinimumTLSVersion TLSv1.3 So my query here is that even if we specify TLSv1.3 for myserver.com as: NSExceptionMinimumTLSVersion TLSv1.3 we want to restrict only to TLS1.3, even if my request fails, how to achieve this?
1
0
347
Dec ’23
openpty && security server
hi, I am using the openpty function in my code to run an interactive command, for example, "hdiutil convert -format UDRO /tmp/myFileName.sparsebundle -o ./test". The file myFileName.sparsebundle is an encrypted disk with a password. When running this command, it triggers the security server and a password input dialog box pops up. I don't want this dialog box to appear, and I want to provide the password through the fd_master returned by openpty. How can I achieve this?
1
0
407
Dec ’23
duplicate symbols error
Im getting a duplicate symbols error when I build my Xcode project and Xcode doesn't specify what or where in my code is there a duplicate: "1 duplicate symbols" "Showing Recent Issues Linker command failed with exit code 1 (use -v to see invocation) " #include <stdio.h> #include <IOKit/IOKitLib.h> typedef struct { uint32_t datasize; uint32_t datatype; uint8_t data[32]; } SMCVal_t; io_connect_t conn; kern_return_t openSMC(void) { kern_return_t result; kern_return_t service; io_iterator_t iterator; service = IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("AppleSMC"), &iterator); if(service == 0) { printf("error: could not match dictionary"); return 0; } result = IOServiceOpen(service, mach_task_self(), 0, &conn); IOObjectRelease(service); return 0; } kern_return_t closeSMC(void) { return IOServiceClose(conn); } kern_return_t readSMC(char *key, SMCVal_t *val) { kern_return_t result; uint32_t keyCode = *(uint32_t *)key; SMCVal_t inputStruct; SMCVal_t outputStruct; inputStruct.datasize = sizeof(SMCVal_t); inputStruct.datatype = 'I' << 24; //a left shift operation. turning the I into an int by shifting the ASCII value 24 bits to the left inputStruct.data[0] = keyCode; result = IOConnectCallStructMethod(conn, 5, &inputStruct, sizeof(SMCVal_t), &outputStruct, (size_t*)&inputStruct.datasize); if (result == kIOReturnSuccess) { if (val -> datasize > 0) { if (val -> datatype == ('f' << 24 | 'l' << 16 | 't' << 8 )) { //bit shifting to from 32bit operation associated with the ASCII charecters 'f', 'l', and 't' float temp = *(float *)val -> data; return temp; } } } return 0.0; } double getTemperature(char *key) { SMCVal_t val; kern_return_t result; result = readSMC(key, &val); if(result == kIOReturnSuccess) { if (val.datasize > 0) { printf("val.datasize: %u\n", val.datasize); if (val.datatype != 0) { double temperature = (double)val.data[0]; return temperature; } } } return 0.0; } double convertToFahrenheit(double Fahrenheit) { return (Fahrenheit * (9.0 / 5.0)) + 32.0; } int main(void) { kern_return_t result; result = openSMC(); if(result == kIOReturnSuccess) { double temp = getTemperature("TC0P"); double temperatureInFahrenheit = convertToFahrenheit(temp); printf("temp: %.2f\n", temperatureInFahrenheit); result = closeSMC(); } return 0; }
2
0
640
Jan ’24
Xcode cannot recognize generic methods
In objective-c, I created a category, like @interface NSArray <__covariant ObjectType> (ppEx) @end Look at this ObjectType, I wrote a method like - (NSArray *)pp_map:(id(^)(ObjectType element))block;which act like the map function in Swift. you can call it like NSArray <NSString *>*values = @[@"1", @"2", @"3", @"4"]; NSArray *valueMap = [values pp_map:^id _Nonnull(NSString * _Nonnull element) { return [NSString stringWithFormat:@"Hello %@", element]; }]; Now I need to add a property like mapBlock, I want to realize the same func; @property (nonatomic, copy) NSArray *(^mapBlock)(id(^paramBlock)(ObjectType element)); I did it. But when I call this method in Xcode, it can't complete automatically. values.mapBlock(^id _Nonnull(ObjectType _Nonnull element) { }) It's unable to recognize type NSString, and always show ObjectType which can cause error. I can manually change it to NSString, but it's too complicated. I think it's a problem of Xcode. Can anybody help me?
1
0
316
Jan ’24