最近想模仿某个项目中的某个功能做个Demo,用到CocoaPods管理第三方库,期间出现了一些小问题。
问题一:
通过CocoaPods去导入AFNetworking,执行 pod install –verbose –no-repo-update 终端会有相应的警告:
[!] The `aikaaikaComic [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. [!] The `aikaaikaComic [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. |
解决办法:
- 选择程序 xxx -> TARGETS -> Build Settings
- 找到 Other Linker Flags 如果里面有配置参数先删除,添加 $(inherited)
- 然后执行 pod update –verbose –no-repo-update
问题二:
编译程序提示错误:Undefined symbols for architecture i386 或 Undefined symbols for architecture armv7
解决方法:
- 编辑 Podfile
- 添加
post_install do |installer_representation| installer_representation.project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ARCHS'] = 'armv7 armv7s' end end end
注意 config.build_settings[‘ARCHS’] = ‘armv7 armv7s’ 和项目的 xxx -> TARGETS -> Build Settings 中的 Valid Architectures 的内容对应。
问题三:
再次编译提示错误:lb: library not found for -lPods 或者 lb: library not found for -libPods-AFNetworking.a
解决方法:
- 编辑 Podfile
- 在上面添加的内容中再加上 config.build_settings[‘ONLY_ACTIVE_ARCH’] = ‘NO’
post_install do |installer_representation| installer_representation.project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ARCHS'] = 'armv7 armv7s' config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' end end end
这是因为 64 位下项目中的 Build Active Architecture Only 默认是 NO,而 CocoaPods 中的是 YES。
问题四:
通过 CocoaPods 引入 BaiduMapAPI ,执行 pod update 终端提示如下:
[!] The `YYW [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. [!] The `YYW [Release]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target. |
解决办法:
- 选择程序 xxx -> TARGETS -> Build Settings
- 找到 Library Search Path 添加 $(inherited)
- 编译运行通过