在XCode中使用私有API时出现编译错误

时间:2016-01-29 19:07:52

标签: ios objective-c iphone xcode iphone-privateapi

我正在尝试使用Apple Private API为iPhone编写应用程序。 这仅供个人开发人员使用。它不会被提交到应用程序商店,因此我不必担心拒绝。

我已按照此视频中的说明操作,但我不太确定如何修复这些编译错误:

enter image description here

以下是Youtube链接:https://www.youtube.com/watch?v=OLX7b_KZIvg

如果您不想观看Youtube视频,可以采取以下步骤来制作这些错误:

  1. 从此网址下载私有框架标头:https://github.com/kennytm/iphone-private-frameworks/tree/master
  2. 解压缩下载的文件
  3. 将所需的类复制到Xcode PrivateFrameworks路径中,我的路径是: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks (我使用了TelephonyUtilities.framework)
  4. 在Xcode中创建一个新项目(我使用的是7.2版本)
  5. 转到项目/构建设置并将“框架搜索路径”值设置为/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks(您的路径可能略有不同)
  6. Go Project / General并将库TelephonyUtilities.framework添加到“Linked Frameworks and Libraries”部分
  7. 注意:1。此时,您应该能够无误地构建       2.还应该在左侧面板的项目文件夹中看到私有框架。

    1. 现在,如果您在项目中为ViewController.h添加标题并进行构建,则会显示上面显示的错误。
    2. 这是我的ViewController.h文件:

      #import <UIKit/UIKit.h>
      #include <TelephonyUtilities/TUCallCenter.h>  // <<<<< This line causes the compilation errors
      
      @interface ViewController : UIViewController
      
      
      @end
      

      我使用私有API的原因是我希望我的应用接受来电,公共API不允许。

      任何有助于解决此问题的帮助或指针都将受到赞赏。

      由于

2 个答案:

答案 0 :(得分:0)

如果有人想知道,我需要的修复非常简单。 幸运的是,我并不需要TUCallCenter类中的所有可用功能。 我只需要一些,我可以通过评论不必要的行来逃避。

以下是对TUCallCenter.h头文件的更改:

/* Generated by RuntimeBrowser
   Image: /System/Library/PrivateFrameworks/TelephonyUtilities.framework/TelephonyUtilities
 */

#include "TUCallModelState.h"  // <<< Had to add this because TUCallModelState is used below

@interface TUCallCenter : NSObject {
    TUCallModelState *_callModelState;
}

