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

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

Crash while reading data from keychain
Hi, I have observed this crash, can anyone pls help finding its root cause - Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000008 VM Region Info: 0x8 is not in any region. Bytes before following region: 4374659064 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 104c00000-104c04000 [ 16K] r-x/r-x SM=COW ... for Endpoint Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [2452] Triggered by Thread: 1 Thread 0 name: Dispatch queue: com.example Thread 0: 0 libsystem_kernel.dylib 0x00000001b25d22d0 0x1b25ce000 + 17104 1 libsystem_kernel.dylib 0x00000001b25d1660 0x1b25ce000 + 13920 2 libdispatch.dylib 0x00000001849c7888 0x1849ab000 + 116872 3 libdispatch.dylib 0x00000001849c7c24 0x1849ab000 + 117796 4 libxpc.dylib 0x00000001cfb52e68 0x1cfb45000 + 56936 5 Security 0x000000018c319090 0x18c2f9000 + 131216 6 Security 0x000000018c319b38 0x18c2f9000 + 133944 7 Security 0x000000018c3a4c0c 0x18c2f9000 + 703500 8 Security 0x000000018c3a4fd0 0x18c2f9000 + 704464 9 Security 0x000000018c3a385c 0x18c2f9000 + 698460 10 Security 0x000000018c3a26c8 0x18c2f9000 + 693960 11 Security 0x000000018c3a2ff4 0x18c2f9000 + 696308 12 Security 0x000000018c3a4ed8 0x18c2f9000 + 704216 13 Security 0x000000018c3a0a1c 0x18c2f9000 + 686620 14 Security 0x000000018c3a40a0 0x18c2f9000 + 700576 15 common 0x000000010836df2c -[KeyChainClient queryValueAsDataWithKey:withStatus:withAccessGroup:thisDeviceOnly:] (in common) (KeyChainClient.mm:53) 16 common 0x000000010836e274 -[KeyChainClient getValueAsDataWithKey:withAccessGroup:thisDeviceOnly:] (in common) (KeyChainClient.mm:110) 17 common 0x000000010836e298 -[KeyChainClient getValueAsDataWithKey:withAccessGroup:] (in common) (KeyChainClient.mm:115)
1
0
591
Mar ’23
Upgrde an old app to ventura with your Xcode 4.5 source.
Hello, can upgrade an old front-end app for mac ventura 13.0? I have the complete source write in cocoa xCode e object C. When try to export app the system tell me Build fail. Have 5 error in syntax of CGColours component and conversion. The source in question is avaible for free at this link. https://mnt.conts.it/winxound/downloads/WinXound_3_4_0_OSX_Sources_XCode_4_5_0.zip Thank’s anyway.
2
0
1.2k
Mar ’23
protocol_addMethodDescription problems
Hi, I'm wondering if anyone else has seen this (and hopefully found a workaround). I'm working on a bug in PyObjC (https://github.com/ronaldoussoren/pyobjc/issues/17) related to protocols and can reproduce this in pure (Objective-)C. PyObjC creates a protocol and populates the method descriptors using the Objective-C runtime API, e.g. objc_allocateProtocol and protocol_getMethodDescription. This appears to work unreliably when adding multiple methods using protocol_getMethodDescription when the selector name and/or type encoding argument to protocol_getMethodDescription are not static strings: When the arguments are not static strings I have trouble finding the method descriptor using protocol_getMethodDescription. The code fails intermittently when adding two methods (but still fairly often), and fails reliably for me when adding 3 methods. The PyObjC issue I mentioned earlier contains a full reproducer.
1
0
716
Feb ’23
How to differentiate the Airplane mode from No Service from carrier with Obj-C? ?
Is it possible to differentiate whether user has no signal from carrier's mobile internet or purposefully has Airplane mode enabled? I want to disable some features inside my app if user has Airplane mode enable. At the same time, I want to keep these same features enabled if the device simply do not have service from carrier at that moment. platform :ios, '11.0' Following block code with Objective C was found in a StackOverFlow post and it is helpfull but it either lack of signal from carrier or airplane mode returns as ConnectionTypeNone. typedef enum { ConnectionTypeUnknown, ConnectionTypeNone, ConnectionType3G, ConnectionTypeWiFi } ConnectionType; + (ConnectionType)connectionType { SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, "8.8.8.8"); SCNetworkReachabilityFlags flags; BOOL success = SCNetworkReachabilityGetFlags(reachability, &flags); CFRelease(reachability); if (!success) { return ConnectionTypeUnknown; } BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); BOOL isNetworkReachable = (isReachable && !needsConnection); if (!isNetworkReachable) { return ConnectionTypeNone; } else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { return ConnectionType3G; } else { return ConnectionTypeWiFi; } }
1
0
1.1k
Jan ’23
launchd that runs a console app from authenticator
I have an authentication app (authApp) that runs on Mac. AuthApp lets you log in to the Mac. It runs in place of the default login screen. I have added a new button in authApp and I want that button to launch another app (let's call it newApp) when clicked. AuthApp is written in Objective-C and newApp in Swift. I am able to launch newApp from the login screen every time at logout with the help of launchd agents. But that is not what I want; I want it to open only when the button in AuthApp is clicked. This is my launchd plist `<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.example.apple-sample</string> <key>LimitLoadToSessionType</key> <string>LoginWindow</string> <key>KeepAlive</key> <true/> <key>ProgramArguments</key> <array> <string>/Library/PrivilegedHelperTools/newApp.app/Contents/MacOS/newApp</string> </array> </dict> </plist>` The file is saved in /Library/LaunchAgents. newApp is in /Library/PrivilegedHelperTools. Is there a way to execute this launchd programmatically (Objective-C++/Swift) from the code so that newApp is launched? Please note this needs to be done before the user has logged in to the machine.
7
1
1.1k
Jan ’23
How to define a Class instance type conforming to a protocol?
Consider the following Objective-C protocol declaration, which requires only class methods: @protocol TDWMethoding<NSObject> + (void)foo; + (void)bar; @end Assuming I need to return an instance of a Class which conforms to this protocol from a method, how am I supposed to specify the return type? - (nullable /*return-type*/)instantiateMethoding { Class instance = ... // some implementation if ([instance conformsToProtocol:@protocol(TDWMethoding)]) { return instance; } return nil; } There are a number of working options I considered so far in regards to how to express the /*return-type*/, but each has its own downsides: Class - this way it doesn't expose conformance. What kind of Class is it? What does it do? Does it conform to the protocol at all? Class<TDWMethoding> - this looks like a viable solution and even was suggested a few times by other developers (here and here) but I personally find it inconsistent and misleading: when we have a variable of form Type<Protocol> *instance, it commonly means that protocol class methods should be sent to the instance's class ([[instance class] foo]) not the instance itself ([instance foo]); id<TDWMethoding> and returning an instance of the class instead - this is consistent, but it requires me to instantiate the class, which is both redundant and prevents me from hiding the constructors of the utility classes which conforms to the protocol with NS_UNAVAILABLE macro. Is there a better semantic to express such a return-type?
3
0
1.5k
Jan ’23
Parsing preferred phonenumbers with CNPhoneNumber from vcf-file
I try to parse a vcf-file. I use CNContact for this. That works quite well, but with the phonenumbers i have a problem. With CNLabeledValue<CNPhoneNumber*>* I get the label (e. g. "home") and the phonenumber in the value. Excerpt from the vCard: TEL;TYPE=home:1234567890 But if the number is tagged with a "pref" i can't get this tag for the phonenumber. Excerpt from the vCard: TEL;TYPE=home,pref:0987654321 Is there anyway to find out, which numbers are the preferred numbers? I use following code: for (CNLabeledValue<CNPhoneNumber*>* number in cnContact.phoneNumbers) { NSString *label = number.label; NSString *number = ((CNPhoneNumber*)number).stringValue; //Do some work with label and number }
0
0
743
Jan ’23
Avoid backup of Cookies.binarycookies file
Hello to everyone, my iOS banking app has a WKWebView that shows a webpage from an external supplier. For security reasons the file Cookies.binarycookies generated by this webpage should not be present in the backup of the app. I've implemented this code but it doesn't work  if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {     BOOL result = NO;     NSURL *url = [NSURL URLWithString:filePath];     result = [url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error]; } The result value is YES after the execution but the file is still present in the backup. I doubt that this file is protected and this fix won't work. Have you any suggestion on how I can proceed? Thank you, Chiara
1
0
1.3k
Jan ’23
Error adding app to login items using SMAppService
Hello all, I am trying to use the new SMAppService added in MacOS Ventura to add my app to login items. This is the code I am using: if (@available(macOS 13.0, *)) { SMAppService* service = [SMAppService mainAppService]; NSError* error = nil; BOOL output = false; if (setEnabled) output = [service registerAndReturnError:&error]; else output = [service unregisterAndReturnError:&error]; } However when I run the app I see this error: Domain=SMAppServiceErrorDomain Code=1 "Operation not permitted" UserInfo={NSLocalizedFailureReason=Operation not permitted} 2022-12-25 11:14:16.628 TimeDoctor2[16823:159849] Error adding or removing item Error Domain=SMAppServiceErrorDomain Code=1 "Operation not permitted" UserInfo={NSLocalizedFailureReason=Operation not permitted} I have tried to check the error detail using this command on another terminal tab: sudo log stream --debug --info --predicate "process in { '<my process>', 'smd', 'backgroundtaskmanagementd'} and sender in {'ServiceManagement', 'BackgroundTaskManagement', 'smd', 'backgroundtaskmanagementd'}" I don´t really understand the output: Filtering the log data using "process IN {"<my process>", "smd", "backgroundtaskmanagementd"} AND sender IN {"ServiceManagement", "BackgroundTaskManagement", "smd", "backgroundtaskmanagementd"}" Timestamp            Thread   Type    Activity       PID  TTL   2022-12-25 11:01:57.444537+0100 0x25272  Activity  0x514e0       306  0  smd: (BackgroundTaskManagement) BTMManager.getEffectiveDisposition 2022-12-25 11:01:57.445383+0100 0x25271  Default   0x514e0       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=<private>, type=app, url=(null), config=(null) 2022-12-25 11:01:57.452448+0100 0x25272  Error    0x514e0       306  0  smd: (BackgroundTaskManagement) [com.apple.backgroundtaskmanagement:main] getEffectiveDisposition: error: Error Domain=BTMErrorDomain Code=-98 "(null)" 2022-12-25 11:01:57.452479+0100 0x25272  Error    0x0         306  0  smd: [com.apple.xpc.smd:SMAppService] Unable to get disposition of item: <private> error: Error Domain=NSPOSIXErrorDomain Code=3 2022-12-25 11:01:57.452378+0100 0x25271  Error    0x514e0       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) 2022-12-25 11:01:57.452495+0100 0x25272  Default   0x0         306  0  smd: [com.apple.xpc.smd:all] Found status: 3 for <private> 2022-12-25 11:01:57.842135+0100 0x25534  Activity  0x514e1       306  0  smd: (BackgroundTaskManagement) BTMManager.getEffectiveDisposition 2022-12-25 11:01:57.842254+0100 0x25271  Default   0x514e1       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=<private>, type=app, url=(null), config=(null) 2022-12-25 11:01:57.849707+0100 0x25271  Error    0x514e1       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) 2022-12-25 11:01:57.849804+0100 0x25534  Error    0x514e1       306  0  smd: (BackgroundTaskManagement) [com.apple.backgroundtaskmanagement:main] getEffectiveDisposition: error: Error Domain=BTMErrorDomain Code=-98 "(null)" 2022-12-25 11:01:57.849828+0100 0x25534  Error    0x0         306  0  smd: [com.apple.xpc.smd:SMAppService] Unable to get disposition of item: <private> error: Error Domain=NSPOSIXErrorDomain Code=3 2022-12-25 11:01:57.849839+0100 0x25534  Default   0x0         306  0  smd: [com.apple.xpc.smd:all] Found status: 3 for <private> 2022-12-25 11:01:58.020633+0100 0x25534  Activity  0x514e2       306  0  smd: (BackgroundTaskManagement) BTMManager.getEffectiveDisposition 2022-12-25 11:01:58.020762+0100 0x25271  Default   0x514e2       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=<private>, type=app, url=(null), config=(null) 2022-12-25 11:01:58.025436+0100 0x25534  Error    0x514e2       306  0  smd: (BackgroundTaskManagement) [com.apple.backgroundtaskmanagement:main] getEffectiveDisposition: error: Error Domain=BTMErrorDomain Code=-98 "(null)" 2022-12-25 11:01:58.025334+0100 0x25271  Error    0x514e2       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) 2022-12-25 11:01:58.304370+0100 0x25271  Error    0x514e4       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) Could someone help me please?
1
0
1.3k
Dec ’22
Gstreamer - Record live stream when user initiated an action like a button click.
I have an application in iOS that needs to be stream from a device and display on iPhone. Also the user needs to record the stream to phone storage when they tap a button. Added a pipeline in server side: gst-launch-1.0 -v avfvideosrc device-index=0 ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! queue ! udpsink host=192.168.0.106 port=5005 also in client side: (GStreamerBackend.m) pipeline = gst_parse_launch("udpsrc port=5005 caps="application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, tune=zerolatency, bitrate=500, speed-preset=superfast, payload=96" ! rtph264depay ! h264parse ! tee name=t t. ! queue ! avimux ! filesink location=/var/mobile/Containers/Data/Application/C40A7960-18CC-480E-9171-520ADF26BB8D/Documents/video1.avi t. ! queue leaky=1 ! decodebin ! videoconvert ! autovideosink sync=false", &error); This will display and record the stream correctly. But how do I separate the display and record? I need to record the stream only on button click. I need to add a new class for start and stop recording. I found the code in .c But need it in objective c. If anybody knows, please let me inform.
0
0
1k
Dec ’22
wkwebview.navigationdelegate is still nil after assigned delegate
I assign its navigationDelegate in my 'CustomWebView' init function, the init function is called in the viewDidLoad function and the 'CustomWebView' implements the WKNavigationDelegate functions, objection_requires(NSStringFromSelector(@selector(configRepository))) - (instancetype)initWithConfiguration:(WKWebViewConfiguration *)configuration configRepository:(SKYConfigRepository *)configRepository { self = [super init]; _configRepository = configRepository; if (self) { [[JSObjection defaultInjector] injectDependencies:self]; self.converterLink = [JSObjection defaultInjector][@protocol(UniversalLinkConverterProtocol)]; WKWebViewConfiguration *wkWebViewConfig = [self getWebViewConfigWithUpdatedUserAgent:configuration]; _wkWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:wkWebViewConfig]; _wkWebView.navigationDelegate = self; ... ... then when I debug the '_wkWebView.navigationDelegate' is nil the 'self' is not nil, and it implements the WKNavigationDelegate, {   WKWebView *_wkWebView;   SKYConfigRepository *_configRepository; }
3
0
1.8k
Dec ’22
Call swift code from objc code in objc project
I read the article here... https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-cand this is what I did.Created a header file for swift file.added @class SwiftFile.h#import MyAppTargetName-Swift.h in the objc file from where I want to reference my swift code.Now in my swift file when I write...@interface ClassName { MySwiftClass *swiftClass; }I get error message Unknown Type Name "MySwiftClass".How can I resolve this and get going?Am I doing something wrong?Does the bridging header i created along with the swift file need to me edited?Neerav
17
0
14k
Dec ’22
objc vImage PixelBuffer crop
I need for an objc implementation exactly the functionality of this swift documentation: https://developer.apple.com/documentation/accelerate/vimage/pixelbuffer/3951652-cropped?changes=_7_1&language=objc It seems that there is no objc documentation present. Does anyone know how to call the crop function in objc?
2
0
737
Nov ’22
is it possible to set alarm in iPhone’s default Alarm Clock from other application ?
I'm looking for a way to set up a new alarm in the actual IOS Alarm Clock application from a new (self-created) app.Basically, the app I'm creating would programmatically add a new alarm to the Default alarm Clock app, which would then simply behave as it normally does -- making the built-in alarm clock ring when the time arrives.
7
0
9.7k
Nov ’22
CTCellularPlanProvisioning, CTCellularPlanProvisioningAddPlanResultUnknown before the wizard finished
I'm using the below code to activate Esim, UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}]; [plan addPlanWith:request completionHandler:^(CTCellularPlanProvisioningAddPlanResult result) { if (result==CTCellularPlanProvisioningAddPlanResultFail){ NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil]; reject(@"2", @"CTCellularPlanProvisioningAddPlanResultFail - Can't add an Esim subscription", error); }else if (result==CTCellularPlanProvisioningAddPlanResultUnknown){ NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil]; reject(@"3", @"CTCellularPlanProvisioningAddPlanResultUnknown - Can't setup eSim due to unknown error", error); }else{ //CTCellularPlanProvisioningAddPlanResultSuccess resolve(@(true)); } [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier]; }]; When I call the method, it will simultaneously open the "Add Cellular Plan" wizard and return the CTCellularPlanProvisioningAddPlanResultUnknown. However, in the end, the Esim will add successfully, but I will not receive the prosperous state in "completion handler."
1
0
2.3k
Nov ’22
Crash while reading data from keychain
Hi, I have observed this crash, can anyone pls help finding its root cause - Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000008 VM Region Info: 0x8 is not in any region. Bytes before following region: 4374659064 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---&amp;gt; __TEXT 104c00000-104c04000 [ 16K] r-x/r-x SM=COW ... for Endpoint Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [2452] Triggered by Thread: 1 Thread 0 name: Dispatch queue: com.example Thread 0: 0 libsystem_kernel.dylib 0x00000001b25d22d0 0x1b25ce000 + 17104 1 libsystem_kernel.dylib 0x00000001b25d1660 0x1b25ce000 + 13920 2 libdispatch.dylib 0x00000001849c7888 0x1849ab000 + 116872 3 libdispatch.dylib 0x00000001849c7c24 0x1849ab000 + 117796 4 libxpc.dylib 0x00000001cfb52e68 0x1cfb45000 + 56936 5 Security 0x000000018c319090 0x18c2f9000 + 131216 6 Security 0x000000018c319b38 0x18c2f9000 + 133944 7 Security 0x000000018c3a4c0c 0x18c2f9000 + 703500 8 Security 0x000000018c3a4fd0 0x18c2f9000 + 704464 9 Security 0x000000018c3a385c 0x18c2f9000 + 698460 10 Security 0x000000018c3a26c8 0x18c2f9000 + 693960 11 Security 0x000000018c3a2ff4 0x18c2f9000 + 696308 12 Security 0x000000018c3a4ed8 0x18c2f9000 + 704216 13 Security 0x000000018c3a0a1c 0x18c2f9000 + 686620 14 Security 0x000000018c3a40a0 0x18c2f9000 + 700576 15 common 0x000000010836df2c -[KeyChainClient queryValueAsDataWithKey:withStatus:withAccessGroup:thisDeviceOnly:] (in common) (KeyChainClient.mm:53) 16 common 0x000000010836e274 -[KeyChainClient getValueAsDataWithKey:withAccessGroup:thisDeviceOnly:] (in common) (KeyChainClient.mm:110) 17 common 0x000000010836e298 -[KeyChainClient getValueAsDataWithKey:withAccessGroup:] (in common) (KeyChainClient.mm:115)
Replies
1
Boosts
0
Views
591
Activity
Mar ’23
Upgrde an old app to ventura with your Xcode 4.5 source.
Hello, can upgrade an old front-end app for mac ventura 13.0? I have the complete source write in cocoa xCode e object C. When try to export app the system tell me Build fail. Have 5 error in syntax of CGColours component and conversion. The source in question is avaible for free at this link. https://mnt.conts.it/winxound/downloads/WinXound_3_4_0_OSX_Sources_XCode_4_5_0.zip Thank’s anyway.
Replies
2
Boosts
0
Views
1.2k
Activity
Mar ’23
protocol_addMethodDescription problems
Hi, I'm wondering if anyone else has seen this (and hopefully found a workaround). I'm working on a bug in PyObjC (https://github.com/ronaldoussoren/pyobjc/issues/17) related to protocols and can reproduce this in pure (Objective-)C. PyObjC creates a protocol and populates the method descriptors using the Objective-C runtime API, e.g. objc_allocateProtocol and protocol_getMethodDescription. This appears to work unreliably when adding multiple methods using protocol_getMethodDescription when the selector name and/or type encoding argument to protocol_getMethodDescription are not static strings: When the arguments are not static strings I have trouble finding the method descriptor using protocol_getMethodDescription. The code fails intermittently when adding two methods (but still fairly often), and fails reliably for me when adding 3 methods. The PyObjC issue I mentioned earlier contains a full reproducer.
Replies
1
Boosts
0
Views
716
Activity
Feb ’23
How to differentiate the Airplane mode from No Service from carrier with Obj-C? ?
Is it possible to differentiate whether user has no signal from carrier's mobile internet or purposefully has Airplane mode enabled? I want to disable some features inside my app if user has Airplane mode enable. At the same time, I want to keep these same features enabled if the device simply do not have service from carrier at that moment. platform :ios, '11.0' Following block code with Objective C was found in a StackOverFlow post and it is helpfull but it either lack of signal from carrier or airplane mode returns as ConnectionTypeNone. typedef enum { ConnectionTypeUnknown, ConnectionTypeNone, ConnectionType3G, ConnectionTypeWiFi } ConnectionType; + (ConnectionType)connectionType { SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, "8.8.8.8"); SCNetworkReachabilityFlags flags; BOOL success = SCNetworkReachabilityGetFlags(reachability, &flags); CFRelease(reachability); if (!success) { return ConnectionTypeUnknown; } BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); BOOL isNetworkReachable = (isReachable && !needsConnection); if (!isNetworkReachable) { return ConnectionTypeNone; } else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { return ConnectionType3G; } else { return ConnectionTypeWiFi; } }
Replies
1
Boosts
0
Views
1.1k
Activity
Jan ’23
launchd that runs a console app from authenticator
I have an authentication app (authApp) that runs on Mac. AuthApp lets you log in to the Mac. It runs in place of the default login screen. I have added a new button in authApp and I want that button to launch another app (let's call it newApp) when clicked. AuthApp is written in Objective-C and newApp in Swift. I am able to launch newApp from the login screen every time at logout with the help of launchd agents. But that is not what I want; I want it to open only when the button in AuthApp is clicked. This is my launchd plist `&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt; &amp;lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&amp;gt; &amp;lt;plist version="1.0"&amp;gt; &amp;lt;dict&amp;gt; &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt; &amp;lt;string&amp;gt;com.example.apple-sample&amp;lt;/string&amp;gt; &amp;lt;key&amp;gt;LimitLoadToSessionType&amp;lt;/key&amp;gt; &amp;lt;string&amp;gt;LoginWindow&amp;lt;/string&amp;gt; &amp;lt;key&amp;gt;KeepAlive&amp;lt;/key&amp;gt; &amp;lt;true/&amp;gt; &amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt; &amp;lt;array&amp;gt; &amp;lt;string&amp;gt;/Library/PrivilegedHelperTools/newApp.app/Contents/MacOS/newApp&amp;lt;/string&amp;gt; &amp;lt;/array&amp;gt; &amp;lt;/dict&amp;gt; &amp;lt;/plist&amp;gt;` The file is saved in /Library/LaunchAgents. newApp is in /Library/PrivilegedHelperTools. Is there a way to execute this launchd programmatically (Objective-C++/Swift) from the code so that newApp is launched? Please note this needs to be done before the user has logged in to the machine.
Replies
7
Boosts
1
Views
1.1k
Activity
Jan ’23
How to define a Class instance type conforming to a protocol?
Consider the following Objective-C protocol declaration, which requires only class methods: @protocol TDWMethoding&lt;NSObject&gt; + (void)foo; + (void)bar; @end Assuming I need to return an instance of a Class which conforms to this protocol from a method, how am I supposed to specify the return type? - (nullable /*return-type*/)instantiateMethoding { Class instance = ... // some implementation if ([instance conformsToProtocol:@protocol(TDWMethoding)]) { return instance; } return nil; } There are a number of working options I considered so far in regards to how to express the /*return-type*/, but each has its own downsides: Class - this way it doesn't expose conformance. What kind of Class is it? What does it do? Does it conform to the protocol at all? Class&lt;TDWMethoding&gt; - this looks like a viable solution and even was suggested a few times by other developers (here and here) but I personally find it inconsistent and misleading: when we have a variable of form Type&lt;Protocol&gt; *instance, it commonly means that protocol class methods should be sent to the instance's class ([[instance class] foo]) not the instance itself ([instance foo]); id&lt;TDWMethoding&gt; and returning an instance of the class instead - this is consistent, but it requires me to instantiate the class, which is both redundant and prevents me from hiding the constructors of the utility classes which conforms to the protocol with NS_UNAVAILABLE macro. Is there a better semantic to express such a return-type?
Replies
3
Boosts
0
Views
1.5k
Activity
Jan ’23
Parsing preferred phonenumbers with CNPhoneNumber from vcf-file
I try to parse a vcf-file. I use CNContact for this. That works quite well, but with the phonenumbers i have a problem. With CNLabeledValue&lt;CNPhoneNumber*&gt;* I get the label (e. g. "home") and the phonenumber in the value. Excerpt from the vCard: TEL;TYPE=home:1234567890 But if the number is tagged with a "pref" i can't get this tag for the phonenumber. Excerpt from the vCard: TEL;TYPE=home,pref:0987654321 Is there anyway to find out, which numbers are the preferred numbers? I use following code: for (CNLabeledValue&lt;CNPhoneNumber*&gt;* number in cnContact.phoneNumbers) { NSString *label = number.label; NSString *number = ((CNPhoneNumber*)number).stringValue; //Do some work with label and number }
Replies
0
Boosts
0
Views
743
Activity
Jan ’23
Avoid backup of Cookies.binarycookies file
Hello to everyone, my iOS banking app has a WKWebView that shows a webpage from an external supplier. For security reasons the file Cookies.binarycookies generated by this webpage should not be present in the backup of the app. I've implemented this code but it doesn't work  if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {     BOOL result = NO;     NSURL *url = [NSURL URLWithString:filePath];     result = [url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&amp;error]; } The result value is YES after the execution but the file is still present in the backup. I doubt that this file is protected and this fix won't work. Have you any suggestion on how I can proceed? Thank you, Chiara
Replies
1
Boosts
0
Views
1.3k
Activity
Jan ’23
Error adding app to login items using SMAppService
Hello all, I am trying to use the new SMAppService added in MacOS Ventura to add my app to login items. This is the code I am using: if (@available(macOS 13.0, *)) { SMAppService* service = [SMAppService mainAppService]; NSError* error = nil; BOOL output = false; if (setEnabled) output = [service registerAndReturnError:&error]; else output = [service unregisterAndReturnError:&error]; } However when I run the app I see this error: Domain=SMAppServiceErrorDomain Code=1 "Operation not permitted" UserInfo={NSLocalizedFailureReason=Operation not permitted} 2022-12-25 11:14:16.628 TimeDoctor2[16823:159849] Error adding or removing item Error Domain=SMAppServiceErrorDomain Code=1 "Operation not permitted" UserInfo={NSLocalizedFailureReason=Operation not permitted} I have tried to check the error detail using this command on another terminal tab: sudo log stream --debug --info --predicate "process in { '<my process>', 'smd', 'backgroundtaskmanagementd'} and sender in {'ServiceManagement', 'BackgroundTaskManagement', 'smd', 'backgroundtaskmanagementd'}" I don´t really understand the output: Filtering the log data using "process IN {"<my process>", "smd", "backgroundtaskmanagementd"} AND sender IN {"ServiceManagement", "BackgroundTaskManagement", "smd", "backgroundtaskmanagementd"}" Timestamp            Thread   Type    Activity       PID  TTL   2022-12-25 11:01:57.444537+0100 0x25272  Activity  0x514e0       306  0  smd: (BackgroundTaskManagement) BTMManager.getEffectiveDisposition 2022-12-25 11:01:57.445383+0100 0x25271  Default   0x514e0       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=<private>, type=app, url=(null), config=(null) 2022-12-25 11:01:57.452448+0100 0x25272  Error    0x514e0       306  0  smd: (BackgroundTaskManagement) [com.apple.backgroundtaskmanagement:main] getEffectiveDisposition: error: Error Domain=BTMErrorDomain Code=-98 "(null)" 2022-12-25 11:01:57.452479+0100 0x25272  Error    0x0         306  0  smd: [com.apple.xpc.smd:SMAppService] Unable to get disposition of item: <private> error: Error Domain=NSPOSIXErrorDomain Code=3 2022-12-25 11:01:57.452378+0100 0x25271  Error    0x514e0       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) 2022-12-25 11:01:57.452495+0100 0x25272  Default   0x0         306  0  smd: [com.apple.xpc.smd:all] Found status: 3 for <private> 2022-12-25 11:01:57.842135+0100 0x25534  Activity  0x514e1       306  0  smd: (BackgroundTaskManagement) BTMManager.getEffectiveDisposition 2022-12-25 11:01:57.842254+0100 0x25271  Default   0x514e1       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=<private>, type=app, url=(null), config=(null) 2022-12-25 11:01:57.849707+0100 0x25271  Error    0x514e1       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) 2022-12-25 11:01:57.849804+0100 0x25534  Error    0x514e1       306  0  smd: (BackgroundTaskManagement) [com.apple.backgroundtaskmanagement:main] getEffectiveDisposition: error: Error Domain=BTMErrorDomain Code=-98 "(null)" 2022-12-25 11:01:57.849828+0100 0x25534  Error    0x0         306  0  smd: [com.apple.xpc.smd:SMAppService] Unable to get disposition of item: <private> error: Error Domain=NSPOSIXErrorDomain Code=3 2022-12-25 11:01:57.849839+0100 0x25534  Default   0x0         306  0  smd: [com.apple.xpc.smd:all] Found status: 3 for <private> 2022-12-25 11:01:58.020633+0100 0x25534  Activity  0x514e2       306  0  smd: (BackgroundTaskManagement) BTMManager.getEffectiveDisposition 2022-12-25 11:01:58.020762+0100 0x25271  Default   0x514e2       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: appURL=<private>, type=app, url=(null), config=(null) 2022-12-25 11:01:58.025436+0100 0x25534  Error    0x514e2       306  0  smd: (BackgroundTaskManagement) [com.apple.backgroundtaskmanagement:main] getEffectiveDisposition: error: Error Domain=BTMErrorDomain Code=-98 "(null)" 2022-12-25 11:01:58.025334+0100 0x25271  Error    0x514e2       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) 2022-12-25 11:01:58.304370+0100 0x25271  Error    0x514e4       491  0  backgroundtaskmanagementd: [com.apple.backgroundtaskmanagement:main] effectiveItemDisposition: failed to construct identifier with parameters: appURL=/Applications/Time Doctor 2.app, url=(null), type=app, config=(null) Could someone help me please?
Replies
1
Boosts
0
Views
1.3k
Activity
Dec ’22
Gstreamer - Record live stream when user initiated an action like a button click.
I have an application in iOS that needs to be stream from a device and display on iPhone. Also the user needs to record the stream to phone storage when they tap a button. Added a pipeline in server side: gst-launch-1.0 -v avfvideosrc device-index=0 ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! queue ! udpsink host=192.168.0.106 port=5005 also in client side: (GStreamerBackend.m) pipeline = gst_parse_launch("udpsrc port=5005 caps="application/x-rtp, media=video, clock-rate=90000, encoding-name=H264, tune=zerolatency, bitrate=500, speed-preset=superfast, payload=96" ! rtph264depay ! h264parse ! tee name=t t. ! queue ! avimux ! filesink location=/var/mobile/Containers/Data/Application/C40A7960-18CC-480E-9171-520ADF26BB8D/Documents/video1.avi t. ! queue leaky=1 ! decodebin ! videoconvert ! autovideosink sync=false", &error); This will display and record the stream correctly. But how do I separate the display and record? I need to record the stream only on button click. I need to add a new class for start and stop recording. I found the code in .c But need it in objective c. If anybody knows, please let me inform.
Replies
0
Boosts
0
Views
1k
Activity
Dec ’22
send a photo or video through the photo app
Hi, I made an app where you can share photos and videos, but I want to make it a thing so the user can share the photo or video through the photos app on your phone. Is it something apple does automatically or do I have to embed this fature in.
Replies
1
Boosts
0
Views
902
Activity
Dec ’22
iOS app stuck and crash
Hi, I have received lots of crash report recently.The phenomenon is first stuck and then crash.This crash have bothered me for many days. below is the crash report symbol.crash
Replies
3
Boosts
0
Views
1.7k
Activity
Dec ’22
wkwebview.navigationdelegate is still nil after assigned delegate
I assign its navigationDelegate in my 'CustomWebView' init function, the init function is called in the viewDidLoad function and the 'CustomWebView' implements the WKNavigationDelegate functions, objection_requires(NSStringFromSelector(@selector(configRepository))) - (instancetype)initWithConfiguration:(WKWebViewConfiguration *)configuration configRepository:(SKYConfigRepository *)configRepository { self = [super init]; _configRepository = configRepository; if (self) { [[JSObjection defaultInjector] injectDependencies:self]; self.converterLink = [JSObjection defaultInjector][@protocol(UniversalLinkConverterProtocol)]; WKWebViewConfiguration *wkWebViewConfig = [self getWebViewConfigWithUpdatedUserAgent:configuration]; _wkWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:wkWebViewConfig]; _wkWebView.navigationDelegate = self; ... ... then when I debug the '_wkWebView.navigationDelegate' is nil the 'self' is not nil, and it implements the WKNavigationDelegate, {   WKWebView *_wkWebView;   SKYConfigRepository *_configRepository; }
Replies
3
Boosts
0
Views
1.8k
Activity
Dec ’22
Call swift code from objc code in objc project
I read the article here... https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-cand this is what I did.Created a header file for swift file.added @class SwiftFile.h#import MyAppTargetName-Swift.h in the objc file from where I want to reference my swift code.Now in my swift file when I write...@interface ClassName { MySwiftClass *swiftClass; }I get error message Unknown Type Name "MySwiftClass".How can I resolve this and get going?Am I doing something wrong?Does the bridging header i created along with the swift file need to me edited?Neerav
Replies
17
Boosts
0
Views
14k
Activity
Dec ’22
zombie crash (double) which can not be caught
hello, we received a zombie crash which confused us long time, seems like double free, can you give us some advices about this crash? very confused , this crash can not be caught in xcode (instruments -&gt; Zombie). this is full log, thx ! double free.crash
Replies
1
Boosts
0
Views
695
Activity
Dec ’22
objc vImage PixelBuffer crop
I need for an objc implementation exactly the functionality of this swift documentation: https://developer.apple.com/documentation/accelerate/vimage/pixelbuffer/3951652-cropped?changes=_7_1&language=objc It seems that there is no objc documentation present. Does anyone know how to call the crop function in objc?
Replies
2
Boosts
0
Views
737
Activity
Nov ’22
To which C language dialect do I have to change my Xcode settings that it will compile my code
So currently this is happening when I set my C language dialect to gnu11. Which one would I have to use for these errors to disappear?
Replies
1
Boosts
0
Views
1.1k
Activity
Nov ’22
Determine macOS version on which Xcode is running
How do I check the host macOS version in which Xcode or the Simulator is running? None of the TargetConditionals in TARGET_OS would work for this.
Replies
5
Boosts
0
Views
1.3k
Activity
Nov ’22
is it possible to set alarm in iPhone’s default Alarm Clock from other application ?
I'm looking for a way to set up a new alarm in the actual IOS Alarm Clock application from a new (self-created) app.Basically, the app I'm creating would programmatically add a new alarm to the Default alarm Clock app, which would then simply behave as it normally does -- making the built-in alarm clock ring when the time arrives.
Replies
7
Boosts
0
Views
9.7k
Activity
Nov ’22
CTCellularPlanProvisioning, CTCellularPlanProvisioningAddPlanResultUnknown before the wizard finished
I'm using the below code to activate Esim, UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}]; [plan addPlanWith:request completionHandler:^(CTCellularPlanProvisioningAddPlanResult result) { if (result==CTCellularPlanProvisioningAddPlanResultFail){ NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil]; reject(@"2", @"CTCellularPlanProvisioningAddPlanResultFail - Can't add an Esim subscription", error); }else if (result==CTCellularPlanProvisioningAddPlanResultUnknown){ NSError *error = [NSError errorWithDomain:@"react.native.simcardsmanager.handler" code:1 userInfo:nil]; reject(@"3", @"CTCellularPlanProvisioningAddPlanResultUnknown - Can't setup eSim due to unknown error", error); }else{ //CTCellularPlanProvisioningAddPlanResultSuccess resolve(@(true)); } [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier]; }]; When I call the method, it will simultaneously open the "Add Cellular Plan" wizard and return the CTCellularPlanProvisioningAddPlanResultUnknown. However, in the end, the Esim will add successfully, but I will not receive the prosperous state in "completion handler."
Replies
1
Boosts
0
Views
2.3k
Activity
Nov ’22