美文网首页
模块解耦之快速编译

模块解耦之快速编译

作者: William8 | 来源:发表于2017-03-30 09:43 被阅读0次

    快速编译

    1.背景

    为了实现各模块之家的解耦和各模块和App之间的快速可插拔要求,设计了此方案。

    此方案能够解决如下问题:

    a1.模块的单独编码和模块的单独编译;

    a2.需要应用模块的时候能够通过一行命令就能快速接入某个功能模块到App中,不需要的时候就能快速的去掉该模块在工程中的引用;

    a3.能够按需引用功能模块,自动生成工程代码,可实现定制项目的快速响应。

    2.实现方案

    a1.实现思路:使用cocoapods本地仓库的方式,把各个模块在本地创建仓库,实现模块功能的本地管理和本地编译;再通过Podfile install命令实现功能模块的快速引用和快速删除。

    a2.本地仓库的创建方法

    aa1:使用xcode创建一个工程,工程名字就叫cocospods;

    在cocospods目录下创建LocalLib目录,用来放置各个模块的代码;

    在LocalLib下面,创建pod库的代码名称,比如叫download。

    代码目录如图:

    aa2:在download目录下面,创建podspec文件。

    创建命令:pod spec create download

    aa3:修改download. podspec文件

    .podspec修改要点如下:

    #

    #Be sure to run `pod spec lint upload.podspec' to ensure this is a

    #valid spec and to remove all comments including this before submittingthe spec.

    #

    #To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html

    #To see working Podspecs in the CocoaPods repo seehttps://github.com/CocoaPods/Specs/

    #

    Pod::Spec.new do |s|

    #―――Spec Metadata――――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #These will help people to findyour library, and whilst it

    #can feel like a chore to fillin it's definitely to your advantage. The

    #summary should be tweet-length,and the description more in depth.

    #

    s.name="upload"

    s.version= "0.0.1"

    s.summary= "A shortdescription of upload."

    # This description is used to generate tags and improve search results.

    #* Think: What does it do? Whydid you write it? What is the focus?

    #* Try to keep it short, snappyand to the point.

    #* Write the descriptionbetween the DESC delimiters below.

    #* Finally, don't worry aboutthe indent, CocoaPods strips it!

    s.description= 'upload test'

    s.homepage='http://EXAMPLE/upload'[11]

    # s.screenshots="www.example.com/screenshots_1.gif","www.example.com/screenshots_2.gif"

    #―――Spec License―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #Licensing your code isimportant. See http://choosealicense.com for more info.

    #CocoaPods will detect a licensefile if there is a named LICENSE*

    #Popular ones are 'MIT', 'BSD'and 'Apache License, Version 2.0'.

    #

    s.license= "MIT[12]"

    # s.license= { :type =>"MIT", :file => "FILE_LICENSE" }

    #―――Author Metadata―――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #Specify the authors of thelibrary, with email addresses. Email addresses

    #of the authors are extractedfrom the SCM log. E.g. $ git log. CocoaPods also

    #accepts just a name if you'drather not provide an email address.

    #

    #Specify a social_media_urlwhere others can refer to, for example a twitter

    #profile URL.

    #

    s.author= { 'William' => '' }

    # Or just: s.author= 'William'

    # s.authors= { 'William' => '' }

    # s.social_media_url= 'http://twitter.com/William'[13]

    #―――Platform Specifics―――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #If this Pod runs only on iOS orOS X, then specify the platform and

    #the deployment target. You canoptionally include the target after the platform.

    #

    #s.platform= :ios

    # s.platform= :ios, '5.0'

    #When using multiple platforms

    # s.ios.deployment_target ='5.0'

    # s.osx.deployment_target = '10.7'

    # s.watchos.deployment_target ='2.0'

    # s.tvos.deployment_target ='9.0'

    [14]

    #―――Source Location――――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #Specify the location from wherethe source should be retrieved.

    #Supports git, hg, bzr, svn andHTTP.

    #

    s.source= { :git =>""[15], :tag => "#{s.version}" }

    #―――Source Code――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #CocoaPods is smart about how itincludes source code. For source files

    #giving a folder will includeany swift, h, m, mm, c & cpp files.

    #For header files it willinclude any header in the folder.

    #Not including thepublic_header_files will make all headers public.

    #

    s.source_files="Classes"[16], "Classes/**/*.{h,m}"

    s.exclude_files = "Classes/Exclude"

    # s.public_header_files = "Classes/**/*.h"

    #―――Resources――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #A list of resources includedwith the Pod. These are copied into the

    #target bundle with a buildphase script. Anything else will be cleaned.

    #You can preserve files frombeing cleaned, please don't preserve

    #non-essential files like tests,examples and documentation.

    #

    # s.resource="icon.png"

    # s.resources = "Resources/*.png"

    # s.preserve_paths = "FilesToSave","MoreFilesToSave"

    #―――Project Linking――――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #Link your library withframeworks, or libraries. Libraries do not include

    #the lib prefix of their name.

    #

    # s.framework="SomeFramework"

    # s.frameworks = "SomeFramework", "AnotherFramework"

    # s.library= "iconv"

    # s.libraries = "iconv", "xml2"

    #―――Project Settings―――――――――――――――――――――――――――――――――――――――――――――――――――――――――#

    #

    #If your library depends oncompiler flags you can set them in the xcconfig hash

    #where they will only apply toyour library. If you depend on other Podspecs

    #you can include multipledependencies to ensure it works.

    # s.requires_arc = true

    # s.xcconfig = { "HEADER_SEARCH_PATHS" =>"$(SDKROOT)/usr/include/libxml2" }

    # s.dependency "JSONKit", "~> 1.4"

    end

    3.附件、参考信息

    参考链接:http://blog.csdn.net/veryitman/article/details/51407078

    Podfile文件信息:

    platform :ios,'7.0'

    #use_frameworks!

    target'cocospods' do

    # download模块

    pod 'download', :path =>'./LocalLib/download/'

    # upload模块

    pod ‘upload’, :path =>'./LocalLib/upload/'

    #pod 'core_lib_spec', :svn =>'http://svn.ids111.com/o2o/client/ios/trunks/master/Frameworks/CoreLibrary'

    end

    [11]原先为"http://EXAMPLE/upload",编译问题把“”改为‘’

    [12]原先为"MIT (example)",去掉example

    [13]把双引号“”改为单引号‘’,编译问题,去掉没有必要的信息

    [14]把双引号“”改为单引号‘’,编译问题。

    [15]去掉里面的内容

    [16]源代码文件夹名称

    相关文章

      网友评论

          本文标题:模块解耦之快速编译

          本文链接:https://www.haomeiwen.com/subject/oazlvttx.html