GithubHelp home page GithubHelp logo

linxunfeng / lxfprotocoltool Goto Github PK

View Code? Open in Web Editor NEW
113.0 2.0 18.0 4.14 MB

由Swift中协议方式实现功能的实用工具库【Refreshable、EmptyDataSetable 支持 Rx 】

Home Page: https://fullstackaction.com

License: MIT License

Swift 94.98% Ruby 5.02%
xib swift emptydataset protocol refresh fullscreen screen empty associate rxswift

lxfprotocoltool's Introduction

LXFProtocolTool

Author Build Status Version License Platform visitors

通过协议的方式来方便快捷地实现一些的实用功能,目前功能不多,往后会逐渐增加,喜欢的来个Star吧 : )

对Swift协议不熟悉的同学可以阅读以下两篇文章做下了解:

iOS - Swift 面向协议编程(一) -- 【个人博客】 【掘金】 【全栈行动】

iOS - Swift 面向协议编程(二) -- 【个人博客】 【掘金】 【全栈行动】

CocoaPods

LXFProtocolTool 支持CocoaPods:

  • 完全安装
pod 'LXFProtocolTool'

当然,也可以根据自己的需要安装指定子库

  • Xib加载
pod 'LXFProtocolTool/LXFNibloadable'
  • 空白视图
pod 'LXFProtocolTool/EmptyDataSetable'
  • 刷新控件
pod 'LXFProtocolTool/Refreshable'
  • 关联属性
pod 'LXFProtocolTool/AssociatedObjectStore'
  • 全屏
pod 'LXFProtocolTool/FullScreenable'

Usage

具体功能与使用请跳转 -- Wiki首页

Wiki目录

Article

License

LXFProtocolTool is available under the MIT license. See the LICENSE file for more info.

Author

Other

lxfprotocoltool's People

Contributors

linxunfeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lxfprotocoltool's Issues

Refreshable 的循环引用问题

Refreshable 的协议extension方法里面

直接使用了 self.base.initRefreshHeader 或者其他初始化 mj_header 的方法会导致循环引用

我看内存结构确实是block持有了self导致viewModel无法释放

所以viewModel 只要订阅了 refresh方法创建的Observable 必然会导致循环引用

关于空白页组件

我看很多APP都是全屏空白提示页,是否是因为他们像安卓一样自定义了navtitlebar作为页面布局,或者有其他解决方案?

swift中使用闭包可以不用判空了

public func emptyDataSet(_ scrollView: UIScrollView, didTap view: UIView) {
// if scrollView.emptyViewTapBlock != nil {
// scrollView.emptyViewTapBlock!(view)
// }
scrollView.emptyViewTapBlock?(view)
}

Abort trap: 6 问题记录

问题

在原先是OC,之后进行OCSwift 混编的项目中,通过Cocoapods集成 LXFProtocolTool/EmptyDataSetable 不报错,但在Swift文件中导入LXFProtocolTool后编译就会报错

Xcode报错内容

/Users/lxf/Library/Developer/Xcode/DerivedData/xxx-aizytmxonhdydshaycccmwbtmfix/Build/Intermediates.noindex/xxx.build/Debug-iphonesimulator/xxx.build/Objects-normal/x86_64/xxx.swiftmodule
---
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Combines, Serialization, Rest of Onone } on SIL for xxx.xxx)
4.	While loading conformances for extension of NSObject (in module 'LXFProtocolTool')
0  swift                    0x0000000107217c15 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000107218332 SignalHandler(int) + 610
2  libsystem_platform.dylib 0x00007fff6aa8b5fd _sigtramp + 29
3  libsystem_platform.dylib 0x00007f95b8ec1200 _sigtramp + 18446743619756055584
4  libsystem_c.dylib        0x00007fff6a961808 abort + 120
5  swift                    0x000000010346779f swift::ModuleFile::fatal(llvm::Error) + 2639
6  swift                    0x0000000103483e06 swift::ModuleFile::loadAllConformances(swift::Decl const*, unsigned long long, llvm::SmallVectorImpl<swift::ProtocolConformance*>&) + 790
7  swift                    0x0000000103bf4c69 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 6201
8  swift                    0x0000000103bf366f swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 575
9  swift                    0x0000000103bf3784 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 852
10 swift                    0x0000000103bf3d1f swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 2287
11 swift                    0x0000000103bf3718 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 744
12 swift                    0x0000000103bf3784 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 852
13 swift                    0x0000000103bf3d1f swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 2287
14 swift                    0x0000000103bf3718 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 744
15 swift                    0x0000000103bf3784 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 852
16 swift                    0x0000000103bf3d1f swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 2287
17 swift                    0x0000000103bf3718 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 744
18 swift                    0x0000000103bf3784 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 852
19 swift                    0x0000000103bf3d1f swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 2287
20 swift                    0x0000000103bf3718 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 744
21 swift                    0x0000000103bf3784 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 852
22 swift                    0x0000000103bf3d1f swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 2287
23 swift                    0x0000000103bf3718 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 744
24 swift                    0x0000000103bf3784 swift::ConformanceLookupTable::updateLookupTable(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceStage) + 852
25 swift                    0x0000000103d22249 swift::NominalTypeDecl::getAllProtocols() const + 73
26 swift                    0x0000000103004e7c (anonymous namespace)::NominalTypeWalker::walkToDeclPre(swift::Decl*) + 60
27 swift                    0x0000000103bc8d4d (anonymous namespace)::Traversal::doIt(swift::Decl*) + 189
28 swift                    0x0000000103004440 swift::ProtocolConformanceAnalysis::init() + 240
29 swift                    0x0000000103199eff swift::SILPassManager::SILPassManager(swift::SILModule*, bool, swift::irgen::IRGenModule*) + 2623
30 swift                    0x00000001031b2761 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 49
31 swift                    0x00000001031a0c45 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 1077
32 swift                    0x00000001031a4056 swift::runSILPassesForOnone(swift::SILModule&) + 166
33 swift                    0x0000000102b5f714 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 772
34 swift                    0x0000000102a2f148 performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1288
35 swift                    0x0000000102a1f7ba swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 21802
36 swift                    0x00000001029a02c1 main + 1265
37 libdyld.dylib            0x00007fff6a892cc9 start + 1
error: Abort trap: 6 (in target 'xxx' from project 'xxx')

尝试

  • 尝试过新建一个 OC 项目,以相同方法 import LXFProtocolTool ,但是一点问题都没有~
  • 也尝试过在Swift组件的.podspec文件中添加如下代码,但是也不起作用
s.pod_target_xcconfig = {'SWIFT_COMPILATION_MODE'=>'wholemodule'}

解决

在桥接文件中,将依赖的 DZNEmptyDataSet 导入之后再次编译就可以了

#import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.