7

I'm following the selected answer importing private frameworks in Xcode

Basically I want to be able to control Airplane mode in my app. When I import RadioPreferences.h into my app and try to compile, I'm getting Expected Identifier for @class <RadiosPreferencesDelegate>;

I'm not exactly sure what to do next. I didn't even know you can forward declare protocols.

Community
  • 1
  • 1
ninjaneer
  • 6,951
  • 8
  • 60
  • 104
  • See here http://stackoverflow.com/questions/13095109/reachability-airplane-mode-3g-vs-wifi – Joe Nov 14 '12 at 21:08
  • I'm getting: `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)` – ninjaneer Nov 14 '12 at 21:18
  • Where did you find `RadioPreferences.h`, you need to make sure you link against the correct framework? – Joe Nov 14 '12 at 21:24
  • ACB's answer shows that I should paste the contents into `RadiosPreferences.h`. I'm assuming that's the AppSupport.framework? – ninjaneer Nov 14 '12 at 21:28

1 Answers1

8

First copy the following contents into a file named RadioPreferences.h. (Taken from 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

  • Next, go to the Build Phases of your target in Xcode and expand the Link Binary With Libraries section.
  • In a finder window navigate to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/PrivateFrameworks. Replace iPhoneOS6.0.sdk in the path with the sdk you are targeting.
  • Drag AppSupport.framework over to your expanded Link Binary With Libraries section.

Everything should now compile and you will be able to use the class.

Community
  • 1
  • 1
Joe
  • 56,979
  • 9
  • 128
  • 135
  • Actually wait, I'm still getting `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)` after following this. – ninjaneer Nov 14 '12 at 22:22
  • The above code is working for me with entitlements for <= 6.x. But I am unable to toggle it for IOS 7.x. Please give the Api details if you are able to do it – androabhay Mar 11 '14 at 08:51
  • @Ninja I am facing the same error. How you resolved Undefined symbols for architecture armv7? – user2533604 Oct 10 '14 at 10:41
  • sorry, i don't remember. this was a long time ago. – ninjaneer Oct 10 '14 at 19:49