Travis CI 构建 [Cocoapod Swift] 失败,没有 'such module...' 错误
Travis CI build [Cocoapod Swift] fails with no 'such module...' error
我有一个用 Swift 编写的 repository,这是一个标准的 cocoapod 工作区(标准格式,带有使用 Quick 和 Nimble 测试创建的示例应用程序,没有 UI 测试) 在我的本地机器 (Xcode 11.2.1, macOS Catalina 10.15.1) 上顺利构建(并运行测试),但是 Travis CI 构建失败并出现错误,其中一个模块不存在:
/Users/travis/build/Kentico/kontent-delivery-sdk-swift/Example/KenticoKontentDelivery/KontentModels/Cafe.swift:9:8: no such module 'ObjectMapper'
完整的 Travis CI 日志 here。
.podspec 文件:
Pod::Spec.new do |s|
s.name = 'KenticoKontentDelivery'
s.version = '2.0.0'
s.summary = 'Swift SDK for Kentico Kontent Delivery'
s.description = <<-DESC
Swift SDK for Kentico Kontent Delivery.
DESC
s.homepage = 'https://github.com/kentico/kontent-delivery-sdk-swift'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'makma' => 'martinmakarsky@gmail.com' }
s.source = { :git => 'https://github.com/kentico/kontent-delivery-sdk-swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/kenticokontent'
s.ios.deployment_target = '8.0'
s.source_files = 'KenticoKontentDelivery/Classes/**/*'
s.dependency 'AlamofireObjectMapper', '~> 5.2.0'
s.dependency 'ObjectMapper', '~> 3.5.1'
s.dependency 'Kanna', '~> 4.0.2'
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
end
use_frameworks!
platform :ios, '12.0'
target 'KenticoKontentDelivery_Example' do
pod 'KenticoKontentDelivery', :path => '../'
pod 'AlamofireImage', '~> 3.6.0'
pod 'ObjectMapper', '~> 3.5.1'
pod 'AlamofireObjectMapper', '~> 5.2.0'
target 'KenticoKontentDelivery_Tests' do
inherit! :search_paths
pod 'Quick', '~> 2.2.0'
pod 'Nimble', '~> 7.0'
pod 'ObjectMapper', '~> 3.5.1'
pod 'AlamofireObjectMapper', '~> 5.2.0'
end
end
osx_image: xcode11.1
language: objective-c
cache: cocoapods
podfile: Example/Podfile
before_install:
- gem install cocoapods # Since Travis is not always on latest version
- pod repo update
- pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/KenticoKontentDelivery.xcworkspace -scheme KenticoKontentDelivery-Example -sdk iphonesimulator -destination 'name=iPhone 8' ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
after_success:
- bash <(curl -s https://codecov.io/bash)
deploy:
provider: script
script: sh ./scripts/push.sh
skip_cleanup: true
on:
tags: true
我尝试了什么:
- 更改了所有依赖项的版本
- 更改了 osx_image 个版本
我终于调整了设置,以便能够在 Travis CI 上成功 运行。我不确定哪个设置会影响结果,但是,在这些更改之后构建和测试 运行 顺利。
- 降级
IPHONEOS_DEPLOYMENT_TARGET
到版本 11
- 在
Podfile
中设置platform :ios, '11.0'
- 在
.podspec
中设置s.ios.deployment_target = '11.0'
- 设置
s.swift_versions = '5.0'
- 删除了
.swift-version
文件
我有一个用 Swift 编写的 repository,这是一个标准的 cocoapod 工作区(标准格式,带有使用 Quick 和 Nimble 测试创建的示例应用程序,没有 UI 测试) 在我的本地机器 (Xcode 11.2.1, macOS Catalina 10.15.1) 上顺利构建(并运行测试),但是 Travis CI 构建失败并出现错误,其中一个模块不存在:
/Users/travis/build/Kentico/kontent-delivery-sdk-swift/Example/KenticoKontentDelivery/KontentModels/Cafe.swift:9:8: no such module 'ObjectMapper'
完整的 Travis CI 日志 here。
.podspec 文件:
Pod::Spec.new do |s|
s.name = 'KenticoKontentDelivery'
s.version = '2.0.0'
s.summary = 'Swift SDK for Kentico Kontent Delivery'
s.description = <<-DESC
Swift SDK for Kentico Kontent Delivery.
DESC
s.homepage = 'https://github.com/kentico/kontent-delivery-sdk-swift'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'makma' => 'martinmakarsky@gmail.com' }
s.source = { :git => 'https://github.com/kentico/kontent-delivery-sdk-swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/kenticokontent'
s.ios.deployment_target = '8.0'
s.source_files = 'KenticoKontentDelivery/Classes/**/*'
s.dependency 'AlamofireObjectMapper', '~> 5.2.0'
s.dependency 'ObjectMapper', '~> 3.5.1'
s.dependency 'Kanna', '~> 4.0.2'
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
end
use_frameworks!
platform :ios, '12.0'
target 'KenticoKontentDelivery_Example' do
pod 'KenticoKontentDelivery', :path => '../'
pod 'AlamofireImage', '~> 3.6.0'
pod 'ObjectMapper', '~> 3.5.1'
pod 'AlamofireObjectMapper', '~> 5.2.0'
target 'KenticoKontentDelivery_Tests' do
inherit! :search_paths
pod 'Quick', '~> 2.2.0'
pod 'Nimble', '~> 7.0'
pod 'ObjectMapper', '~> 3.5.1'
pod 'AlamofireObjectMapper', '~> 5.2.0'
end
end
osx_image: xcode11.1
language: objective-c
cache: cocoapods
podfile: Example/Podfile
before_install:
- gem install cocoapods # Since Travis is not always on latest version
- pod repo update
- pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/KenticoKontentDelivery.xcworkspace -scheme KenticoKontentDelivery-Example -sdk iphonesimulator -destination 'name=iPhone 8' ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
after_success:
- bash <(curl -s https://codecov.io/bash)
deploy:
provider: script
script: sh ./scripts/push.sh
skip_cleanup: true
on:
tags: true
我尝试了什么:
- 更改了所有依赖项的版本
- 更改了 osx_image 个版本
我终于调整了设置,以便能够在 Travis CI 上成功 运行。我不确定哪个设置会影响结果,但是,在这些更改之后构建和测试 运行 顺利。
- 降级
IPHONEOS_DEPLOYMENT_TARGET
到版本 11 - 在
Podfile
中设置 - 在
.podspec
中设置 - 设置
s.swift_versions = '5.0'
- 删除了
.swift-version
文件
platform :ios, '11.0'
s.ios.deployment_target = '11.0'