Post

Replies

Boosts

Views

Activity

Can iOS extension use the same binary as app?
I have an iOS SwiftUI app which uses some extensions like NotificationServiceExtension, NotificationContentExtension, WidgetExtension etc. I noticed that each extension uses its own process and has its own bundle with the .appex extension... and is packaged within the app bundle, with .app extension. In my case, most of my logic is in C++ and when the app starts up, it needs to 'startup' the C++ layer. Now, in WidgetExtension, if it's going to read data from disk and update its interface, I need to initialise my C++ layer first. The same can be said for NotificationServiceExtension. This is leading me to include all my C++ artefacts into the extension target as well. Here's my problem: If the size of my app (containing all my C++ artefacts) is 10MB and I'm using 20 extensions (say), the final size of the shipped app bundle is 10MB + (20 * 10MB) = 210MB, since extension bundle (.appex) is packaged within the app bundle (.app). Since the app and the extensions are using the same C++ artefacts, I was hoping to have one binary in the bundle. The app and its extensions will point to this binary. When the app is launched, the app entry point (struct conforming to App protocol) is invoked, in case of widget, the widget entry point (WidgetBundle) is invoked and so on for each extension. This will reduce the final size of the app bundle. Is it possible to have one binary and the app target, all extension targets would use this binary for there functioning?
1
0
453
May ’24
Interfaces of Swift extension not called if put in separate target
I have a SceneDelegate class which is part of Target 1 code. Target 1 is compiled as a static library. public class SceneDelegate: UIResponder, UIWindowSceneDelegate { public var window: UIWindow? // SceneDigBecomeActive // other lifecycle events } The SceneDelegate is programmatically assigned in the 'configurationForConnecting' of the AppDelegate in Target 1. i.e. config = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role) // Set the scene delegate config.delegateClass = SceneDelegate.self Now, I do 'extension SceneDelegate' in Target 2. In this extension, I have put the 'willConnectTo' function definition. Target 2 is also compiled as a static library. extension SceneDelegate { public func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // ... } // Also has sceneDidDisconnect } The App Target has Target 1 and Target 2 added under 'Link Binary with Libraries'. Now when the application runs, willConnectTo is never invoked, which was in Target 2. The other code in Target 2 is invoked properly. However the other lifecycle states like SceneDidBecomeActive, sceneDidResignActive etc from Target 1 gets invoked. Is there any limitation as such when using extensions in this manner ?
0
0
501
Nov ’22
How to launch an application in Minimized mode in macOS?
In macOS, an application can be launched in hidden mode through the login items i.e. Preference -> Users & Groups -> For any user, Login Items -> Select the application and click on 'Launch as Hidden'. When this user logs into the machine, the selected application would be launched - app icon would be visible in dock panel and application window would not be visible. Application window becomes visible only when the app icon is clicked once. Documentation of all also talks about miniaturizing all windows. I understand miniaturize-all would end up in all windows being minimized. Can an application be launched in such a mode ? In Windows an application can be launched from PowerShell as 'Start-Process -WindowStyle Hidden' or 'Start-Process -WindowStyle Minimized'. For macOS, is there an way to launch an application with miniatured window, either through the OS/App setting or through some command/script. In that case, how is hidden different from miniaturize ? They seem to be similar. Any inputs will help to get clarity on this.
0
0
2.6k
Nov ’22
Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7feb2d019000> - In Swift
I  have an iOS project where my entry point is in Swift and the logic is in C++. Hence, I use a ObjectiveC++ bridge in between. I would be creating Ui programmatically using Swift and there is no usage of storyboard file too. Now, once the 'didFinishLaunching' of the AppDelegate is reached, it calls a Objective C++ method to do the initial setup (core initializations etc). Once things are done, I need to create a UIWindow and attach a ViewController to it. Below is how the code looks : func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. NSLog("didFinishLaunching called") MyObjCppWrapper.mySampleObjCppFunc() return true } The ObjCppWrapper class's implementation : @implementation MyObjCppWrapper + (void) mySampleObjCppFunc { [MySampleCreateWindow CreateWindow]; } @end MySampleCreateWindow is a Swift Class which does the work to create the window. Implementation is : @objc class MySampleCreateWindow: NSObject { @objc static func CreateWindow () { var window = UIWindow (frame: UIScreen.main.bounds) window.rootViewController = UINavigationController (rootViewController: ViewController ()) window.makeKeyAndVisible() } } The ViewController just shows a button lets say - code added under 'viewDidLoad'. When I run this application, I get the below error : 2022-09-21 12:55:51.039805+0530 TWSampleiOSWithoutSB01[47488:4493039] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7feb2d019000>. Surprisingly, the code written inside CreateWindow of the MySampleCreateWindow class runs fine if it is pasted inside the didFinishLaunching of the AppDelegate. Any suggestions on what I am doing wrong or should correct ? Please note : Many of the solutions given to this similar error were for Obj-C and different scenarios. Some of them seem to be deprecated now.
0
0
1k
Sep ’22
Xcode watchOS project not building from commandline
I have an 'Independent watchOS' project created in Xcode. To this project, I have linked few static libraries (as xcframework). The architecture is set to 'x86_64'. I am able to successfully build this project and deploy it on the watch simulator. The code inside the static libraries also get called and things work fine. However, when I try to build the same project from command-line, it doesnt work and fails with multiple errors. Command used : xcodebuild -target "TWWatchOSTemplateProj WatchKit App" -configuration Debug -destination 'platform=watchOS Simulator,arch=x86_64' build Error : /Users/abhishek.mohata/TW_Test_Projects/TWKshetrapalNative/TWLibs/TWBrahmaClient.xcframework:1:1: error: While building for watchOS, no library for this platform was found in '/Users/abhishek.mohata/TW_Test_Projects/TWKshetrapalNative/TWLibs/TWBrahmaClient.xcframework'. (in target 'TWWatchOSTemplateProj WatchKit Extension' from project 'TWWatchOSTemplateProj') warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64_32, armv7k). (in target 'TWWatchOSTemplateProj WatchKit Extension' from project 'TWWatchOSTemplateProj') error: No profiles for 'com.tally.TWWatchOSTemplateProj.watchkitapp' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.tally.TWWatchOSTemplateProj.watchkitapp'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'TWWatchOSTemplateProj WatchKit App' from project 'TWWatchOSTemplateProj') warning: ONLY_ACTIVE_ARCH=YES requested with multiple ARCHS and no active architecture could be computed; building for all applicable architectures (in target 'TWWatchOSTemplateProj WatchKit App' from project 'TWWatchOSTemplateProj') ** BUILD FAILED ** When built from command-line, why is the error related to architecture comes while the same works from xcode ? Also, is there anything to be added to the command for signing as the details are already present in the xcodeproj.
0
0
716
Jun ’22
iOS Simulator gives 'You dont have permission error'
I am currently on macOS Monterey 12.2 and have started an iPhone 12 iOS 15.0 simulator. On this simulator, if I drop files from desktop or a folder inside desktop, I get an error saying, 'The file could not be opened because you don't have the permission to view it'. However, if this files is moved to some folder inside ~/Builds/SampleFiles/*, the drag and drop copies the files to the simulator. Is something specific needed to be done to provide such an access to the simulator ? I can see that Simulator has 'Full Disk Access' under 'Security and Privacy'.
2
0
2.5k
Feb ’22
File association with application where file-extension is not defined in plist file
Hi, We are developing a Business Management application for Accounting/Inventory/Invoicing etc. which is capable of being integrated with a reasonably wide variety of 3rd Party document formats – like spreadsheets, and PDF, and ALSO capable of being customized by the end-user to support additional formats.  While the ‘out-of-the-box’ integrations(extensions) can be listed in the info.plist for people to opt to open a particular document type using our application, if they wish to – what do we need to do to allow them to associate their own customized integrations.  For defining the same in plist file, we do this for already defined extensions : <dict> <key>CFBundleTypeName</key> <string>TWDB</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.tw.twdb</string> </array> </dict>
0
0
473
Feb ’22
Programmatically access all desktops/workspaces in macOS
Hi, I would like to be able to tell at any time which mission control workspace the user is currently using programmatically on macOS or programmatically check the number of desktops/workspaces are currently created on a macOS screen. I could not find any working answer during my search. Any workspace identifier works for me (uuid, workspace number...). Is there a programmatic way of doing this in Objective C ? Thank you for the help!
0
0
509
Jan ’22
How to detach application process from the parent console/terminal ?
I have an application that is built as an app bundle. I open a new terminal window, and launch the application through ./. When I do this, the application UI is launched and some application logs are printed on the terminal. If I want to detach my application process from the terminal, how can the same be achieved such that I can close the terminal and my application keeps running. Basically, how do we ‘detach’ from the parent console once we have detected that we WERE started from the parent console ?
0
0
770
Jan ’22
Difference between open --hide and open --background
Hi, I am trying to use the open command from the Terminal window to open my application. I have tried the following : open --hide MyApp.app open --background MyApp.app The documentation says : --help launch the app hidden and --background does not bring the application to the foreground. I would like to understand the difference between the two ? What I have observed is, in both cases the application launches and my GUI Window is not in the foreground. Am I missing something ?
0
0
472
Dec ’21
Having multiple sessions on Mac with same user
Hi, I have a shared Mac system running on BigSur 11.4 - which I access from office and home. I have a single user id, and do not want the two sessions to interfere with each other. Can I have 2 independent sessions on this Mac machine for the same user ? Basically, I am seeking guidance on ‘what kind of options/settings/helper applications' will allow me to do this. Thanks in advance.
0
0
789
Dec ’21