当前位置:   article > 正文

写给iOS程序员的命令行使用秘籍

securityguardopenlite

Mac OS是Unix系统的分支,有着强大的命令行功能。很多事情在命令行下处理会事半功倍,所以我就iOS程序员可能会用到的功能讲述一下。

终端设置

Mac的终端有一个很关键的配置,就是“使用 Option 键作为 Meta 键”。勾上这个选项之后,就可以使用Emacs的编辑命令了。

我发现有些人的终端没有设置“平滑文本”,导致终端上的文字很难看。赶紧把这个选项勾上吧。

常用的几个快捷键如下。

  1. control+a,跳到命令行开始位置;control+e,跳到命令行结尾位置。

  2. option+f,向后跳一个word;option+b,向前跳一个word。

  3. option+d,向后删除一个word;option+delete,向前删除一个word。

  4. control+_,撤销之前一次编辑操作。

  5. control+k,删除到行尾;control+u,删除到行首。

终端颜色高亮也不错,看起来感觉会更有感觉。比如ls可以看到目录会是蓝色的,普通文件是白色的,可执行程序会是绿色的。

具体设置可以参考:让Mac OS X的终端多姿多彩

homebrew

homebrew是一个非常有用包管理工具,通过homebrew可以安装更多有用的unix工具,比如wget、tree等等。

安装

目前最好的安装方式都是下面这样的,一句命令搞定。

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

使用

  1. [~]$ brew install tree
  2. ==> Downloading http://mama.indstate.edu/users/ice/tree/src/tree-1.7.0.tgz
  3. Already downloaded: /Library/Caches/Homebrew/tree-1.7.0.tgz
  4. ==> 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
  5. /usr/local/Cellar/tree/1.7.07 files, 128K, built in 2 seconds

tree这个工具看目录的内容非常直观好看。

  1. [~/ilaiwang/LWShareTo]$ tree
  2. .
  3. ├── LWShareTo
  4. │   ├── LWShareContent.h
  5. │   ├── LWShareContent.m
  6. │   ├── LWShareTo-Prefix.pch
  7. │   ├── LWShareTo.h
  8. │   ├── LWShareTo.m
  9. │   ├── LWShareToMacro.h
  10. │   ├── LWShareToUtils.h
  11. │   ├── LWShareToUtils.m
  12. │   ├── ShareModule
  13. │   │   ├── LWShareChannelService.h
  14. │   │   ├── LWShareChannelService.m
  15. │   │   ├── LWShareToBaseClass.h
  16. │   │   ├── LWShareToBaseClass.m
  17. │   │   ├── LWShareToClipboard.h
  18. │   │   ├── LWShareToClipboard.m
  19. │   │   ├── LWShareToDouban.h
  20. │   │   ├── LWShareToDouban.m
  21. │   │   ├── LWShareToInside.h
  22. │   │   ├── LWShareToInside.m
  23. │   │   ├── LWShareToLWFeed.h
  24. │   │   ├── LWShareToLWFeed.m
  25. │   │   ├── LWShareToLWSession.h
  26. │   │   ├── LWShareToLWSession.m
  27. │   │   ├── LWShareToOutside.h
  28. │   │   ├── LWShareToOutside.m
  29. │   │   ├── LWShareToQQSession.h
  30. │   │   ├── LWShareToQQSession.m
  31. │   │   ├── LWShareToQQZone.h
  32. │   │   ├── LWShareToQQZone.m
  33. │   │   ├── LWShareToRenren.h
  34. │   │   ├── LWShareToRenren.m
  35. │   │   ├── LWShareToSinaWeibo.h
  36. │   │   ├── LWShareToSinaWeibo.m
  37. │   │   ├── LWShareToTencentWeibo.h
  38. │   │   ├── LWShareToTencentWeibo.m
  39. │   │   ├── LWShareToWechatSession.h
  40. │   │   ├── LWShareToWechatSession.m
  41. │   │   ├── LWShareToWechatTimeline.h
  42. │   │   └── LWShareToWechatTimeline.m
  43. │   ├── WebviewRender.h
  44. │   └── WebviewRender.m
  45. ├── LWShareTo.xcodeproj
  46. │   └── project.pbxproj
  47. └── LWShareToTests
  48.     ├── LWShareToTests-Info.plist
  49.     ├── LWShareToTests.m
  50.     └── en.lproj
  51.         └── InfoPlist.strings
  52. 5 directories, 44 files

shell

GNU Coreutils包含了各种GNU好用的工具。根据我的观察,我发现Mac预装了Coreutils,只是版本比较低,建议自己安装一下,否者sort连”-h”参数都没有。具体安装和配置的方法在让Mac OS X的终端多姿多彩这篇文章里面也有。

Xcode图形化操作挺好用的,不过知道一些命令行的操作会更佳。在下面这个地方看到Xcode编译的详细过程。

