【问题标题】:Using Private Framework: Importing RadioPreferences.h使用私有框架:导入 RadioPreferences.h
【发布时间】:2012-11-14 20:59:14
【问题描述】:

我正在关注所选答案importing private frameworks in Xcode

基本上,我希望能够在我的应用中控制飞行模式。当我将RadioPreferences.h 导入我的应用程序并尝试编译时,我得到Expected Identifier for @class <RadiosPreferencesDelegate>;

我不确定下一步该做什么。我什至不知道您可以转发声明协议。

【问题讨论】:

  • 我收到:Undefined symbols for architecture armv7: "_OBJC_CLASS_$_RadiosPreferences", referenced from: objc-class-ref in NetworkManager.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • 您在哪里找到RadioPreferences.h,您需要确保链接到正确的框架?
  • ACB 的回答显示我应该将内容粘贴到RadiosPreferences.h。我假设那是 AppSupport.framework?

标签: iphone objective-c ios private-functions


【解决方案1】:

首先将以下内容复制到一个名为RadioPreferences.h 的文件中。 (取自https://stackoverflow.com/a/13095362/418715)。

@protocol RadiosPreferencesDelegate
-(void)airplaneModeChanged;
@end


@interface RadiosPreferences : NSObject
{
    struct __SCPreferences *_prefs;
    int _applySkipCount;
    id <RadiosPreferencesDelegate> _delegate;
    BOOL _isCachedAirplaneModeValid;
    BOOL _cachedAirplaneMode;
    BOOL notifyForExternalChangeOnly;
}

- (id)init;
- (void)dealloc;
@property(nonatomic) BOOL airplaneMode;
- (void)refresh;
- (void)initializeSCPrefs:(id)arg1;
- (void)notifyTarget:(unsigned int)arg1;
- (void)synchronize;
- (void *)getValueForKey:(id)arg1;
- (void)setValue:(void *)arg1 forKey:(id)arg2;
@property(nonatomic) BOOL notifyForExternalChangeOnly; // @synthesize notifyForExternalChangeOnly;
@property(nonatomic) id <RadiosPreferencesDelegate> delegate; // @synthesize delegate=_delegate;

@end

  • 接下来,转到 Xcode 中目标的 Build Phases 并展开 Link Binary With Libraries 部分。
  • 在查找器窗口中导航到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/PrivateFrameworks。将路径中的 iPhoneOS6.0.sdk 替换为您要定位的 sdk。
  • 将 AppSupport.framework 拖到展开的 Link Binary With Libraries 部分。

现在一切都应该编译好了,你就可以使用这个类了。

【讨论】:

  • 其实等等,我关注这个之后还是得到Undefined symbols for architecture armv7s: "_OBJC_CLASS_$_RadiosPreferences", referenced from: objc-class-ref in NetworkManager.o ld: symbol(s) not found for architecture armv7s clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • 上面的代码对我来说适用于
  • @Ninja 我面临同样的错误。您如何解决架构 armv7 的未定义符号?
  • 对不起,我不记得了。这是很久以前的事了。
猜你喜欢
  • 2021-11-01
  • 2011-05-11
  • 1970-01-01
  • 2011-05-11
  • 2015-04-29
  • 2015-05-19
  • 1970-01-01
  • 1970-01-01
  • 2018-09-01
相关资源
最近更新 更多