模塊解耦之快速編譯

快速編譯

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]源代碼文件夾名稱

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,048評論 6 542
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,414評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,169評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,722評論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,465評論 6 412
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,823評論 1 328
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,813評論 3 446
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,000評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,554評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,295評論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,513評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,035評論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,722評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,125評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,430評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,237評論 3 398
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,482評論 2 379

推薦閱讀更多精彩內容