如果在编译的时候遇到链接错误,在命令行下检查一下就非常有必要了。下面这个命令就是链接生成来往二进制程序的,可以拷贝到终端里面运行。如果链接出错误了,可以仔细检查一下这个命令。

  1. Ld /Users/henshao/Library/Developer/Xcode/DerivedData/Laiwang-fxscnxkslrypubbeazdfkveysldy/Build/Products/Debug-iphoneos/Laiwang.app/Laiwang normal arm64
  2.     cd /Users/henshao/ilaiwang/LaiwangV3
  3.     export IPHONEOS_DEPLOYMENT_TARGET=6.0
  4.     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"
  5.     /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,查找文件。比如我想分析一下来往源代码各个部分的文件数量。可以发现业务里面文件数量最多的三个业务分别是扎堆、敲门和聊天。

  1. [~/ilaiwang/LaiwangV3/Laiwang/PageViews]$ find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo $(find {} -type f | wc -l) {}' | sort -nr
  2. 914 .
  3. 167 ./EventPage
  4. 92 ./ChatPage
  5. 91 ./KnockPage
  6. 88 ./FriendPage
  7. 86 ./PubAccountPage
  8. 54 ./FeedPage
  9. 47 ./SharedPage
  10. 44 ./PostPage
  11. 29 ./SearchPage
  12. 29 ./PhotoEditorPage
  13. 29 ./MorePage
  14. 28 ./NearByPage
  15. 26 ./FriendRadarPage
  16. 15 ./LoginPage
  17. 14 ./MinePage
  18. 14 ./AlbumPage
  19. 12 ./PhotoFilterPage
  20. 10 ./EmotionBoxPage
  21. 9 ./ShareMsgPage
  22. 8 ./XiamiPage
  23. 8 ./NotificationPage
  24. 4 ./IntroducePage
  25. 2 ./OAuthPage
  26. 2 ./NewGuidePage
  27. 2 ./MusicPage
  28. 2 ./MoviePage
  29. 2 ./DiscoveryExPage

grep,搜索文本。结合正则表达式,分析日志什么的,非常之强大。grep有几个有用的选项,分别是“-r”递归搜索目录;“-i”,忽略大小写;“-c”,统计符合搜索条件的文本的行数;“–color”,高亮搜索结果。

du,统计目录大小。比如我想知道来往图片资源的情况。可以看出图片资源一共有8.2MB,其中共享的图片占到2.1MB,其次是聊天的图片占了1.4MB。

  1. [~/iOS_release/lwimageassets]$ du -sh LWImageAssets
  2. 8.2M    LWImageAssets
  3. [~/iOS_release/lwimageassets/LWImageAssets]$ du -sh * | sort -hr
  4. 2.1M    shared_img
  5. 1.4M    chat_img
  6. 636K    event_img
  7. 528K    icon_default
  8. 524K    feed_img
  9. 472K    post_img
  10. 464K    knock_img
  11. 392K    radar_img
  12. 284K    profile_img
  13. 264K    friend_img
  14. 236K    pub_account_map_img
  15. 140K    editor_img
  16. 132K    yifa_img
  17. 132K    emotion_img
  18. 84K    neighbour_img
  19. 80K    lwuikits_img
  20. 76K    discovery_img
  21. 72K    graffiti_img
  22. 72K    asr_img
  23. 60K    login_img
  24. 52K    video_guide_img
  25. 44K    qr_img
  26. 40K    more_img
  27. 36K    share_msg_img
  28. 32K    my_img
  29. 20K    slide_img
  30. 16K    animal_img
  31. 12K    xiamibar_img
  32. 4.0K    search_img
  33. 4.0K    movie_img

file,用于查看文件信息。

  1. file libxiamiMusic.a 
  2. libxiamiMusic.a: Mach-O universal binary with 4 architectures
  3. libxiamiMusic.a (for architecture armv7):    current ar archive random library
  4. libxiamiMusic.a (for architecture i386):    current ar archive random library
  5. libxiamiMusic.a (for architecture x86_64):    current ar archive random library
  6. libxiamiMusic.a (for architecture arm64):    current ar archive random library
  7. file Laiwang 
  8. Laiwang: Mach-O 64-bit executable

strings,查看文件中的文本信息。

  1. $ strings Laiwang | head -n 10
  2. kSearchTextKey
  3. kSearchedPersonKey
  4. invalid_token
  5. user_in_black_list
  6. user_blocked
  7. expired_token
  8. invalid_grant
  9. refreshed_token
  10. client_id
  11. client_secret

