一、添加多工程
新建
待續(xù)...
-
多工程靜態(tài)庫連接問題注意事項(xiàng)
1平委、在其他工程中丧肴,load 方法不調(diào)用問題
-
解決方案
在對(duì)應(yīng)主工程project -> targets -> build setting. -> other linker flag 設(shè)置:-all_load
或者-ObjC
,其中區(qū)別自己補(bǔ)充燃箭;該該操作是為了設(shè)置編譯鏈接鸥滨;也可以在其他主工程里面調(diào)用 其他的工程
【因?yàn)槟銢]使用到任何一個(gè)庫的函數(shù)戴甩,因此鏈接的時(shí)候會(huì)被忽略掉的】
-
2符喝、庫文件導(dǎo)入
#import <xxxx/xxxx.h>
不會(huì)自動(dòng)提示-
解決方案
在對(duì)應(yīng)主工程project -> targets -> build setting. -> header search paths 設(shè)置:$(SRCROOT)/../xxxx
,其中xxxx 為子工程名字甜孤,該操作主要為設(shè)置路徑
-
解決方案
-
3协饲、文件導(dǎo)入
#import <xxxx/xxxx.h>
報(bào)錯(cuò),提示找不到該文件-
解決方案
在對(duì)應(yīng)主工程project -> targets -> build phrase. -> headers ,把需要在其他工程調(diào)用的類設(shè)置:public
缴川,然后在該靜態(tài)庫的.h
文件中導(dǎo)入#import <XXXX/xxxx.h>
-
解決方案
二茉稠、cocopods管理多工程
1、Podfile 使用
去官網(wǎng)查看Podfile 用戶把夸,上面介紹了多工程的使用
-
示例
# Uncomment the next line to define a global platform for your project # 學(xué)習(xí)博客: http://www.reibang.com/p/7d0ad4cde012 # 官網(wǎng)Podfile: https://guides.cocoapods.org/using/the-podfile.html source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/Artsy/Specs.git' platform :ios, '9.0' #忽略Pods警告 inhibit_all_warnings! #設(shè)置工作空間文件名 workspace 'MineAppProject.xcworkspace' #通用pods集 def commonPods # Pods someFile pod 'YYKit', '~> 1.0.9' pod 'MGJRouter' pod 'AFNetworking', '~> 3.0' pod 'MJExtension', '~> 3.0.15.1' pod 'Masonry' end target 'QFUIKit' do use_frameworks! commonPods project 'QFUIKit/QFUIKit.xcodeproj' target 'QFUIKitTests' do inherit! :search_paths end end target 'CommonComponent' do use_frameworks! commonPods project 'CommonComponent/CommonComponent.xcodeproj' target 'CommonComponentTests' do inherit! :search_paths end end target 'BackgroundControlComponent' do use_frameworks! commonPods project 'BackgroundControlComponent/BackgroundControlComponent.xcodeproj' target 'BackgroundControlComponentTests' do inherit! :search_paths # Pods for testing end end target 'MineApp' do use_frameworks! commonPods project 'MineApp/MineApp.xcodeproj' target 'MineAppTests' do inherit! :search_paths # Pods for testing end target 'MineAppUITests' do inherit! :search_paths # Pods for testing end end
-
多工程cocopods注意事項(xiàng)
- 1而线、警告
[!] The `MineApp [Debug]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `../Pods/Target Support Files/Pods-MineApp/Pods-MineApp.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target.
解決方案
在對(duì)應(yīng)project -> targets -> build setting. ->header search path 導(dǎo)入:$(inherited)
2、警告
add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).
-
解決方案
靜態(tài)庫需添加一個(gè)測(cè)試工程恋日,否則有上述警告警告target 'xxxxxxTests' do inherit! :search_paths end
3膀篮、警告
[!] Could not automatically select an Xcode project. Specify one in your Podfile like so: project 'path/to/Project.xcodeproj'
-
解決方案
需導(dǎo)入 工程路徑 xcodeproj【否則:會(huì)報(bào)錯(cuò)無法自動(dòng)選擇Xcode項(xiàng)目。在Podfile中指定一個(gè)路徑: project 'xxxxx/xxxxx.xcodeproj'】target 'MineApp' do use_frameworks! #主工程路徑 xcodeproj【否則:會(huì)報(bào)錯(cuò)無法自動(dòng)選擇Xcode項(xiàng)目谚鄙。在Podfile中指定一個(gè)路徑】 project 'xxxxx/xxxxx.xcodeproj' end
-
4各拷、警告
Library not loaded: @rpath/AFNetworking.framework
-
解決方案
在對(duì)應(yīng)project -> targets -> build setting. -> Mach-O Type 導(dǎo)入:Static Library
-
解決方案