masonry庫最低支持版本引起的崩潰問題

問題及解決

  • 問題
    開發(fā)中,遇到在代碼中使用mas_bottomMargin崩潰的問題。
  • 解決方法
    修改Masonry Target最低支持版本為iOS8.0以上


    三方庫Target最低版本.png

原因分析及進(jìn)一步優(yōu)化處理

  • 原因
    mas_bottomMargin等幾個屬性定義依靠的是最低支持版本至少是8.0。
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)

@property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;

#endif
  • 優(yōu)化處理
    為了防止其它Pod安裝的三方庫遇到類似問題,可以在Podfifle文件最后統(tǒng)一修改為三方庫最低支持iOS版本與app保持一致, 比如app最低支持iOS9.0的寫法如下
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
    end
  end
end

參考

# Set deployment target for CocoaPods's pod

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容