nm,查看可执行程序里面的符号信息。

  1. $ nm Laiwang | head -n 10
  2. 00000001001425e4 t +[ABContact addressWithStreet:withCity:withState:withZip:withCountry:withCode:]
  3. 0000000100142484 t +[ABContact arrayForProperty:inRecord:]
  4. 0000000100146438 t +[ABContact contactWithData:]
  5. 000000010014591c t +[ABContact contactWithDictionary:]
  6. 000000010014191c t +[ABContact contactWithRecord:]
  7. 0000000100141984 t +[ABContact contactWithRecordID:]
  8. 0000000100141b70 t +[ABContact contact]
  9. 000000010014252c t +[ABContact dictionaryWithValue:andLabel:]
  10. 0000000100141c50 t +[ABContact localizedPropertyName:]
  11. 00000001001424e8 t +[ABContact objectForProperty:inRecord:]

vim

做简单的文本编辑和分析,vim是非常方便的。最简单有用的配置如下。在HOME目录下创建.vimrc隐藏文件,把下面的内容拷贝进去即可。

  1. syntax on #支持语法高亮,看源代码文件会很舒服。
  2. set hls #使用 / 查找内容的时候,会高亮字符串。
  3. set ic  #搜索的时候忽略大小写

CocoaPods

CocoaPods的源都安装在”~/.cocoapods/repos”目录下,有时候找不到pod、版本有问题、或者想确定一下pod的信息,都可以来这个地方翻一翻。

  1. [~/.cocoapods/repos]$ ls
  2. TBMainClientSpecs/  alibaba/  master/
  3. [~/.cocoapods/repos]$ ls TBMainClientSpecs/
  4. AMPSDK/                   TBCalendar/              TBLoginCenter/          TBScanCode/         TBWeiTao/
  5. AccsSDK/                  TBCalendarService/       TBLoginService/         TBScanCodeService/  TBWeiTaoService/
  6. [~]$ pod search swiftyjson
  7. -> AISwiftyJSON (1.0.6)
  8.    AISwiftyJSON makes it easy to deal with JSON data in Swift .
  9.    pod 'AISwiftyJSON''~> 1.0.6'
  10.    - Homepage: https://github.com/asiainfomobile/AISwiftyJSON
  11.    - Source:   git@mirror.git.alibaba-inc.com:asiainfomobile/AISwiftyJSON.git
  12.    - Versions: 1.0.61.0.3 [master repo]
  13. -> SwiftyJSON (2.3.2)
  14.    SwiftyJSON makes it easy to deal with JSON data in Swift
  15.    pod 'SwiftyJSON''~> 2.3.2'
  16.    - Homepage: https://github.com/SwiftyJSON/SwiftyJSON
  17.    - Source:   git@mirror.git.alibaba-inc.com:SwiftyJSON/SwiftyJSON.git
  18.    - Versions: 2.3.22.3.12.3.02.2.12.2.02.1.3 [master repo]

sqlite

Mac自带了sqlite命令行工具。小工具用起来很快很方便。所以简单介绍一下怎么使用这个工具。其实”.help”讲得很详细啦。

  1. [~/Downloads]$ sqlite3 laiwang.sqlite3 
  2. SQLite version 3.8.5 2014-08-15 22:37:57
  3. Enter ".help" for usage hints.
  4. sqlite> .tables
  5. lw_messages            lw_session_event_post
  6. lw_offline_post2       lw_sessions          
  7. sqlite> .schema lw_sessions
  8. 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);
  9. CREATE UNIQUE INDEX idx_sessions_SidUidSt ON lw_sessions(sessionId, userId, sourceType);
  10. CREATE INDEX idx_sessions_UidStSiLm ON lw_sessions(userId, sourceType, sortIndex, lastModify);
  11. sqlite> select * from lw_sessions limit 1;
  12. 1|2651304|2921438|新浪新闻|http://i01.lw.aliimg.com/tfs/T1vldnFFXbXXbKnNzJLAIWANGtebus_73957a0c_180_180.60x60.jpg||pubmessage|||{"type":""}|||0|0|1429026489000|||0||

Python SimpleHTTPServer

SimpleHTTPServer模块绝对是Python最有用的一个模块(另外一个可能是json)。一个命令就能启动一个Web服务器,做演示或者mock接口,不要太方便了。

  1. [~]$ python -m SimpleHTTPServer 9876
  2. Serving HTTP on 0.0.0.0 port 9876 ...

nomad houston

nomad houston这个工具支持在命令行下给APP推送信息,感觉蛮不错的。详细介绍请看:使用Houston给iOS APP推送信息


问啊-定制化IT教育平台,牛人一对一服务,有问必答,开发编程社交头条 官方网站:www.wenaaa.com

QQ群290551701 聚集很多互联网精英,技术总监,架构师,项目经理!开源技术研究,欢迎业内人士,大牛及新手有志于从事IT行业人员进入!


转载于:https://my.oschina.net/u/2394328/blog/630434

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/985142
推荐阅读
相关标签
  

闽ICP备14008679号