Comments (31)
I'm on Cocoapods version of MASShortcut v2.3.3 in a RubyMotion project (I'm on RubyMotion v4.12). I see the "XXX" instead of real strings.
- Has anybody else experienced this with RubyMotion?
- "XXX" is an extremely bad placeholder because you can't google for it (try it, it's NSFW)
from masshortcut.
Indeed, this is a problem, thank you very much for the report! @zoul Will it help if we rename the Localizable.strings
and use a custom table name?
from masshortcut.
I currently use the localized MASShortcut in a production app and it works correctly, but I use Carthage, not CocoaPods. So I think the problem is in our CocoaPods manifest, probably our Localized.strings
file is not installed at all. I’ll take a look at it, just don’t know when yet.
from masshortcut.
I think this will not work, because MASShortcut
s version would just rewrite the local project Localizable.strings
file, there is no “merge policy” for Pods.
from masshortcut.
Oh, I see – this is why I find Carthage better, it just sticks to the framework that’s already defined. Judging by this blog post and this Stack Overflow thread, it looks like we need to create a resource bundle to stick the strings file into?
from masshortcut.
Yeah… This is not very convenient for such a small number of strings :) Any better idea? @beaufour?
from masshortcut.
I really wish I knew more about the inner workings of CocoaPods, but alas I don't.
from masshortcut.
Unless I've missed something, it seems like it wasn't too much work :)
from masshortcut.
Thanks!
from masshortcut.
This is now available in the 2.3.2 release on CocoaPods. @beaufour, can you please verify that the fix works in the version distributed by CocoaPods?
from masshortcut.
👍 Works like a charm.
from masshortcut.
Thank you guys 👻
from masshortcut.
👍
from masshortcut.
This might be related as I'm having reports of users getting some hangs.
I'm using 2.3.2 as a cocoapod.
the crash is :
10/21/15 11:50:25.617 AM com.apple.xpc.launchd[1]: (com.apple.xpc.launchd.oneshot.0x1000002b.GhostNote[19341]) Service exited due to signal: Killed: 9
10/21/15 11:51:20.967 AM GhostNote[24081]: *** -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
10/21/15 11:52:15.079 AM GhostNote[24081]: *** -[NSBundle initWithURL:]: nil URL argument
10/21/15 11:52:15.081 AM GhostNote[24081]: (
0 CoreFoundation 0x00007fff9e4a2bd2 exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8b8b9dd4 objc_exception_throw + 48
2 CoreFoundation 0x00007fff9e5093fd +[NSException raise:format:] + 205
3 Foundation 0x00007fff9cd84ea2 -[NSBundle initWithURL:] + 87
4 Foundation 0x00007fff9cd84e38 +[NSBundle bundleWithURL:] + 45
5 MASShortcut 0x0000000109875f64 MASLocalizedString + 132
6 MASShortcut 0x0000000109879951 -[MASShortcutView drawRect:] + 989
7 AppKit 0x00007fff8c750d5e -[NSView _drawRect:clip:] + 3626
8 AppKit 0x00007fff8c7a951d -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1873
9 AppKit 0x00007fff8c7a98fa -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2862
10 AppKit 0x00007fff8c7a98fa -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2862
11 AppKit 0x00007fff8c74e487 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 838
12 AppKit 0x00007fff8c74dc6c -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 334
13 AppKit 0x00007fff8c74c077 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2449
14 AppKit 0x00007fff8c747485 -[NSView displayIfNeeded] + 1950
15 AppKit 0x00007fff8c746ccc -[NSWindow displayIfNeeded] + 232
16 AppKit 0x00007fff8cdc5206 ___NSWindowGetDisplayCycleObserver_block_invoke6323 + 476
17 AppKit 0x00007fff8c746667 __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 738
18 QuartzCore 0x00007fff9e96b91d _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 85
19 QuartzCore 0x00007fff9e96add8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 160
20 QuartzCore 0x00007fff9e96aa98 _ZN2CA11Transaction6commitEv + 508
21 QuartzCore 0x00007fff9e97628f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 71
22 CoreFoundation 0x00007fff9e437e07 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
23 CoreFoundation 0x00007fff9e437d77 __CFRunLoopDoObservers + 391
24 CoreFoundation 0x00007fff9e416d58 CFRunLoopRunSpecific + 328
25 HIToolbox 0x00007fff90f35d55 RunCurrentEventLoopInMode + 235
26 HIToolbox 0x00007fff90f35a97 ReceiveNextEventCommon + 184
27 HIToolbox 0x00007fff90f359cf _BlockUntilNextEventMatchingListInModeWithFilter + 71
28 AppKit 0x00007fff8c5eef3a _DPSNextEvent + 1067
29 AppKit 0x00007fff8c5ee369 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
30 AppKit 0x00007fff8c5e2ecc -[NSApplication run] + 682
31 GhostNote 0x00000001097e76dd GhostNote + 108253
32 libdyld.dylib 0x00007fff8d6cb5ad start + 1
from masshortcut.
at a breakpoint on line 12 of MASLocalization.m bundleURL is nil.
I'm not sure why I don't get this crash and other users do, but perhaps it has to do with their locale.
I just checked and it appears that the bundle it refers to is in the built product inside the MASShortcut.framework that cocoa pods generated.
from masshortcut.
Thanks a lot for the problem report!
To me it looks like this code may help:
NSString *MASLocalizedString(NSString *key, NSString *comment) {
NSBundle *frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]];
#ifdef COCOAPODS
NSURL *bundleURL = [frameworkBundle URLForResource:@"MASShortcut" withExtension:@"bundle"];
frameworkBundle = [NSBundle bundleWithURL:bundleURL];
#endif
return [frameworkBundle localizedStringForKey:key value:@"XXX" table:@"Localizable"];
}
Can you check if it works please?
from masshortcut.
I believe that is the code that exists in the current latest version.
I found this issue since some users are getting a blocked UI when showing the view that contains the MASShortcutView.
For some reason though, for me it does not hang, but I would see the exception in the debugger.
The URL was nil, and this code seems to resolve properly and get the bundle.
NSString *MASLocalizedString(NSString *key, NSString *comment) {
NSBundle *frameworkBundle = nil;
#ifdef COCOAPODS
// NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"MASShortcut" withExtension:@"framework"];
//
NSURL * bundleURL = [[NSBundle mainBundle] bundleURL];
NSURL *frameworkBundleURL = [bundleURL URLByAppendingPathComponent:@"Contents/Frameworks/MASShortcut.framework/Versions/A/Resources/MASShortcut.bundle"];
frameworkBundle = [NSBundle bundleWithURL:frameworkBundleURL];
#else
frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]];
#endif
return [frameworkBundle localizedStringForKey:key value:@"XXX" table:@"Localizable"];
}
My pod file has the use_frameworks! directive, perhaps that is the difference.
Though that code appears it wouldn’t return a value if COCOAPODS is defined?
On Oct 22, 2015, at 7:25 AM, Vadim Shpakovski [email protected] wrote:
Thanks a lot for the problem report!
To me it looks like this code may help:
NSString *MASLocalizedString(NSString *key, NSString *comment) {
NSBundle *frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]];
#ifdef COCOAPODS
NSURL *bundleURL = [frameworkBundle URLForResource:@"MASShortcut" withExtension:@"bundle"];
frameworkBundle = [NSBundle bundleWithURL:bundleURL];
#else
return [frameworkBundle localizedStringForKey:key value:@"XXX" table:@"Localizable"];
}
Can you check if it works please?—
Reply to this email directly or view it on GitHub #74 (comment).
from masshortcut.
@jhoughjr so you are seeing the bundleURL
== nil
in your local build? And you build with use_frameworks!
? (just making sure I fully understand it)
from masshortcut.
Yes I think that is what is happening.
Currently in specifying a hard coded url gleaned from inspecting the app bundle and the issue seems fixed.
Sent from my iPhone
On Oct 26, 2015, at 3:31 PM, Allan Beaufour [email protected] wrote:
@jhoughjr so you are seeing the bundleURL == nil in your local build? And you build with use_frameworks!? (just making sure I fully understand it)
—
Reply to this email directly or view it on GitHub.
from masshortcut.
Yes I think that is what is happening.
Currently in specifying a hard coded url gleaned from inspecting the app bundle and the issue seems fixed.
Building as a framework is what Carthage is doing as far as I know, so the trick might just to only do the COCOAPODS
ugliness when using CocoaPods but not when building as a framework. If you force the code to take the #else
branch does it work for you?
from masshortcut.
I just ran a pod update
on my application and am now running into the same issue that @jhoughjr was seeing. I also am using the use_frameworks!
flag in my Podfile. The previous version I was using was 2.2.0, which worked just fine for me. For now I've just pinned to that specific version in my Podfile to keep things working, but that isn't the greatest solution.
from masshortcut.
Did we find out whether the use_frameworks!
flag makes COCOAPODS
false? That would explain the issue.
from masshortcut.
Did we find out whether the use_frameworks! flag makes COCOAPODS false? That would explain the issue.
My guess is that it actually makes it true
, but that use_frameworks
doesn't build the bundle so it evaluates to nil. But as said, I'm guessing. I have never used use_frameworks
myself.
from masshortcut.
I think that COCOAPODS
is always set to true when pod install
is run as part of the configuration performed by CocoaPods, regardless of whether you are using frameworks in your application. In looking at my build settings for the application targets, I see that it has been specifically set in both the "Preprocessor Macros" section for Obj-C and the "Other Swift Flags" section for Swift (my application is Swift based and contains Objective-C code).
In the Cocoapods documentation [1] on using frameworks it seems to suggest that the original use of [NSBundle bundleForClass:[MASShortcut class]]
pre #75 should work fine, as it specifically says, "This will then work for both frameworks and static libraries". However, when I manually modify MASLocalization.m to this effect, I run into the original issue @beaufour was seeing with the XXX
fallback being displayed everywhere.
[1] http://blog.cocoapods.org/CocoaPods-0.36/#caveats
from masshortcut.
I have tried to fix the problem by not guessing which bundle to use and simply using the one that works. Can you all please test the new code if it really works as intended? Sorry for the trouble.
from masshortcut.
👍 Works for me (not using use_frameworks!
). Nice dispatch_once
pattern.
from masshortcut.
Sorry for the relayed response. This code does not crash for me, with use_frameworks!
turned on, but unfortunately I'm back to the old issue of the XXX default value being shown everywhere.
I'll poke around to see if I can get something working.
from masshortcut.
So how about now? The current code tests if the CocaPods bundle contains the localized strings. If not, it switches to the framework bundle instead.
from masshortcut.
Sorry everyone, i was very busy the last couple of weeks wrapping up a contract.
I'll test the latest version and let you know tonight.
from masshortcut.
Another data point: 7fc5e78 works for me (with use_frameworks!
). Thanks for the fix!
from masshortcut.
This should be now fixed by d32fc18 (shipped as a part of 2.3.3), sorry for the long wait.
from masshortcut.
Related Issues (20)
- Bridging header file instructions link broken HOT 2
- Can I add a Package.swift file and use it with SPM? HOT 7
- Unconsistency between italian translation from Apple HOT 3
- Tab isn't allowed
- Is there a way I can detect Key press and hold with MASShortcut? HOT 4
- Layout issue on macOS Big Sur HOT 3
- Can't set two arrow keys as part of a shotcut HOT 2
- Not visible to VoiceOver HOT 4
- Multiple Warnings for Deprecations HOT 6
- Toggling shortcut handling? e.g. an off-mode HOT 6
- NSKeyedUnarchiveFromData deprecated warning HOT 5
- Cannot record shortcut with format ⌥+⇧+<Letter> HOT 1
- How to binding custom shortcut on MASShortcutView ?
- Getting 'Error: missing module map file' when trying to build HOT 10
- Request: Could you push a release now that you have SMP support HOT 5
- Crash -[MASShortcutView propagateValue:forBinding:]
- Double-quoted include "MASxyz.h" in framework header, expected angle-bracketed instead HOT 2
- TIS API is deprecated
- EXC_BAD_ACCESS on Monterey when using swift String for defaultsKey
- README.md: "A nice, documented API" links to deprecated cocoadocs.org HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from masshortcut.