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