cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

CocoaPods with frameworks #87

Closed radex closed 8 years ago

radex commented 8 years ago

If I enable framework use in CocoaPods (for Swift support), like so:

target :Mac do
  platform :osx, '10.10'
  use_frameworks!
  link_with 'Mac'

  pod 'MASShortcut',      '~> 2.3'
end

MASShortcut won't work. Trying to #import a header doesn't work, and importing the MASShortcut module will silently fail — will compile, but no symbols will actually be imported.

I pinned down the issue to the the MASShortcut-umbrella.h file generated by CocoaPods:

#import <Cocoa/Cocoa.h>

#import "MASDictionaryTransformer.h"
#import "MASHotKey.h"
#import "MASKeyCodes.h"
#import "MASLocalization.h"
#import "MASShortcut.h"
#import "MASShortcutBinder.h"
#import "MASShortcutMonitor.h"
#import "MASShortcutValidator.h"
#import "MASShortcutView+Bindings.h"
#import "MASShortcutView.h"
//#import "Shortcut.h"

FOUNDATION_EXPORT double MASShortcutVersionNumber;
FOUNDATION_EXPORT const unsigned char MASShortcutVersionString[];

I suppose that the fact that it generates both imports to all headers automatically and also adds your import-all Shortcut.h confuses the compiler somehow. When I commented out that import, it works now (I can now import MASShortcut in Swift, no problem). But I don't know how to fix it for everyone.

shpakovski commented 8 years ago

Thanks a lot for the problem report Radek! Sorry but I don't know how to fix this. @zoul Hi Tomáš, maybe you have any idea?

zoul commented 8 years ago

I just tried creating a fresh Xcode Swift project for an OS X app using MASShortcut via CocoaPods with the use_frameworks flag on. The project builds just fine, I can import MASShortcut without build errors and also creating and logging an instance of MASShortcut works. Where could the difference be?

radex commented 8 years ago

Very interesting. I'll try this again later in the week, but one diff could be, I'm using CocoaPods targets to group together pods…

radex commented 8 years ago

Sigh. I tried again, making sure to remove all of DerivedData etc, and could not reproduce the issue. Perhaps it was some botched cache (I was upgrading from 1.x after all).

shpakovski commented 8 years ago

Thank you very much guys!

zoul commented 8 years ago

Happy to help! 👍