XCode添加两个工程联动

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wjy0629/article/details/81501926

接受了一个旧项目,SDK中含有Pods,由于有一个新功能,需要在SDK中进行添加更改,但是SDK中含有Pods,因此不能简单的将SDK添加到工程中去。具体的做法见下方,待我一一讲来:
1、首先终端创建一个文件夹test
2、在文件夹中终端创建一个Podfile文件,同时将原先的两个含有Pods的工程拷贝进去。

Podfile文件内容为:
 

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
workspace 'JYAPP_IOS'
xcodeproj 'DanaleSDK1/DanaleSDK.xcodeproj'
xcodeproj 'HuaweiVideo/HuaweiVideo.xcodeproj'


target 'HuaweiVideo' do
xcodeproj 'HuaweiVideo/HuaweiVideo.xcodeproj'
pod 'AFNetworking', '~> 3.1.0'
pod 'AliyunOSSiOS', '~> 2.6.2'
pod 'Masonry', '1.1.0'
pod 'Reachability', '3.2'
pod 'Braintree/UnionPay'
pod 'Braintree/PayPal'
pod 'OAStackView'
pod 'FMDB'
pod 'libqrencode', '~> 3.4.2'
pod 'Bugly'
pod 'TPKeyboardAvoiding'
pod 'ReactiveCocoa', '2.3.1'
pod 'TTTAttributedLabel'
pod 'IQKeyboardManager'
pod 'ZJAnimationPopView'
pod 'MJExtension'
pod 'FDFullscreenPopGesture'
end

target 'DanaleSDK' do
xcodeproj 'DanaleSDK1/DanaleSDK.xcodeproj'
pod 'AFNetworking', '~> 3.1.0'
pod 'AliyunOSSiOS', '~> 2.6.2'
pod 'Masonry', '1.1.0'
pod 'Reachability', '3.2'
pod 'Braintree/UnionPay'
pod 'Braintree/PayPal'
pod 'OAStackView'
pod 'WechatOpenSDK'
end

此时的文件构成为:

3、分别进入DanaleSDK与HuaweiVideo文件夹,执行 $ rm -rf xxxxx.xcworkspace,将各自的xcworkspace文件移除,然后删除其中的pod相关文件
4、然后在test中,执行pod install,执行成功后CocoaPods会报警告,
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `DanaleSDK` to `../Pods/Target Support Files/Pods-DanaleSDK/Pods-DanaleSDK.debug.xcconfig` or include the `../Pods/Target Support Files/Pods-DanaleSDK/Pods-DanaleSDK.debug.xcconfig` in your build configuration (`DanaleSDK/Pods/Target Support Files/Pods-DanaleSDK/Pods-DanaleSDK.debug.xcconfig`).

此时打开JYAPP_IOS文件,显示为下图

5、编译任意一个工程
此时会报错,
diff: /Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
原因为原先有Pods的配置文件未删除掉,还是默认使用以前的,因此此时需要将原先的配置文件删除,重新pod install

6、再次执行pod install后,编译任意工程

还是编译报错,


error: /Applications/Xcode9.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-DanaleSDK
error: /Applications/Xcode9.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-DanaleSDK is not an object file (not allowed in a library)

原因为执行编译时,未找到Pods-DanaleSDK,那么此时需要去找此文件。

此文件报红色,红色为不存在此文件,也可以看Pods---》Products中的

那么此文件应该怎么生成呢?

7、打开Scheme,如下图

将对应的libPods-DanaleSDK.a与libPods-HuaweiVideo.a调出,编译。

此时再次查看第6步中截图的文件,不再是红色。编译任意一个工程文件,OK,编译通过。

以上就是Pods管理以前含有Pods的多个工程的步骤。
附:在A工程中如何引入SDK源码,一般做法为,打开工程,然后将sdk源码拷贝到工程目录下面,执行addFile添加到A目标工程中,然后将A工程中的.a库删除,再Build Phases中打开Link Binary With Libraries中添加SDK源码对应的.a库即可。最后找到A中引用的SDK的方法,cmd+左键,是否能够跳转,至此完结。
 

猜你喜欢

转载自blog.csdn.net/wjy0629/article/details/81501926