How to detect if a dyld-ed symbol exists? - ios

Is there a common way to detect if a symbol exists or not? Like CGPathCreateCopyByStrokingPath() in iOS5, which is only available on iOS5 and later.
If I compile and run apps using this routine on iOS 4 devices, I would get a runtime dyld error.
In Objective-C, +class and other utility APIs can be used to determine the existence of some class or some selector, is there any API to do this on dyld-ed symbols?
Or is it under Apple's permission to use dyld functions for an AppStore oriented app?

To check the availability of a function, explicitly compare its address to NULL or nil.
if (CGPathCreateCopyByStrokingPath != NULL) {
// it exists
}
Here's Apple's documentation on the matter (listing 3-2).

Related

Interpreting nm output after rejected app

my app was rejected by Apple, because somehow my app uses private API's.
Apple said that my app uses
framework: '/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation': CFHashBytes
I couldn't find anything in the code, so I searched stackoverflow and fout out that I can use otool or strings.
With string I find two "hash" calls (wherever they are) and using nm, I get the following output:
nm Sporty\ Architect | grep hash
0000000100077490 T __TFO16Sporty_Architect12ActivityTypeg9hashValueSi
0000000100056240 T __TFO16Sporty_Architect12RotationModeg9hashValueSi
0000000100064480 T __TFO16Sporty_Architect13DraggedSliderg9hashValueSi
000000010003e3a0 T __TFO16Sporty_Architect8FileTypeg9hashValueSi
000000010003d910 T __TFO16Sporty_Architect9DateRangeg9hashValueSi
0000000100021360 T __TFO16Sporty_Architect9ModelModeg9hashValueSi
U __TFSig9hashValueSi
00000001000777b0 T __TTWO16Sporty_Architect12ActivityTypes8HashableS_FS1_g9hashValueSi
00000001000562e0 T __TTWO16Sporty_Architect12RotationModes8HashableS_FS1_g9hashValueSi
0000000100064500 T __TTWO16Sporty_Architect13DraggedSliders8HashableS_FS1_g9hashValueSi
000000010003e9d0 T __TTWO16Sporty_Architect8FileTypes8HashableS_FS1_g9hashValueSi
000000010003e080 T __TTWO16Sporty_Architect9DateRanges8HashableS_FS1_g9hashValueSi
0000000100021500 T __TTWO16Sporty_Architect9ModelModes8HashableS_FS1_g9hashValueSi
I think the U __TFSig9hashValueSi is it, isn't it? But now the question...how can i narrow this down any further?
It is beyond me, why Apple offers a validate button that shows that everything is OK and once the app is in review, it gets rejected for something, that could clearly be detected at compile time (or at least when it is submitted).
If you don't use any external API or framework, CFHashBytes is present only in Swift framework.
I had this issue with two Apps. I have sent this message to the Resolution Center and now both have been approved:
"Hello,
I think that there is an error. The only file that contains that non-public API is libswiftFoundation.dylib, framework used in Swift Apps. Xcode uses it automatically. Please, check it again.
Many thanks."
I hope this helps you.

Undocumented method to find sim card availability in ios?

I have found an undocumented method for detecting sim card availability in iphone. This method needs CoreTelephony.framework
NSString * CTSIMSupportGetSIMStatus();
int CTGetSignalStrength();
NSString *status = CTSIMSupportGetSIMStatus();
NSLog(#"Sim card status %#",status);
This method works well. can i use this method in my project? If i use this undocumented method, will apple reject my app? plz let me know... Thanks
You can not use undocumented method as Apple says that they can change the implementation for bug fixing or by updating the SDK cause App crash. They do not allow the use of Private API and trace at submission at store. Mostly private method can be found in debugging at Xcode and start with _Underscore so you can try alternative to achieving things if you do not want to get reject your application later at submission.

How to get unique user ID for HockeyApp?

In the HockeyApp SDK v. 3.5, they have shifted to a new method of user identification. In previous versions of the SDK, there was a callback method - (NSString*)userNameForCrashManager:(BITCrashManager *)crashManager which would set a string which would identify all crash reports sent from the client.
However, in version 3.5 of the SDK, it seems that this is deprecated, and it is preferred that you simply call:
[[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation];
This sets a unique ID for the user. But how can I access this identifier? I want to attach it to support emails so that I can search for crash reports the user has submitted.
You can use the following delegate to set the userName:
- (NSString *)userNameForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager
This is documented in the header and help ofBITHockeyManagerDelegate and the replacement is also mentioned in the header and help of BITCrashManagerDelegate documentation.
BITAuthenticator is only used for beta distribution due to the fact that Apple removed the UDID calls from iOS 7. See the documentation and help. It is automatically disabled in App Store builds and without further setup creates anonymous IDs! Please read the mentioned documentation.
I think you are looking for publicInstallationIdentifier. That should return an NSString, unique for each user.
Look at this header file - BITAuthenticator.h .
Also, in the BITHockeyManager, there is a method called configureWithIdentifier: in which you can pass the identifier.

Deprecated methods in iOS

How can I check all the methods that were deprecated since iOS 4.3? Is there a website, that shows or filters all the methods that are deprecated in a give particular iOS?
The best place is to check in Apple Class Reference. Ex. for NSString.
This will be updated by them after every modification, and will be almost accurate and uptodate as compared to all other website, which in turn will get the information from here only.
if ([object respondsToSelector:#selector(methodName)])
{
// do something
}

Would apple allow this this non-public method?

I am using some non-public method to better control the slide effects of my application, for example:
[self dismissModalViewControllerWithTransition:2];
After trying to upload my App with the Application Loader I got the message that I can not use such non-public methods. I found in stackoverflow a nice workaround here: How does Apple know you are using private API?
So, I've adapted my code:
int tvalue = 2;
objc_msgSend(self, sel_getUid("dismissModalViewControllerWithTransition:"), tvalue);
After changing the code, the Application Loader did accept my binary. So here my question: can I get any problems when the App gets revised by apple?
Thanks in advance.
You cannot. Your app was not rejected because Apple could not track properly your code. Skip using non-public methods.

Resources