//@property (nonatomic, readonly, retain) TUCall *activeVideoCall;
//@property (nonatomic, readonly) BOOL anyCallIsEndpointOnCurrentDevice;
//@property (nonatomic, readonly) BOOL anyCallIsHostedOnCurrentDevice;
//@property (nonatomic, readonly) unsigned int callCountOnDefaultPairedDevice;
//@property (nonatomic, readonly, copy) NSArray *callGroupsOnDefaultPairedDevice;
@property (nonatomic, retain) TUCallModelState *callModelState;
//@property (nonatomic, readonly, copy) NSArray *callsHostedElsewhere;
//@property (nonatomic, readonly, copy) NSArray *callsHostedOrAnEndpointElsewhere;
//@property (nonatomic, readonly, copy) NSArray *callsOnDefaultPairedDevice;
//@property (nonatomic, readonly, copy) NSArray *callsWithAnEndpointElsewhere;
//@property (nonatomic, readonly, copy) NSArray *conferenceParticipantCalls;
//@property (nonatomic, readonly) unsigned int currentAudioAndVideoCallCount;
//@property (nonatomic, readonly, copy) NSArray *currentAudioAndVideoCalls;
//@property (nonatomic, readonly) unsigned int currentCallCount;
//@property (nonatomic, readonly, retain) NSArray *currentCallGroups;
//@property (nonatomic, readonly, copy) NSArray *currentCalls;
//@property (nonatomic, readonly, retain) TUCall *currentVideoCall;
//@property (nonatomic, readonly) unsigned int currentVideoCallCount;
//@property (nonatomic, readonly, copy) NSArray *currentVideoCalls;
//@property (nonatomic, readonly, copy) NSArray *displayedCalls;
//@property (nonatomic, readonly, retain) TUCall *incomingCall;
//@property (nonatomic, readonly, copy) NSArray *incomingCalls;
//@property (nonatomic, readonly, retain) TUCall *incomingVideoCall;
//
//+ (id)_sharedInstanceWithDaemonDelegate:(id)arg1;
//+ (BOOL)emergencyCallBackModeIsActive;
+ (BOOL)isInCallServiceProcess;
//+ (void*)sharedAddressBook;
+ (id)sharedInstance;
//
//- (void).cxx_destruct;
//- (id)_allCalls;
//- (id)_callGroupsFromCalls:(id)arg1;
//- (void)_callStatusChangedInternal:(id)arg1;
//- (id)_dial:(id)arg1 callID:(int)arg2 service:(int)arg3 sourceIdentifier:(id)arg4 dialType:(int)arg5 uniqueProxyIdentifier:(id)arg6;
//- (id)_dialWithRequest:(id)arg1 completion:(id /* block */)arg2;
//- (void)_handleCallControlFailure:(id)arg1;
//- (id)activeVideoCall;
//- (BOOL)allCallsAreOfService:(int)arg1;
//- (BOOL)allCallsPassTest:(id /* block */)arg1;
//- (int)ambiguityState;
- (void)answerCall:(id)arg1;
//- (void)answerCall:(id)arg1 withSourceIdentifier:(id)arg2;
//- (void)answerCall:(id)arg1 withSourceIdentifier:(id)arg2 wantsHoldMusic:(BOOL)arg3;
//- (void)answerCallWithHoldMusic:(id)arg1;
//- (BOOL)anyCallIsEndpointOnCurrentDevice;
//- (BOOL)anyCallIsHostedOnCurrentDevice;
//- (BOOL)anyCallPassesTest:(id /* block */)arg1;
//- (id)audioAndVideoCallsWithStatus:(int)arg1;
//- (id)audioOrVideoCallWithStatus:(int)arg1;
//- (unsigned int)callCountOnDefaultPairedDevice;
//- (id)callGroupsOnDefaultPairedDevice;
//- (id)callModelState;
//- (id)callPassingTest:(id /* block */)arg1;
//- (id)callPassingTest:(id /* block */)arg1 sortedUsingComparator:(id /* block */)arg2;
//- (id)callPassingTest:(id /* block */)arg1 withOptions:(unsigned int)arg2;
//- (id)callWithCallUUID:(id)arg1;
//- (id)callWithStatus:(int)arg1;
//- (id)callWithUniqueProxyIdentifier:(id)arg1;
//- (id)callsHostedElsewhere;
//- (id)callsHostedOrAnEndpointElsewhere;
//- (id)callsOnDefaultPairedDevice;
//- (id)callsPassingTest:(id /* block */)arg1;
//- (id)callsPassingTest:(id /* block */)arg1 returningNilForEmpty:(BOOL)arg2;
//- (id)callsWithAnEndpointElsewhere;
//- (id)callsWithStatus:(int)arg1;
//- (BOOL)canInitiateCallForService:(int)arg1;
//- (BOOL)canInitiateCalls;
//- (BOOL)canInitiateVoicemailCall;
//- (BOOL)canMergeCalls;
//- (BOOL)canUseThumperOverRelayForIncomingAndOutgoingCalls;
//- (id)conferenceCall;
//- (id)conferenceParticipantCalls;
//- (unsigned int)countOfCallsPassingTest:(id /* block */)arg1;
//- (unsigned int)currentAudioAndVideoCallCount;
//- (id)currentAudioAndVideoCalls;
//- (unsigned int)currentCallCount;
//- (id)currentCallGroups;
//- (id)currentCalls;
//- (id)currentVideoCall;
//- (unsigned int)currentVideoCallCount;
//- (id)currentVideoCalls;
//- (void)dealloc;
//- (id)dial:(id)arg1 callID:(int)arg2 service:(int)arg3;
//- (id)dial:(id)arg1 callID:(int)arg2 service:(int)arg3 sourceIdentifier:(id)arg4 uniqueProxyIdentifier:(id)arg5;
//- (id)dial:(id)arg1 service:(int)arg2;
//- (id)dialEmergency:(id)arg1;
//- (id)dialEmergency:(id)arg1 sourceIdentifier:(id)arg2;
//- (id)dialVoicemail;
//- (id)dialVoicemailWithSourceIdentifier:(id)arg1;
//- (id)dialWithRequest:(id)arg1;
//- (void)dialWithRequest:(id)arg1 completion:(id /* block */)arg2;
//- (void)disconnectAllCalls;
//- (void)disconnectCall:(id)arg1;
//- (void)disconnectCall:(id)arg1 withReason:(int)arg2;
//- (void)disconnectCurrentCallAndActivateHeld;
//- (void)disconnectNonRelayingCalls;
//- (void)disconnectRelayingCalls;
//- (id)displayedCall;
//- (id)displayedCallFromCalls:(id)arg1;
//- (id)displayedCalls;
//- (void)endActiveAndAnswerCall:(id)arg1;
//- (void)endActiveOrHeldAndAnswerCall:(id)arg1;
//- (void)endEmergencyCallBackMode;
//- (void)endHeldAndAnswerCall:(id)arg1;
//- (void)enteredBackgroundForAllCalls;
//- (void)enteredForegroundForCall:(id)arg1;
//- (void)enumerateCallsInvokingBlock:(id /* block */)arg1 forCallsPassingTest:(id /* block */)arg2;
//- (void)enumerateCallsWithOptions:(unsigned int)arg1 invokingBlock:(id /* block */)arg2 forCallsPassingTest:(id /* block */)arg3;
//- (id)frontmostAudioOrVideoCall;
//- (id)frontmostCall;
- (void)handleCallModelStateChanged:(id)arg1;
//- (void)holdActiveAndAnswerCall:(id)arg1;
//- (id)incomingCall;
//- (id)incomingCalls;
//- (id)incomingVideoCall;
//- (id)initWithDaemonDelegate:(id)arg1;
//- (BOOL)isAddCallAllowed;
//- (BOOL)isAmbiguous;
//- (BOOL)isEndAndAnswerAllowed;
//- (BOOL)isHardPauseAvailable;
//- (BOOL)isHoldAllowed;
//- (BOOL)isHoldAndAnswerAllowed;
//- (BOOL)isMergeable;
//- (BOOL)isSendToVoicemailAllowed;
//- (BOOL)isSwappable;
//- (BOOL)isTakingCallsPrivateAllowed;
//- (void)pullHostedCallsFromPairedHostDevice;
//- (void)pullRelayingCallsFromClient;
//- (void)pullThumperCallFromClientUsingInfo:(id)arg1 completion:(id /* block */)arg2;
//- (void)pushHostedCallsToPairedClientDevice;
//- (void)pushRelayingCallsToHost;
//- (void)pushRelayingCallsToHostWithSourceIdentifier:(id)arg1;
//- (void)resumeCall:(id)arg1;
//- (void)sendFieldModeDigits:(id)arg1;
//- (void)setCallModelState:(id)arg1;
//- (void)swapCalls;
//- (id)videoCallWithStatus:(int)arg1;

@end

正如您所看到的,只留下了一些功能,我能够构建并运行。

答案 1 :(得分:0)

{{1}}

这是使用私有框架动态加载TUCallCenter实例的方法。