私が構築した3つのフレームワークを含むテストアプリケーション(私はバグをテストするために何もしません)を持っています。フレームワークは、ファイルのコピーフェーズを使用してアプリケーションのFrameworksディレクトリにコピーされます。フレームワークディレクトリからのフレームワークとそれぞれに含まれるクラスの数を出力しますiOS:objc_copyClassNamesForImageがデバイス上で動作しません
#import "AppDelegate.h"
@import ObjectiveC;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[NSBundle allFrameworks] enumerateObjectsUsingBlock:^(NSBundle *framework, NSUInteger idx, BOOL *stop) {
unsigned int count = 0;
__unused const char** classes = objc_copyClassNamesForImage([[framework executablePath] UTF8String], &count);
NSRange inFramework = [framework.executablePath rangeOfString:@".app/Frameworks"];
if (inFramework.length > 0) {
NSLog(@"Framework %@, classes: %i", framework.executablePath.lastPathComponent, count);
}
}];
return YES;
}
@end
:私は、次のアプリデリゲートのコードを持っています。
私は次のような結果を得るシミュレータでこのコードを実行すると:
2016-11-04 12:02:17.682 RuntimeTest[54326:623229] Framework PEGKit, classes: 24
2016-11-04 12:02:17.705 RuntimeTest[54326:623229] Framework Alchemic, classes: 57
2016-11-04 12:02:17.707 RuntimeTest[54326:623229] Framework StoryTeller, classes: 10
を、私は私が得るデバイス上でそれを実行したときにしかし:
2016-11-04 12:07:04.215417 RuntimeTest[1035:365233] Framework PEGKit, classes: 0
2016-11-04 12:07:04.224495 RuntimeTest[1035:365233] Framework Alchemic, classes: 0
2016-11-04 12:07:04.254946 RuntimeTest[1035:365233] Framework StoryTeller, classes: 0
デバイスが持つiPhone 7でありますiOS 10.1。私はこのコードが過去に働いていたと確信していて、それはobjc_copyClassNamesForImage
が何とか壊れているようです。
私の実際の理論では、これは10.1バグである可能性があります。または、ビルドプロパティで設定されているか、設定されていないものです。
誰でもこれを確認できますか?何が間違っているかも考えていますか?