Posts

Post not yet marked as solved
0 Replies
223 Views
We can see Xcode supports to generate code coverage for unit test bundles. Does it has any support for generating code coverage report for a regular application/bundle. What we want to try is that can I check for my certain application how much code coverage is being done. If Xcode does not have any support for this, what apple suggest us to do for this ?
Posted Last updated
.
Post not yet marked as solved
1 Replies
564 Views
I have observed that in my application, Even If I set the QoS value of all the thread created to USER_INTERACTIVE, the OS is producing a warning "Thread running at User-Interactive QoS class waiting on a lower QoS thread running at Default QoS class. Investigate ways to avoid priority inversions". I am aware that it is not right to set all threads as USER_INTERACTIVE QoS, but If we assume this case for once, then it means that the OS can dynamically change the QoS of the threads even if we are explicitly setting it. Is this the correct understanding? Also, the main thread has QoS value USER_INTERACTIVE, then is it the case that its child threads will inherit the QoS value from the parent thread, If we are not setting any QoS for a pthread?
Posted Last updated
.
Post not yet marked as solved
5 Replies
491 Views
I have a project that has Cpp code and swift code and I m making some calls from swift to cpp. For this I m using the Cpp-swift interop mechanism introduced in swift 5.9 for making direct calls between swift and cpp. I m using module.modulemap file to expose the cpp code to swift. I am facnig an error when I try to access a cpp header that are using the cpp compiler flags in some static assert statements. These methods are working fine in cpp however, when I try to access these methods from swift using the modulemap file, the compiler flags are not being identified by swift, and produces the below error error: use of undeclared identifier 'TW_KERNEL_WINDOWS'. This is my module.modulemap file: module CoreModule { header "ProcessStates.hpp" //cpp header that contains compiler flags export * } below is the cpp header code that I m trying to access in swift: #pragma once // if the given condition is false – treat as an error #define STATIC_CHECKFALSE(condition, message) static_assert (condition, message) STATIC_CHECKFALSE ((TW_KERNEL_WINDOWS == 0) || (TW_KERNEL_WINDOWS == 1), "TW_KERNEL_WINDOWS can only be 0 or 1"); Can someone help, why is this happening and how to resolve this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
241 Views
I am building a macOS project where I m creating a thread using pthread in cpp. I am setting the QOS class using the pthread_attr_set_qos_class_np and later checking the value of the QOS class using the pthread_attr_get_qos_class_np. These calls are successful but the QOS class is not being set. Below is the cpp function that I m invoking from my swift code. bool CppThread::CreateThread () { pthread_t threadId; pthread_attr_t attr; qos_class_t qos_class; int relative_priority; int rc = pthread_attr_init(&attr); if (rc) { printf ("pthread_attr_init failed"); } if (pthread_attr_set_qos_class_np (&attr, QOS_CLASS_BACKGROUND, 5)) { printf ("pthread_attr_set_qos_class_np failed\n"); } int retval = pthread_create(&threadId, &attr, threadFunction, NULL); if (retval) { std::cerr << "Error creating thread" << std::endl; return false; } if (pthread_attr_get_qos_class_np (&attr, &qos_class, &relative_priority)) { printf ("pthread_attr_get_qos_class_np failed\n"); } printf ("QoS class: %d, Relative priority: %d\n", qos_class, relative_priority); pthread_join(threadId, NULL); // Wait for thread to finish std::cout << "Thread finished" << std::endl; return true; } OUTPUT: QoS class: 0, Relative priority: 0 Thread finished I have tried setting multiple QOS values but the output always shows the QOS class value as 0. Why is it not getting set?
Posted Last updated
.
Post not yet marked as solved
0 Replies
376 Views
I have the below code where my swift code calls a cpp function. In this the swift calls a cpp function and passes a swift 'String' as argument to it, which is then received in the cpp code as 'const char *'. This conversion works without any errors. Is this a documented behaviour in cpp-swift interop and is this safe to use? Swift side: internal static func CharCheck (pSentence: String) -&gt; Void { TWSoundLogic.CharacterSoundCount (pSentence) } In the C++ side, void TWSoundLogic::CharacterSoundCount (const char * pSentence) { .. } However, on returning a String type from a swift function and trying to receive it as a const char* in c++, it gives an error in cpp No viable conversion from 'swift::String' to 'const char *' . Why does it not allow to return, but it allows to pass as argument? Can someone explain this behaviour?
Posted Last updated
.
Post not yet marked as solved
0 Replies
261 Views
I had raised a support request in Apple DTS for an issue related to notification. I had a few iteration with the support team related to this but the problem remains unresolved. Everytime I send a response for what has been asked, it takes more than a week for the team to reply. This issue has been pending for over a month now and my work is blocked due to this. Can someone help me in getting a quick response or tell me how to reach the relevant people who can help me with this? Here is my Case ID : 5269018
Posted Last updated
.
Post not yet marked as solved
0 Replies
272 Views
In IOS, when the device is kept idle for some time, the screen turns off and the device enters sleep mode. It also enters sleep mode when we press the power button to turn the screen off. In my application, I wanted to detect If the device has entered/exited the sleep mode. I have followed the below links but some of these ways like observing 'Darwin notifications' is no longer allowed by apple. Other ways consider the device being locked as sleep mode, which is not precisely correct. Is there a way to correctly determine this? Please share the apple documentation links if this is possible. https://stackoverflow.com/questions/14191980/detect-screen-on-off-from-ios-service/14208787#14208787 https://nemecek.be/blog/104/checking-if-device-is-locked-or-sleeping-in-ios
Posted Last updated
.
Post not yet marked as solved
0 Replies
313 Views
I have a mac application that is configured to have a universal link. Clicking the universal link launches my application. The documentation says that the link is received in the application(_:continue:restorationHandler:) delegate method which is invoked very late in the application lifecycle after applicationDidBecomeActive. I have the initialisation code of my app in applicationWillFinishLaunching method. Is there any way the Universal link can be received early, so that I can show the appropriate application window based on the universal link parameters? Is there any other delegate that receives the universal link?
Posted Last updated
.
Post not yet marked as solved
1 Replies
282 Views
I have observed that some of the applications like xcode show a list of recently opened documents in their dock menu like in the image below. I wanted to show similar recently opened docs for my application but I not able to find any resource on how to achieve this. Can someone help on how to do this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
346 Views
The notification parameter in DidFinishLaunching contains a key LaunchIsDefaultLaunchKey which according to Apple documentation is: The value for this key is an NSNumber containing a Boolean value. The value is false if the app was launched to open or print a file, to perform a Service action, if the app had saved state that will be restored, or if the app launch was in some other sense not a default launch. Otherwise its value will be true. I m not able to understand the exact usecase for this parameter, like where can we make use of this parameter. Can I use this key to identify If my application was launched using a universal link?
Posted Last updated
.
Post not yet marked as solved
2 Replies
519 Views
I have created a universal link which I m using for two different applications in macOS. Below is the apple-app-site-association file for the same: { "applinks":{ "apps":[], "details":[ { "appID":"E5R4JF6D5K.com.demo.App1", "paths":[ "/app1/*" ] }, { "appID":"E5R4JF6D5K.world.demo.App2", "paths":[ "/app2/*" ] } ] } } After creating this file in my server and providing the same Url in my associated domain capability for both my application, when I try to launch my applications using the link then only the first application is getting launched everytime. The second application is never launched. for Url with http://custom.com/app1/... it redirects to first app. for Url with http://custom.com/app2/... it redirects to browser. I tried uninstalling the first app, but then it always directs in browser. I tried a separate url for both apps, and it works fine. I m not able to figure out the problem. The apple documentation says that it is possible to have two application linked to a common domain. Any help?
Posted Last updated
.
Post not yet marked as solved
0 Replies
288 Views
I wanted to add some dock menu options for my application when it is not running. These dock menu options can be used to launch the application. I came across dock TilePlugin that can be used to add these dock options. But one of the comments in this forum discussion mentions that these Plugins are not allowed if you want ot publish your application in the appStore. Can someone confirm this? If this is true, then Is there some other solution that can be used to add the dock options which appear when the application is not running, and can be used to launch the application? Also do the recent open Files appear using this plugin mechanism?
Posted Last updated
.
Post not yet marked as solved
1 Replies
351 Views
I was going through this apple documention and it states, "By default, the generated header contains interfaces for Swift declarations marked with the public or open modifier", however, In my Xcode project, the public methods are not visible in the objective C code, and only the methods that are marked with @objc are visible. Is there some problem in my code or Is this a bug?
Posted Last updated
.
Post not yet marked as solved
3 Replies
765 Views
In the mac general setting, we can provide the language preference for an individual application like in the image below, I have provided for TextEdit app. Now based on the system preferred languages, TextEdit will have a default language. However if I explicitly set the language for TextEdit (arabic in my example), then the application will use that language. I wanted to identify in my program the language that an app is currently running in. I have tried the below code, but it always return 'en', even after my preference is set to 'Arabic'. let u = URL(fileURLWithPath: "/System/Applications/TextEdit.app") let b = Bundle(url: u)! let textedit_preference = b.preferredLocalizations print(textedit_preference) //["en"] How can I identify what language is being set by the user for an individual application? I have followed this link but it does not contain this information.
Posted Last updated
.
Post not yet marked as solved
1 Replies
261 Views
I have a project where I m making direct swift calls from cpp as introduced in swift5.9. Below is my swift class whose method is being invoked on cpp. import Foundation public class MySwiftClass { public static func testInterop () -> Void { NSLog("----------- hey --------") } } I m able to successfully invoke 'testInterop()' in cpp with the above class, however if I add conformance to NSObject in the 'MySwiftClass' class, then the swift call fails with the error "No member named 'MySwiftClass' in namespace 'Module2'", where Module2 is my swift target. I m not able to identify why is this happening. Any help?
Posted Last updated
.