Post

Replies

Boosts

Views

Activity

Reply to How to force XCode 14.3 to install on Monterey
I found a not-so-perfect solution. It turned out that you can actually ignore Info.plist hacking. You can directly run it inside a Terminal window. I just downloaded Xcode_14.3.1_Release_Candidate.xip yesterday and I can get it running using the following commands: cd ~/Application/Xcode.app/Contents/MacOS ./Xcode It works without any problem. Building/debugging works fine. But there is some gotchas: The icon of course is shown as "No" sign. When there is no project open, and you switch to other apps, you have no way to switch it back because macOS won't list it when you press CMD+TAB, but it is in Activity Monitor. So comes a question. Does anyone know how bring Xcode app window back?
May ’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 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 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 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 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 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 Linker errors in Swift app with a framework bundle
Ah, it's my fault. Framework in a bundle just won't work. I have to create a new target with a Framework type. Now my test app runs.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Not able to inherit from NSObject in unit test
Can I delete this question? It's stupid because I was overwhelmed by other learning problems and asked this silly question.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to How to force XCode 14.3 to install on Monterey
I found a not-so-perfect solution. It turned out that you can actually ignore Info.plist hacking. You can directly run it inside a Terminal window. I just downloaded Xcode_14.3.1_Release_Candidate.xip yesterday and I can get it running using the following commands: cd ~/Application/Xcode.app/Contents/MacOS ./Xcode It works without any problem. Building/debugging works fine. But there is some gotchas: The icon of course is shown as "No" sign. When there is no project open, and you switch to other apps, you have no way to switch it back because macOS won't list it when you press CMD+TAB, but it is in Activity Monitor. So comes a question. Does anyone know how bring Xcode app window back?
Replies
Boosts
Views
Activity
May ’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
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 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 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 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 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 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 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 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 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 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 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