我最近升级到Xcode 8,一个现有的项目升级到Swift 3。在Cocoapods遇到各种问题后,我决定从头开始。在运行了pod deintegrate
并删除了Podfile
、Podfile.lock
和[Project].xcworkspace
之后,就Cocoapods而言,我是一片空白。
然后我采取了以下行动:
-
在项目位置打开一个终端,运行
pod init
,然后运行pod install
(使用pod init
创建的存根Podfile)。这似乎是成功的,但随之而来的是以下两个警告:
[!] The `Xena [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Xena [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
此时,打开Xcode并构建项目会给出"No such module"错误,这完全在意料之中。
按照这个问题的说明解决了这个问题,重新运行pod install
是成功的。
-
关闭Xcode,添加了我使用的模块到Podfile(见下文),再次运行
pod install
。 -
打开Xcode并构建项目。我再次收到"No such module"错误,特别是
No such module 'ReactiveCocoa'
我已经确认,同样的问题发生在SnapKit, Hue, KMPlaceholderTextView, KeychainSwift和Siren,这取决于导入语句的顺序。
我Podfile
:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Xena' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Xena
pod 'ReactiveCocoa', :git => 'https://github.com/ReactiveCocoa/ReactiveCocoa.git'
pod 'SnapKit', '~> 3.0.2'
pod 'Hue', '~> 2.0.1'
pod 'KMPlaceholderTextView', '~> 1.3.0'
pod 'GooglePlacePicker'
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'KeychainSwift', '~> 7.0'
pod 'Siren'
target 'XenaTests' do
inherit! :search_paths
# Pods for testing
end
target 'XenaUITests' do
inherit! :search_paths
# Pods for testing
end
end
确保打开的是.xcworkspace
而不是.xcodeproj
文件。
你可以进一步研究这篇文章。
也在:Target> General> Linked Frameworks and Libraries下确保你的框架在那里。连Pods_Xena.framework
都在
尝试:
Xcode ->Preferences ->Location ->DerivedData
打开文件夹DerivedData并将其移动到废纸篓
取消下一行的注释,为您的项目定义一个全局平台
platform :iOS, '9.0'
取消注释pod文件中的第二行将对您有所帮助。