Mac OS是Unix系統(tǒng)的分支蝶押,有著強大的命令行功能。很多事情在命令行下處理會事半功倍膘盖,所以我就iOS程序員可能會用到的功能講述一下衩椒。
終端設(shè)置
Mac的終端有一個很關(guān)鍵的配置,就是“使用 Option 鍵作為 Meta 鍵”惹资。勾上這個選項之后贺纲,就可以使用Emacs的編輯命令了。
我發(fā)現(xiàn)有些人的終端沒有設(shè)置“平滑文本”褪测,導(dǎo)致終端上的文字很難看猴誊。趕緊把這個選項勾上吧。
常用的幾個快捷鍵如下侮措。
- control+a稠肘,跳到命令行開始位置;control+e萝毛,跳到命令行結(jié)尾位置项阴。
- option+f,向前跳一個word笆包;option+b环揽,向后跳一個word。
- option+d庵佣,向后刪除一個word歉胶;option+delete,向前刪除一個word巴粪。
- control+_通今,撤銷之前一次編輯操作。
- control+k肛根,刪除到行尾辫塌;control+u,刪除到行首派哲。
終端顏色高亮也不錯臼氨,看起來感覺會更有感覺。比如ls可以看到目錄會是藍(lán)色的芭届,普通文件是白色的储矩,可執(zhí)行程序會是綠色的感耙。
具體設(shè)置可以參考:讓Mac OS X的終端多姿多彩。
homebrew
homebrew是一個非常有用包管理工具持隧,通過homebrew可以安裝更多有用的unix工具即硼,比如wget、tree等等屡拨。
安裝
目前最好的安裝方式都是下面這樣的只酥,一句命令搞定。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
使用
[~]$ brew install tree
==> Downloading http://mama.indstate.edu/users/ice/tree/src/tree-1.7.0.tgz
Already downloaded: /Library/Caches/Homebrew/tree-1.7.0.tgz
==> make prefix=/usr/local/Cellar/tree/1.7.0 MANDIR=/usr/local/Cellar/tree/1.7.0/share/man/man1 CC=clang CFLAGS=-fomit-frame-pointer LD
/usr/local/Cellar/tree/1.7.0: 7 files, 128K, built in 2 seconds
tree這個工具看目錄的內(nèi)容非常直觀好看洁仗。
[~/ilaiwang/LWShareTo]$ tree
.
├── LWShareTo
│ ├── LWShareContent.h
│ ├── LWShareContent.m
│ ├── LWShareTo-Prefix.pch
│ ├── LWShareTo.h
│ ├── LWShareTo.m
│ ├── LWShareToMacro.h
│ ├── LWShareToUtils.h
│ ├── LWShareToUtils.m
│ ├── ShareModule
│ │ ├── LWShareChannelService.h
│ │ ├── LWShareChannelService.m
│ │ ├── LWShareToBaseClass.h
│ │ ├── LWShareToBaseClass.m
│ │ ├── LWShareToClipboard.h
│ │ ├── LWShareToClipboard.m
│ │ ├── LWShareToDouban.h
│ │ ├── LWShareToDouban.m
│ │ ├── LWShareToInside.h
│ │ ├── LWShareToInside.m
│ │ ├── LWShareToLWFeed.h
│ │ ├── LWShareToLWFeed.m
│ │ ├── LWShareToLWSession.h
│ │ ├── LWShareToLWSession.m
│ │ ├── LWShareToOutside.h
│ │ ├── LWShareToOutside.m
│ │ ├── LWShareToQQSession.h
│ │ ├── LWShareToQQSession.m
│ │ ├── LWShareToQQZone.h
│ │ ├── LWShareToQQZone.m
│ │ ├── LWShareToRenren.h
│ │ ├── LWShareToRenren.m
│ │ ├── LWShareToSinaWeibo.h
│ │ ├── LWShareToSinaWeibo.m
│ │ ├── LWShareToTencentWeibo.h
│ │ ├── LWShareToTencentWeibo.m
│ │ ├── LWShareToWechatSession.h
│ │ ├── LWShareToWechatSession.m
│ │ ├── LWShareToWechatTimeline.h
│ │ └── LWShareToWechatTimeline.m
│ ├── WebviewRender.h
│ └── WebviewRender.m
├── LWShareTo.xcodeproj
│ └── project.pbxproj
└── LWShareToTests
├── LWShareToTests-Info.plist
├── LWShareToTests.m
└── en.lproj
└── InfoPlist.strings
5 directories, 44 files
shell
GNU Coreutils包含了各種GNU好用的工具层皱。根據(jù)我的觀察性锭,我發(fā)現(xiàn)Mac預(yù)裝了Coreutils赠潦,只是版本比較低,建議自己安裝一下草冈,否者sort連"-h"參數(shù)都沒有她奥。具體安裝和配置的方法在讓Mac OS X的終端多姿多彩這篇文章里面也有。
Xcode圖形化操作挺好用的怎棱,不過知道一些命令行的操作會更佳哩俭。在下面這個地方看到Xcode編譯的詳細(xì)過程。
如果在編譯的時候遇到鏈接錯誤拳恋,在命令行下檢查一下就非常有必要了凡资。下面這個命令就是鏈接生成來往二進制程序的,可以拷貝到終端里面運行谬运。如果鏈接出錯誤了隙赁,可以仔細(xì)檢查一下這個命令。
Ld /Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Products/Debug-iphoneos/Laiwang.app/Laiwang normal arm64
cd /Users/henshao/ilaiwang/LaiwangV3
export IPHONEOS_DEPLOYMENT_TARGET=6.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -L/Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Products/Debug-iphoneos -L/Users/henshao/ilaiwang/LaiwangV3/../Pods/LWComponentKits/LWComponentKits/AMAP/liboffset -L/Users/henshao/ilaiwang/LaiwangV3/../Pods/LWXiamiMusic/Output -L/Users/henshao/ilaiwang/LaiwangV3/../Pods/QupaiSDK/libQupaiSDK -L/Users/henshao/ilaiwang/LaiwangV3/../Pods/VoIPSDK/SDK/lib -F/Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Products/Debug-iphoneos -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/AMap3DMap -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/AMapSearch -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/DevicePrint -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/TBSecuritySDK -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/SecurityGuardSDK -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/UserTrack -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/PLCrashReporter/iOS\ Framework -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/MtopSDK -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/SpeechRecognizer -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/TBScanLib -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/TBShortURL -F/Users/henshao/ilaiwang/LaiwangV3 -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/TencentOpenApiSDK/64Bit -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/huoyanSDK_laiwang -F/Users/henshao/ilaiwang/LaiwangV3/../Pods/mtopext -F/Users/henshao/ilaiwang/LaiwangV3/Laiwang/LWUIKits/AlipaySDK_2 -F. -FLaiwang -FLaiwangShare -FLaiwangTests -FLaiwang/BaseFrame -FLaiwang/BaseLogic -FLaiwang/Cache -FLaiwang/DataProvider -FLaiwang/DataSource -FLaiwang/DevTools -FLaiwang/H5_Slider_local -FLaiwang/Init -FLaiwang/Integration -FLaiwang/LWSafeMode -FLaiwang/LWUIKits -FLaiwang/PageViews -FLaiwang/SDK -FLaiwang/Sounds -FLaiwang/TestUtility -FLaiwang/UserControls -FLaiwang/Utils -FLaiwangTests/LWServiceTests -FLaiwangTests/Other -FLaiwang/BaseFrame/LWController -FLaiwang/BaseFrame/LWUISDK -FLaiwang/BaseFrame/URLCoordinator -FLaiwang/Cache/LWDataCache -FLaiwang/Cache/LWDB -FLaiwang/Cache/LWDBModel -FLaiwang/H5_Slider_local/app.slide -FLaiwang/Integration/LWService -FLaiwang/Integration/LWServiceTests -FLaiwang/LWUIKits/AlipaySDK_2 -FLaiwang/LWUIKits/LWAlbumPhotoPreview -FLaiwang/LWUIKits/LWCameraCaptureView -FLaiwang/LWUIKits/LWMovieView -FLaiwang/LWUIKits/MMDrawerController -FLaiwang/LWUIKits/TableViewCell -FLaiwang/PageViews/AlbumPage -FLaiwang/PageViews/ChatPage -FLaiwang/PageViews/DiscoveryExPage -FLaiwang/PageViews/EmotionBoxPage -FLaiwang/PageViews/EventPage -FLaiwang/PageViews/FeedPage -FLaiwang/PageViews/FriendPage -FLaiwang/PageViews/FriendRadarPage -FLaiwang/PageViews/IntroducePage -FLaiwang/PageViews/KnockPage -FLaiwang/PageViews/LoginPage -FLaiwang/PageViews/MinePage -FLaiwang/PageViews/MorePage -FLaiwang/PageViews/MoviePage -FLaiwang/PageViews/MusicPage -FLaiwang/PageViews/NearByPage -FLaiwang/PageViews/NewGuidePage -FLaiwang/PageViews/NotificationPage -FLaiwang/PageViews/OAuthPage -FLaiwang/PageViews/PhotoEditorPage -FLaiwang/PageViews/PhotoFilterPage -FLaiwang/PageViews/PostPage -FLaiwang/PageViews/PubAccountPage -FLaiwang/PageViews/SearchPage -FLaiwang/PageViews/SharedPage -FLaiwang/PageViews/ShareMsgPage -FLaiwang/PageViews/XiamiPage -FLaiwang/SDK/EggShell -FLaiwang/SDK/InternalSDK -FLaiwang/SDK/LWFileUploadManager -FLaiwang/SDK/LWHostService -FLaiwang/SDK/LWShareTo -FLaiwang/SDK/SSOApiEngine -FLaiwang/SDK/ViewModels -FLaiwang/SDK/VOIP -FLaiwang/Sounds/asr -FLaiwang/Sounds/radar -FLaiwang/TestUtility/APNSTest -FLaiwang/TestUtility/TimeCounter -FLaiwang/UserControls/BigImageControl -FLaiwang/UserControls/LWAsrBoard -FLaiwang/UserControls/LWAvatarView -FLaiwang/UserControls/LWBrowserViewController -FLaiwang/UserControls/LWCloudAudioPlayerBox -FLaiwang/UserControls/LWCustomUI -FLaiwang/UserControls/LWEasyInputView -FLaiwang/UserControls/LWEmotionView -FLaiwang/UserControls/LWLocationDirectionView -FLaiwang/UserControls/LWLocationDisplayView -FLaiwang/UserControls/LWNativeBridgeWebView -FLaiwang/UserControls/LWObjSelectControl -FLaiwang/UserControls/LWPicker -FLaiwang/UserControls/LWPictureViewer -FLaiwang/UserControls/LWProgressView -FLaiwang/UserControls/LWRichTextContentView -FLaiwang/UserControls/LWScrollTabBar -FLaiwang/UserControls/LWSettingsItem -FLaiwang/UserControls/LWTextZoomView -FLaiwang/UserControls/LWToastView -FLaiwang/UserControls/LWVoiceWidget -FLaiwang/UserControls/LWVoipView -FLaiwang/UserControls/LWWebImageView -FLaiwang/UserControls/LWWebViewController -FLaiwang/UserControls/LWXiamiBar -FLaiwang/UserControls/QBImagePicker -FLaiwang/Utils/ABContact -FLaiwang/Utils/ALAssetsLibrary-CustomPhotoAlbum -FLaiwang/Utils/ASR -FLaiwang/Utils/AWActionSheet -FLaiwang/Utils/Category -FLaiwang/Utils/CompatibleUtil -FLaiwang/Utils/GDataXMLNode -FLaiwang/Utils/Huoyan -FLaiwang/Utils/ImageDownloader -FLaiwang/Utils/LWAppURLNavigator -FLaiwang/Utils/LWBizSearch -FLaiwang/Utils/LWDataStore -FLaiwang/Utils/LWFav -FLaiwang/Utils/LWLocalPageURLRouter -FLaiwang/Utils/LWLocationManager -FLaiwang/Utils/LWMusic -FLaiwang/Utils/LWPushDispatcher -FLaiwang/Utils/LWStatistics -FLaiwang/Utils/NSStringAdditions -FLaiwang/Utils/OffLineSendUtil -FLaiwang/Utils/QupaiSDK -FLaiwang/Utils/SDWebImage -FLaiwang/Utils/SoundEffect -FLaiwang/Utils/UIImageAdditions -FLaiwang/Utils/UIImagePickerControllerAdditions -FLaiwang/Utils/UT -FLaiwang/BaseFrame/LWController/LWTabBarController -FLaiwang/H5_Slider_local/app.slide/css -FLaiwang/H5_Slider_local/app.slide/images -FLaiwang/H5_Slider_local/app.slide/js -FLaiwang/Integration/LWService/ios -FLaiwang/Integration/LWServiceTests/LWPackTests -FLaiwang/Integration/LWServiceTests/LWServiceTests -FLaiwang/LWUIKits/AlipaySDK_2/AlipaySDK.bundle -FLaiwang/PageViews/AlbumPage/Cells -FLaiwang/PageViews/AlbumPage/UserControls -FLaiwang/PageViews/ChatPage/BubbleDay -FLaiwang/PageViews/ChatPage/Cells -FLaiwang/PageViews/ChatPage/MessageSender -FLaiwang/PageViews/ChatPage/MomoChat -FLaiwang/PageViews/ChatPage/UserControls -FLaiwang/PageViews/EventPage/EventCommon -FLaiwang/PageViews/EventPage/EventCreate -FLaiwang/PageViews/EventPage/EventDeprecated -FLaiwang/PageViews/EventPage/EventList -FLaiwang/PageViews/EventPage/EventLottery -FLaiwang/PageViews/EventPage/EventMain -FLaiwang/PageViews/EventPage/EventNotification -FLaiwang/PageViews/EventPage/EventPostDetail -FLaiwang/PageViews/EventPage/EventRecent -FLaiwang/PageViews/EventPage/EventRecommend -FLaiwang/PageViews/EventPage/EventSearch -FLaiwang/PageViews/EventPage/EventSetting -FLaiwang/PageViews/EventPage/EventWall -FLaiwang/PageViews/EventPage/EventZan -FLaiwang/PageViews/EventPage/PubEventRecent -FLaiwang/PageViews/FeedPage/Cells -FLaiwang/PageViews/FeedPage/UserControls -FLaiwang/PageViews/FriendPage/Cells -FLaiwang/PageViews/FriendPage/UserControls -FLaiwang/PageViews/FriendRadarPage/PSCollectionView -FLaiwang/PageViews/FriendRadarPage/PulsingHalo -FLaiwang/PageViews/FriendRadarPage/RNBlurModalView -FLaiwang/PageViews/KnockPage/Answer -FLaiwang/PageViews/KnockPage/Browse -FLaiwang/PageViews/KnockPage/KnockList -FLaiwang/PageViews/KnockPage/SetQuestion -FLaiwang/PageViews/KnockPage/Setting -FLaiwang/PageViews/KnockPage/Statistic -FLaiwang/PageViews/KnockPage/UserControls -FLaiwang/PageViews/KnockPage/VoiceCard -FLaiwang/PageViews/MinePage/UserControls -FLaiwang/PageViews/MorePage/Cells -FLaiwang/PageViews/NotificationPage/Cells -FLaiwang/PageViews/NotificationPage/UserControls -FLaiwang/PageViews/PhotoEditorPage/DataProvider -FLaiwang/PageViews/PhotoEditorPage/DBModel -FLaiwang/PageViews/PhotoEditorPage/UserControls -FLaiwang/PageViews/PostPage/cells -FLaiwang/PageViews/PostPage/UserControls -FLaiwang/PageViews/PubAccountPage/Cells -FLaiwang/PageViews/PubAccountPage/PubToolBar -FLaiwang/PageViews/PubAccountPage/UserControls -FLaiwang/PageViews/SearchPage/SearchCell -FLaiwang/PageViews/SearchPage/SearchCellModel -FLaiwang/PageViews/SearchPage/SearchMsgListPage -FLaiwang/PageViews/SharedPage/Cells -FLaiwang/PageViews/SharedPage/UserControls -FLaiwang/PageViews/ShareMsgPage/UserControls -FLaiwang/SDK/InternalSDK/InternalModel -FLaiwang/SDK/InternalSDK/InternalService -FLaiwang/SDK/LWFileUploadManager/LWProgressObserverCenter -FLaiwang/SDK/LWHostService/BizTasks -FLaiwang/SDK/LWHostService/Utils -FLaiwang/SDK/LWShareTo/ShareModule -FLaiwang/SDK/LWShareTo/ShareRes -FLaiwang/SDK/LWShareTo/ShareService -FLaiwang/SDK/ViewModels/Friends -FLaiwang/SDK/ViewModels/Knock -FLaiwang/SDK/ViewModels/Others -FLaiwang/UserControls/LWProgressView/DACircularProgress -FLaiwang/UserControls/QBImagePicker/LWQBImagePicker+External -FLaiwang/Utils/LWFav/core -FLaiwang/Utils/LWFav/Images -FLaiwang/Utils/LWFav/libs -FLaiwang/Utils/LWFav/UI -FLaiwang/Utils/LWMusic/XiamiSDK -FLaiwang/Utils/NSStringAdditions/NSString_HTML -FLaiwang/Utils/UT/SinaWeibo.bundle -FLaiwang/Integration/LWService/ios/lwservice -FLaiwang/PageViews/EventPage/EventCommon/AttachmentView -FLaiwang/PageViews/EventPage/EventCommon/Comment -FLaiwang/PageViews/EventPage/EventSearch/LWBubbleView -FLaiwang/PageViews/EventPage/EventSearch/LWEventSearchCell -FLaiwang/PageViews/EventPage/EventWall/EventSignIn -FLaiwang/PageViews/KnockPage/Browse/KnockFlipTransition -FLaiwang/PageViews/KnockPage/Browse/LWKnockLocationManager -FLaiwang/Utils/LWFav/libs/CDClient -FLaiwang/Utils/LWFav/libs/file_hash -FLaiwang/Utils/LWFav/libs/GHKit -FLaiwang/Utils/LWFav/libs/PopoverView -FLaiwang/Utils/LWFav/UI/views -FLaiwang/Utils/LWMusic/XiamiSDK/Classes -FLaiwang/Utils/UT/SinaWeibo.bundle/images -FLaiwang/Integration/LWService/ios/lwservice/LaiwangRPC -FLaiwang/Utils/LWMusic/XiamiSDK/Classes/Player -F/Users/henshao/ilaiwang/LaiwangV3/Laiwang -filelist /Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Intermediates/Laiwang.build/Debug-iphoneos/Laiwang.build/Objects-normal/arm64/Laiwang.LinkFileList -dead_strip -ObjC -lCNG -lG711 -lG729 -lPods-AMap3DMap -lPods-AMapSearch -lPods-CocoaAsyncSocket -lPods-DevicePrint -lPods-FLEX -lPods-HTTPDNS -lPods-JDStatusBarNotification -lPods-JSONKit -lPods-LWComponentKits -lPods-LWGPUImage -lPods-LWGraffiti -lPods-LWHttpDNSInterceptor -lPods-LWImageAssets -lPods-LWImageFilter -lPods-LWJSONKit -lPods-LWNetworkKit -lPods-LWPlugin -lPods-LWShareKit -lPods-LWXiamiMusic -lPods-MJRefresh -lPods-MtopSDK -lPods-NJKWebViewProgress -lPods-OpenUDID -lPods-PLCrashReporter -lPods-PSTCollectionView -lPods-QupaiSDK -lPods-Reachability -lPods-RegexKitLite -lPods-SDWebImage -lPods-SecurityGuardSDK -lPods-SpeechRecognizer -lPods-TBMstore -lPods-TBScanLib -lPods-TBSecuritySDK -lPods-TBShortURL -lPods-THLabel -lPods-TencentOpenApiSDK -lPods-UserTrack -lPods-VoIPSDK -lPods-ZipArchive -lPods-crossplay -lPods-huoyanSDK_laiwang -lPods-libextobjc -lPods-libwebp -lPods-lwsdk -lPods-mtopext -lQupaiSDK -laudio_coding_module -laudio_conference_mixer -laudio_decoder_interface -laudio_device -laudio_encoder_interface -laudio_processing -lavcodec -lavformat -lavutil -lbitrate_controller -lc++ -lcommon_audio -lcommon_video -lfield_trial_default -liSAC -liSACFix -licucore -lmedia_file -lmetrics_default -lneteq -loffset -lopus -lpaced_sender -lrbe_components -lred -lremote_bitrate_estimator -lrtc_base_approved -lrtc_sound -lrtp_rtcp -lsqlite3 -lsrtp -lstdc++ -lstdc++.6.0.9 -lswscale -lsystem_wrappers -ltbconf -lvideo_coding_utility -lvideo_engine_core -lvideo_processing -lvideo_render_module -lvideo_render_module_impl -lvideo_render_module_internal_impl -lvoice_engine -lwebrtc -lwebrtc_common -lwebrtc_h264 -lwebrtc_i420 -lwebrtc_opus -lwebrtc_utility -lwebrtc_video_coding -lx264 -lxiamiMusic -lxml2 -lyuv -lyuv_neon -lz -framework AMapSearchKit -framework AVFoundation -framework AudioToolbox -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreLocation -framework CoreMedia -framework CoreTelephony -framework CoreText -framework CrashReporter -framework DevicePrint -framework Foundation -framework GLKit -framework ImageIO -framework MAMapKit -framework MobileCoreServices -framework MtopSDK -framework OpenGLES -framework QuartzCore -framework Security -framework SecurityGuardSDK -framework SpeechRecognizer -framework SystemConfiguration -framework TBScanLib -framework TBSecuritySDK -framework TBShortURLResolve -framework TencentOpenAPI -framework UIKit -framework UT -framework huoyan -framework mtopext -weak_framework AdSupport -lstdc++ -ObjC -fobjc-arc -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.0 -framework LocalAuthentication -framework GameKit -framework AddressBookUI -framework Accelerate -lstdc++.6.0.9 -lxml2 -framework MediaPlayer -framework GLKit -lz -framework SystemConfiguration -framework CoreTelephony -framework Security -framework MessageUI -framework AudioToolbox -framework MobileCoreServices -framework ImageIO -framework QuartzCore -lsqlite3 -lz.1.2.5 -lresolv -liconv -framework AlipaySDK -licucore -framework OpenGLES -framework MapKit -framework CFNetwork -framework AddressBook -framework AssetsLibrary -framework AVFoundation -framework CoreAudio -framework CoreData -framework ShareSDK -framework CoreLocation -framework CoreMedia -framework CoreVideo -framework CoreGraphics -framework UIKit -framework Foundation -lPods -Xlinker -dependency_info -Xlinker /Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Intermediates/Laiwang.build/Debug-iphoneos/Laiwang.build/Objects-normal/arm64/Laiwang_dependency_info.dat -o /Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Products/Debug-iphoneos/Laiwang.app/Laiwang
常用的工具如下廷臼。
- find峻厚,查找文件驶鹉。比如我想分析一下來往源代碼各個部分的文件數(shù)量『裰溃可以發(fā)現(xiàn)業(yè)務(wù)里面文件數(shù)量最多的三個業(yè)務(wù)分別是扎堆、敲門和聊天级解。
[~/ilaiwang/LaiwangV3/Laiwang/PageViews]$ find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo $(find {} -type f | wc -l) {}' | sort -nr
914 .
167 ./EventPage
92 ./ChatPage
91 ./KnockPage
88 ./FriendPage
86 ./PubAccountPage
54 ./FeedPage
47 ./SharedPage
44 ./PostPage
29 ./SearchPage
29 ./PhotoEditorPage
29 ./MorePage
28 ./NearByPage
26 ./FriendRadarPage
15 ./LoginPage
14 ./MinePage
14 ./AlbumPage
12 ./PhotoFilterPage
10 ./EmotionBoxPage
9 ./ShareMsgPage
8 ./XiamiPage
8 ./NotificationPage
4 ./IntroducePage
2 ./OAuthPage
2 ./NewGuidePage
2 ./MusicPage
2 ./MoviePage
2 ./DiscoveryExPage
grep冒黑,搜索文本。結(jié)合正則表達式勤哗,分析日志什么的薛闪,非常之強大。grep有幾個有用的選項俺陋,分別是“-r”遞歸搜索目錄豁延;“-i”昙篙,忽略大小寫;“-c”诱咏,統(tǒng)計符合搜索條件的文本的行數(shù)苔可;“--color”,高亮搜索結(jié)果袋狞。
du焚辅,統(tǒng)計目錄大小。比如我想知道來往圖片資源的情況苟鸯⊥撸可以看出圖片資源一共有8.2MB,其中共享的圖片占到2.1MB早处,其次是聊天的圖片占了1.4MB湾蔓。
[~/iOS_release/lwimageassets]$ du -sh LWImageAssets
8.2M LWImageAssets
[~/iOS_release/lwimageassets/LWImageAssets]$ du -sh * | sort -hr
2.1M shared_img
1.4M chat_img
636K event_img
528K icon_default
524K feed_img
472K post_img
464K knock_img
392K radar_img
284K profile_img
264K friend_img
236K pub_account_map_img
140K editor_img
132K yifa_img
132K emotion_img
84K neighbour_img
80K lwuikits_img
76K discovery_img
72K graffiti_img
72K asr_img
60K login_img
52K video_guide_img
44K qr_img
40K more_img
36K share_msg_img
32K my_img
20K slide_img
16K animal_img
12K xiamibar_img
4.0K search_img
4.0K movie_img
- file,用于查看文件信息砌梆。
$ file libxiamiMusic.a
libxiamiMusic.a: Mach-O universal binary with 4 architectures
libxiamiMusic.a (for architecture armv7): current ar archive random library
libxiamiMusic.a (for architecture i386): current ar archive random library
libxiamiMusic.a (for architecture x86_64): current ar archive random library
libxiamiMusic.a (for architecture arm64): current ar archive random library
$ file Laiwang
Laiwang: Mach-O 64-bit executable
- strings默责,查看文件中的文本信息。
$ strings Laiwang | head -n 10
kSearchTextKey
kSearchedPersonKey
invalid_token
user_in_black_list
user_blocked
expired_token
invalid_grant
refreshed_token
client_id
client_secret
- nm咸包,查看可執(zhí)行程序里面的符號信息桃序。
$ nm Laiwang | head -n 10
00000001001425e4 t +[ABContact addressWithStreet:withCity:withState:withZip:withCountry:withCode:]
0000000100142484 t +[ABContact arrayForProperty:inRecord:]
0000000100146438 t +[ABContact contactWithData:]
000000010014591c t +[ABContact contactWithDictionary:]
000000010014191c t +[ABContact contactWithRecord:]
0000000100141984 t +[ABContact contactWithRecordID:]
0000000100141b70 t +[ABContact contact]
000000010014252c t +[ABContact dictionaryWithValue:andLabel:]
0000000100141c50 t +[ABContact localizedPropertyName:]
00000001001424e8 t +[ABContact objectForProperty:inRecord:]
- otool,查看查看可執(zhí)行程序的信息烂瘫。比如查看可執(zhí)行程序依賴的動態(tài)庫信息媒熊。
[~]$ otool -L /Users/henshao/Library/Developer/Xcode/DerivedData/CloudConsoleApp-gszptqenpqtwraajgpawanvtjtny/Build/Products/Debug-iphonesimulator/CloudConsoleApp.app/CloudConsoleApp
/Users/henshao/Library/Developer/Xcode/DerivedData/CloudConsoleApp-gszptqenpqtwraajgpawanvtjtny/Build/Products/Debug-iphonesimulator/CloudConsoleApp.app/CloudConsoleApp:
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 237.2.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 55.1.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 216.7.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
@rpath/AFNetworking.framework/AFNetworking (compatibility version 1.0.0, current version 1.0.0)
@rpath/ALYUIKit.framework/ALYUIKit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AVFoundation.framework/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/AVKit.framework/AVKit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Accounts.framework/Accounts (compatibility version 1.0.0, current version 0.0.0)
/System/Library/Frameworks/AddressBook.framework/AddressBook (compatibility version 1.0.0, current version 30.0.0)
/System/Library/Frameworks/AddressBookUI.framework/AddressBookUI (compatibility version 1.0.0, current version 33.0.0)
- lsof,觀察描述符的信息坟比。比如觀察系統(tǒng)中https的連接情況芦鳍。
[~]$ lsof -i:443
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
AliLang 910 henshao 9u IPv4 0x3db3574b61c3c44b 0t0 TCP 10.65.155.189:55448->42.156.140.98:https (ESTABLISHED)
AliLang 910 henshao 11u IPv4 0x3db3574b61c3c44b 0t0 TCP 10.65.155.189:55448->42.156.140.98:https (ESTABLISHED)
AliLang 910 henshao 26u IPv4 0x3db3574b61a3225b 0t0 TCP 10.65.155.189:52167->140.205.224.47:https (ESTABLISHED)
AliLang 910 henshao 31u IPv4 0x3db3574b61a3225b 0t0 TCP 10.65.155.189:52167->140.205.224.47:https (ESTABLISHED)
node 33986 henshao 32u IPv4 0x3db3574b602f525b 0t0 TCP 30.9.158.49:53822->ec2-54-235-138-91.compute-1.amazonaws.com:https (ESTABLISHED)
nwjs 77209 henshao 129u IPv4 0x3db3574b6360d06b 0t0 TCP 10.65.155.189:54516->140.205.32.75:https (ESTABLISHED)
^C
[~]$ ps aux | grep 910
henshao 910 0.0 0.2 2728464 20204 ?? S 1 716 10:55.29 /Applications/AliLang.app/Contents/MacOS/AliLang
- Swift符號demangle
$ xcrun swift-demangle __TFFC15CloudConsoleApp31ALYDomainNewOwnerViewController7confirmFPs9AnyObject_T_U_FGSQGVs10DictionaryCSo8NSObjectPS1____T_
_TFFC15CloudConsoleApp31ALYDomainNewOwnerViewController7confirmFPs9AnyObject_T_U_FGSQGVs10DictionaryCSo8NSObjectPS1____T_ ---> CloudConsoleApp.ALYDomainNewOwnerViewController.(confirm (Swift.AnyObject) -> ()).(closure #1)
vim
做簡單的文本編輯和分析,vim是非常方便的温算。最簡單有用的配置如下怜校。在HOME目錄下創(chuàng)建.vimrc隱藏文件,把下面的內(nèi)容拷貝進去即可注竿。
syntax on #支持語法高亮茄茁,看源代碼文件會很舒服。
set hls #使用 / 查找內(nèi)容的時候巩割,會高亮字符串裙顽。
set ic #搜索的時候忽略大小寫
CocoaPods
CocoaPods的源都安裝在"~/.cocoapods/repos"目錄下,有時候找不到pod宣谈、版本有問題愈犹、或者想確定一下pod的信息,都可以來這個地方翻一翻。
[~/.cocoapods/repos]$ ls
TBMainClientSpecs/ alibaba/ master/
[~/.cocoapods/repos]$ ls TBMainClientSpecs/
AMPSDK/ TBCalendar/ TBLoginCenter/ TBScanCode/ TBWeiTao/
AccsSDK/ TBCalendarService/ TBLoginService/ TBScanCodeService/ TBWeiTaoService/
[~]$ pod search swiftyjson
-> AISwiftyJSON (1.0.6)
AISwiftyJSON makes it easy to deal with JSON data in Swift .
pod 'AISwiftyJSON', '~> 1.0.6'
- Homepage: https://github.com/asiainfomobile/AISwiftyJSON
- Source: git@mirror.git.alibaba-inc.com:asiainfomobile/AISwiftyJSON.git
- Versions: 1.0.6, 1.0.3 [master repo]
-> SwiftyJSON (2.3.2)
SwiftyJSON makes it easy to deal with JSON data in Swift
pod 'SwiftyJSON', '~> 2.3.2'
- Homepage: https://github.com/SwiftyJSON/SwiftyJSON
- Source: git@mirror.git.alibaba-inc.com:SwiftyJSON/SwiftyJSON.git
- Versions: 2.3.2, 2.3.1, 2.3.0, 2.2.1, 2.2.0, 2.1.3 [master repo]
為了方便執(zhí)行pod update --verbose
漩怎,可以設(shè)置一個別名勋颖,比如pu
,這樣可以快得飛起勋锤。
$ echo "alias pu='pod update --verbose'" >> ~/.bash_profile && . ~/.bash_profile
$ pu
sqlite
Mac自帶了sqlite命令行工具饭玲。小工具用起來很快很方便。所以簡單介紹一下怎么使用這個工具叁执。其實".help"講得很詳細(xì)啦茄厘。
[~/Downloads]$ sqlite3 laiwang.sqlite3
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
lw_messages lw_session_event_post
lw_offline_post2 lw_sessions
sqlite> .schema lw_sessions
CREATE TABLE lw_sessions (primaryKey INTEGER primary key autoincrement, sessionId TEXT, userId TEXT, title TEXT, icon TEXT, content TEXT, sourceType TEXT, data BLOB, actionType TEXT, actionContent TEXT, senderId TEXT, settings BLOB, unreadCount INTEGER, pushEnnabled INTEGER, lastModify TEXT, ancientStampInDB TEXT, recentStampInDB TEXT, sortIndex INTEGER, background TEXT, members BLOB);
CREATE UNIQUE INDEX idx_sessions_SidUidSt ON lw_sessions(sessionId, userId, sourceType);
CREATE INDEX idx_sessions_UidStSiLm ON lw_sessions(userId, sourceType, sortIndex, lastModify);
sqlite> select * from lw_sessions limit 1;
1|2651304|2921438|新浪新聞|http://i01.lw.aliimg.com/tfs/T1vldnFFXbXXbKnNzJLAIWANGtebus_73957a0c_180_180.60x60.jpg||pubmessage|||{"type":""}|||0|0|1429026489000|||0||
Python
Python有很多好用的模塊,做一些事情非常便利谈宛。
SimpleHTTPServer
SimpleHTTPServer模塊絕對是Python最有用的一個模塊(另外一個可能是json)次哈。一個命令就能啟動一個Web服務(wù)器,做演示或者mock接口吆录,不要太方便了窑滞。
$ python -m SimpleHTTPServer 9876
Serving HTTP on 0.0.0.0 port 9876 ...
JSON格式化
使用json.tool
模塊格式化JSON字符串很方便。
$ python -m json.tool < /tmp/1 <java:10>
{
"address": {
"city": "Nara",
"postalCode": "630-0192",
"streetAddress": "naist street"
},
"age": 26,
"firstName": "John",
"lastName": "doe",
"phoneNumbers": [
{
"number": "0123-4567-8888",
"type": "iPhone"
},
{
"number": "0123-4567-8910",
"type": "home"
}
]
}
nomad houston
nomad houston這個工具支持在命令行下給APP推送信息径筏,感覺蠻不錯的葛假。詳細(xì)介紹請看:使用Houston給iOS APP推送信息障陶。