iOS杂记

  • ios抓包用charles

  • 监听iPhone上的https请求,要先在iPhone上用Safari访问安装证书

  • Error Messages should be of the form:

      [Noun] Can't x because y. [Something is true. Try a thing.]

CocoaPods

  • 安装:sudo gem install cocoapods

  • 使用:在项目目录下建个Podfile,内容如

      platform :ios, '7.0'
      inhibit_all_warnings! #禁止pods里的warnings
      pod 'Reachability',  '~> 3.1.1'

    然后pod install,打开生成的.xcworkspace来使用

    参考:管理包依赖管理本地包Podfile格式

静态库

  • 创建静态库,参见tutorial

    • 若静态库中用到c++而父项目中没用到,则要在父项目的Other Linker Flags中添加-lc++(静态库使用libc++)或-lstdc++(静态库使用libstdc++),参见StackOverflow
    • 静态库只是.o文件的集合,用到的framework都得在父项目中重新link一遍
  • 将静态库的SL.xcodeproj拖进父项目作为子项目的步骤:

    1. 父项目的Target DepedenciesLink Binary With Libraries中添加libSL.a
    2. 父项目的Other Linker Flags中添加-ObjC > -ObjC causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.
      参见QA1490
    3. 父项目的Header Search Paths中添加静态库头文件所在的目录,记得选中recursive
    4. 父项目的Link Binary With Libraries中添加子项目用到的库

    参见:Sub-Projects in Xcode

  • ios上的framework只是对静态库及头文件的封装,动态库因security问题在appstore上被禁使用,所以ios上的framework就是static framework