Support Xcode 6. (breaks pre-Xcode 6) · aixion/instruments-without-delay@1463b94 · GitHub
Skip to content

Commit 1463b94

Browse files
author
Mehdi Mulani
committed
Support Xcode 6. (breaks pre-Xcode 6)
Bunch of work in this change. The main instruments-without-delay hook changed dramatically as Apple now has the Simulator be started by launchd. ScriptAgent is also started by DTMobileIS, which is in turn started by launchd_sim. I removed our dependency on the clang-as-ios-dylib stuff as Xcode 6 now supports dynamic libraries for iOS. Moved the Swizzle code to Common and added a tiny comment about it.
1 parent e4e474c commit 1463b94

148 files changed

Lines changed: 636 additions & 686 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/SwizzleSelector.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// Copyright 2014 Facebook
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import "SwizzleSelector.h"
18+
19+
#import <objc/runtime.h>
20+
#import <objc/message.h>
21+
22+
void SwizzleSelectorForFunction(Class cls, SEL sel, IMP newImp)
23+
{
24+
Method originalMethod = class_getInstanceMethod(cls, sel);
25+
const char *typeEncoding = method_getTypeEncoding(originalMethod);
26+
27+
NSString *newSelectorName = [NSString stringWithFormat:@"__%s_%s", class_getName(cls), sel_getName(sel)];
28+
SEL newSelector = sel_registerName([newSelectorName UTF8String]);
29+
class_addMethod(cls, newSelector, newImp, typeEncoding);
30+
31+
Method newMethod = class_getInstanceMethod(cls, newSelector);
32+
method_exchangeImplementations(originalMethod, newMethod);
33+
}
Lines changed: 285 additions & 0 deletions

0 commit comments

Comments
 (0)