2018年11月19日 10:08:47 蜗牛非牛 阅读数:149

最近在研究RunLoop运行机制,想看看他的底层代码是什么样子的,因而百度看看你们如何操做的。最终绝望的发现基本的操做都同样,然并卵。css
-
zhangquaniMac:3456 zq$ cd /Users/zq/Desktop/3456/3456
-
zhangquaniMac:3456 zq$ clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ViewController.m
显示异常以下:c++
-
clang: warning: using sysroot
for 'iPhoneSimulator' but targeting 'MacOSX' [-Wincompatible-sysroot]
-
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the
-
command line to use the libc++ standard library instead
-
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:12856:188: warning:
-
'kCFCalendarUnitWeek' is deprecated: first deprecated in macOS 10.10 - Use
-
kCFCalendarUnitWeekOfYear or kCFCalendarUnitWeekOfMonth instead
-
[-Wdeprecated-declarations]
-
...or NSCalendarUnitWeekOfYear, depending on which you mean"))) = kCFCalend...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:5156:2: note:
-
'kCFCalendarUnitWeek' has been explicitly marked deprecated here
-
kCFCalendarUnitWeek __attribute__((availability(macos,introduced=10.4,d...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22487:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable sec_trust_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22493:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable sec_identity_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22496:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable sec_identity_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22505:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable sec_certificate_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22521:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable dispatch_data_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22555:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable dispatch_data_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:22559:16: warning:
-
'ns_returns_retained' attribute only applies to functions that return an
-
Objective-C object [-Wignored-attributes]
-
__attribute__((__ns_returns_retained__)) _Nullable dispatch_data_t
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:50310:13: warning:
-
'CADisplayLink' is only available on macOS 10.14 or newer
-
[-Wunguarded-availability-new]
-
- (nullable CADisplayLink *)displayLinkWithTarget:(id)target selector:(S...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:33690:12: note:
-
'CADisplayLink' has been explicitly marked partial here
-
@interface CADisplayLink : NSObject
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:50310:1: note:
-
annotate 'displayLinkWithTarget:selector:' with an availability attribute
-
-
- (nullable CADisplayLink *)displayLinkWithTarget:(id)target selector:(S...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52754:18: error:
-
'UIWebView' is unavailable: not available on macOS
-
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRe...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52702:281: note:
-
'UIWebView' has been explicitly marked unavailable here
-
...__attribute__((availability(macos,unavailable))) @interface UIWebView : ...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52755:30: error:
-
'UIWebView' is unavailable: not available on macOS
-
- (void)webViewDidStartLoad:(UIWebView *)webView __attribute__((availabi...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52702:281: note:
-
'UIWebView' has been explicitly marked unavailable here
-
...__attribute__((availability(macos,unavailable))) @interface UIWebView : ...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52756:31: error:
-
'UIWebView' is unavailable: not available on macOS
-
- (void)webViewDidFinishLoad:(UIWebView *)webView __attribute__((availab...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52702:281: note:
-
'UIWebView' has been explicitly marked unavailable here
-
...__attribute__((availability(macos,unavailable))) @interface UIWebView : ...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52757:18: error:
-
'UIWebView' is unavailable: not available on macOS
-
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)err...
-
-
/var/folders/qc/wbfmgr1x6f9246c0jt6yqt100000gn/T/ViewController-4ce726.mi:52702:281: note:
-
'UIWebView' has been explicitly marked unavailable here
-
...__attribute__((availability(macos,unavailable))) @interface UIWebView : ...
-
-
9 warnings and 4 errors generated.
试了屡次,发现仍是报一样的错误,因而只能继续耐心的看看还有没有不一样的操做,最终获得了一个完美的操做:web
-
zhangquaniMac:~ zq$ cd /Users/zq/Desktop/
3456/3456
-
zhangquaniMac:
3456 zq$ xcrun -sdk iphonesimulator clang -rewrite-objc ViewController.m
转换成功objective-c

补充一下
指定真机macos
xcrun -sdk iphoneos clang -rewrite-objc ViewController.m
指定模拟器app
xcrun -sdk iphonesimulator clang -rewrite-objc ViewController.m
指定SDK版本iphone
xcrun -sdk iphonesimulator10.3 clang -rewrite-objc ViewController.m
Ç语言转C ++ide
-
zhangquaniMac:~ zq$ cd /Users/zq/Desktop/Test/Test
-
zhangquaniMac:Test zq$ clang -rewrite-objc main.c
参考:HTTPS://cotin.tech/iOS/clang-rewrite-objc/oop
Tui