Post

Replies

Boosts

Views

Activity

Reply to Which version of Xcode works best with macOS 12 (Monterey)?
I am not sure if the problems are only specific to me, but I did not experience similar ones for the past many years. The Quick Help pane always stops displaying help after some time of use (for example, after debugging). I get weird auto layout design time issues in IB (I am sure my constraints are correct). Today I got a weird error when I build one of my test project (something about Array Controller but not in my code). When I close and re-open and build, the problem is gone.
Mar ’23
Reply to How can I know when an NSTextField gets input focus (first responder)?
I found out why myself. I create a custom NSWindowController: @implementation MainWC - (void)windowDidLoad { [super windowDidLoad]; MainVC* vc = (MainVC*)self.contentViewController; [vc windowLoaded]; } @end And in MainVC: - (void)windowLoaded { [self.view.window addObserver:self forKeyPath:@"firstResponder" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context { NSView* oldView = change[NSKeyValueChangeOldKey]; NSView* newView = change[NSKeyValueChangeNewKey]; NSLog(@"%@ (%@) ====> %@ (%@)", oldView.identifier, oldView.class, newView.identifier, newView.class); } It seems when a textfield is focused, it immediately resigns and gives focus to its inner textview: 2023-03-24 18:02:54.841247+0800 ObjcTest[25855:1521206] _NS:10 (NSWindow) ====> normal (NSTextField) 2023-03-24 18:02:54.846902+0800 ObjcTest[25855:1521206] normal (NSTextField) ====> (null) (NSTextView) 2023-03-24 18:02:56.032290+0800 ObjcTest[25855:1521662] Sleep done in q 2023-03-24 18:03:09.653850+0800 ObjcTest[25855:1521206] (null) (NSTextView) ====> _NS:10 (NSWindow) 2023-03-24 18:03:09.657517+0800 ObjcTest[25855:1521206] _NS:10 (NSWindow) ====> mytextfield (MyTextField) 2023-03-24 18:03:09.657677+0800 ObjcTest[25855:1521206] -[MyTextField becomeFirstResponder]: <MyTextField: 0x7f8dfa123eb0> 2023-03-24 18:03:09.659349+0800 ObjcTest[25855:1521206] -[MyTextField resignFirstResponder]: <MyTextField: 0x7f8dfa123eb0> 2023-03-24 18:03:09.659522+0800 ObjcTest[25855:1521206] mytextfield (MyTextField) ====> (null) (NSTextView)
Topic: UI Frameworks SubTopic: AppKit Tags:
Mar ’23
Reply to chevron.down.square.fill image name
Thanks for your replies. Okay, I found it here https://developer.apple.com/sf-symbols/ I have a new question. My app min target OS is macOS 10.10. Can I use [NSImage imageNamed:@"chevron.down.square.fill"] in code so that it still works on macOS 10.10? Or should I just use the official app and export the symbols as pictures?
Topic: UI Frameworks SubTopic: AppKit Tags:
Mar ’23
Reply to CFBundleIdentifier not match?
I tried to upload one of my App Store apps, got a new error (upload failed): Metadata/Info.plist Mismatch. The value for bundle_version in the metadata.xml file does not match the value for CFBundleVersion in MYAPP [net.neolib.MYAPP.pkg/Payload/MYAPP.app]. (ID: 9675c1c2-4332-43d8-87d9-4e7f51c83f1b) I feel I am being tortured and helpless...
Apr ’23
Reply to IB_DESIGNABLE and dylib problem
Ah, it's agony! I struggled with this for many hours and finally get it to work, in a mysterious way. At first, setting @rpath to "@loader_path/../Frameworks" or "@executable_path/../Frameworks" did not work. After many tries, I set it to both of the 2 paths and IB_DESIGNABLE started working. But I may be wrong because I tried many many times and ways. It might be that I once set a hardcoded path to the directory where libCocoaSQLite.dylib resides in ("/Users/USERNAME/some/long/path/to/the/dylib"). Then maybe Xcode caches the location somewhere and voila it works! Now the weird thing is that even now I set @rpath to "@loader_path/../Frameworks" alone, IB_DESIGNABLE still works. I cleaned build folder and even rebooted macOS. Is it mysterious?!
Apr ’23
Reply to Weird: let statement leads to nil
It seems self.webView.evaluateJavaScript cannot be called within async context: //Task.init { //await self.test1() //try? await self.webView.evaluateJavaScript("alert('test')") } The above simple code runs without any problem in synchronous mode, but will cause a runtime exception if is called in Task.init block. Is this by design? But I don't believe it.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’23
Reply to Generated xcarchive has no built dylib
I submitted a tick in Apple's feedback center here and got a reply form Apple genius: Change SKIP_INSTALL to NO. If it’s set to yes, then your library product isn’t copied into its install location, and thus doesn’t appear in the archive. Xcode 7.2.1 is a pretty old compare, it probably had bugs in the opposite direction. I really don't understand this default setting. I want a dylib when I create a release archive, but with this default setting on, I don't get one. What's the point? Actually I know the reason behind - Apples is forcing developers to upgrade to latest version. This is just one of many nag bugs deliberately planted into older version of Xcode.
May ’23
Reply to Can I use libraries from brew.sh in my app?
Actually, what I want to do is integrate Firebird database engine which requires icu library. But I had problems installing the official package. Are there any successful stories that I can follow?
Replies
Boosts
Views
Activity
Mar ’22
Reply to How do I control popover invoked by segue?
Sorry for not stating my question clear enough. What I want is NSPopoverDelegate so that I know when the popover is closed so that I can perform some work accordingly.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Which version of Xcode works best with macOS 12 (Monterey)?
I am not sure if the problems are only specific to me, but I did not experience similar ones for the past many years. The Quick Help pane always stops displaying help after some time of use (for example, after debugging). I get weird auto layout design time issues in IB (I am sure my constraints are correct). Today I got a weird error when I build one of my test project (something about Array Controller but not in my code). When I close and re-open and build, the problem is gone.
Replies
Boosts
Views
Activity
Mar ’23
Reply to Which version of Xcode works best with macOS 12 (Monterey)?
I have a test project. The main.storyboard has several VC scenes. One scene has 3 NSTableViews in a row and auto layout works perfectly when I run the app. The weird thing is that each time I open the project, the top spacing constraint grows a little (56). I do not modify anything. After several times of re-opening, the value reverts to the standard value.
Replies
Boosts
Views
Activity
Mar ’23
Reply to KVO addObserver:forKeyPath not working
Soon after I posted this question, I found out why. The window property is not set yet when view is loaded. Now comes a new question - what is the correct time/place to add the addObserver method?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to How can I know when an NSTextField gets input focus (first responder)?
I found out why myself. I create a custom NSWindowController: @implementation MainWC - (void)windowDidLoad { [super windowDidLoad]; MainVC* vc = (MainVC*)self.contentViewController; [vc windowLoaded]; } @end And in MainVC: - (void)windowLoaded { [self.view.window addObserver:self forKeyPath:@"firstResponder" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context { NSView* oldView = change[NSKeyValueChangeOldKey]; NSView* newView = change[NSKeyValueChangeNewKey]; NSLog(@"%@ (%@) ====> %@ (%@)", oldView.identifier, oldView.class, newView.identifier, newView.class); } It seems when a textfield is focused, it immediately resigns and gives focus to its inner textview: 2023-03-24 18:02:54.841247+0800 ObjcTest[25855:1521206] _NS:10 (NSWindow) ====> normal (NSTextField) 2023-03-24 18:02:54.846902+0800 ObjcTest[25855:1521206] normal (NSTextField) ====> (null) (NSTextView) 2023-03-24 18:02:56.032290+0800 ObjcTest[25855:1521662] Sleep done in q 2023-03-24 18:03:09.653850+0800 ObjcTest[25855:1521206] (null) (NSTextView) ====> _NS:10 (NSWindow) 2023-03-24 18:03:09.657517+0800 ObjcTest[25855:1521206] _NS:10 (NSWindow) ====> mytextfield (MyTextField) 2023-03-24 18:03:09.657677+0800 ObjcTest[25855:1521206] -[MyTextField becomeFirstResponder]: <MyTextField: 0x7f8dfa123eb0> 2023-03-24 18:03:09.659349+0800 ObjcTest[25855:1521206] -[MyTextField resignFirstResponder]: <MyTextField: 0x7f8dfa123eb0> 2023-03-24 18:03:09.659522+0800 ObjcTest[25855:1521206] mytextfield (MyTextField) ====> (null) (NSTextView)
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to chevron.down.square.fill image name
Thanks for your replies. Okay, I found it here https://developer.apple.com/sf-symbols/ I have a new question. My app min target OS is macOS 10.10. Can I use [NSImage imageNamed:@"chevron.down.square.fill"] in code so that it still works on macOS 10.10? Or should I just use the official app and export the symbols as pictures?
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to NSStackView.distribution runtime question
I now answer my own question. I installed macOS 10.10 (Yosemite) and can confirm that my app does not crash. BTW, here is the page to download older versions.
Replies
Boosts
Views
Activity
Apr ’23
Reply to IB_DESIGNABLE and dylib problem
I believe this is a bug. IB is looking at the wrong place. It is looking at MYAPP/Contents/MacOS/Frameworks instead of configured MYAPP/Contents/MacOS/../Frameworks.
Replies
Boosts
Views
Activity
Apr ’23
Reply to CFBundleIdentifier not match?
I tried to upload one of my App Store apps, got a new error (upload failed): Metadata/Info.plist Mismatch. The value for bundle_version in the metadata.xml file does not match the value for CFBundleVersion in MYAPP [net.neolib.MYAPP.pkg/Payload/MYAPP.app]. (ID: 9675c1c2-4332-43d8-87d9-4e7f51c83f1b) I feel I am being tortured and helpless...
Replies
Boosts
Views
Activity
Apr ’23
Reply to Quick Help always stops working after debugging
I found out an interesting fact. When Quick Help stops working at all, If I open another project then it immediately comes back. It seems some background work has a bug. Are there any Apple genius devs watching these forums? Hello, can you hear me?
Replies
Boosts
Views
Activity
Apr ’23
Reply to IB_DESIGNABLE and dylib problem
Ah, it's agony! I struggled with this for many hours and finally get it to work, in a mysterious way. At first, setting @rpath to "@loader_path/../Frameworks" or "@executable_path/../Frameworks" did not work. After many tries, I set it to both of the 2 paths and IB_DESIGNABLE started working. But I may be wrong because I tried many many times and ways. It might be that I once set a hardcoded path to the directory where libCocoaSQLite.dylib resides in ("/Users/USERNAME/some/long/path/to/the/dylib"). Then maybe Xcode caches the location somewhere and voila it works! Now the weird thing is that even now I set @rpath to "@loader_path/../Frameworks" alone, IB_DESIGNABLE still works. I cleaned build folder and even rebooted macOS. Is it mysterious?!
Replies
Boosts
Views
Activity
Apr ’23
Reply to Weird: let statement leads to nil
The error is: 2023-04-28 17:53:20.523568+0800 WKWebViewTest[21469:545345] :0: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to Weird: let statement leads to nil
It seems self.webView.evaluateJavaScript cannot be called within async context: //Task.init { //await self.test1() //try? await self.webView.evaluateJavaScript("alert('test')") } The above simple code runs without any problem in synchronous mode, but will cause a runtime exception if is called in Task.init block. Is this by design? But I don't believe it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to Generated xcarchive has no built dylib
I submitted a tick in Apple's feedback center here and got a reply form Apple genius: Change SKIP_INSTALL to NO. If it’s set to yes, then your library product isn’t copied into its install location, and thus doesn’t appear in the archive. Xcode 7.2.1 is a pretty old compare, it probably had bugs in the opposite direction. I really don't understand this default setting. I want a dylib when I create a release archive, but with this default setting on, I don't get one. What's the point? Actually I know the reason behind - Apples is forcing developers to upgrade to latest version. This is just one of many nag bugs deliberately planted into older version of Xcode.
Replies
Boosts
Views
Activity
May ’23