Error when building my private pod.
<module-includes>:2:9: note: in file included from <module-includes>:2:
#import "Headers/Sensa_Shared-Swift.h"
^
/Users/Ysee/Library/Developer/Xcode/DerivedData/Sensa-Shared-ehkhrlhslibfzudxnrvcfrviclrv/Build/Products/Debug-iphoneos/Sensa-Shared/Sensa_Shared.framework/Headers/Sensa_Shared-Swift.h:175:9: error: 'Sensa_Shared/Sensa_Shared.h' file not found
#import <Sensa_Shared/Sensa_Shared.h>
^
<unknown>:0: error: could not build Objective-C module 'Sensa_Shared'
pod install
Analyzing dependencies
Fetching podspec for `Sensa-Model` from `../../Sensa-Model`
Fetching podspec for `Sensa-Network` from `../../Sensa-Network`
Fetching podspec for `Sensa-Shared` from `../`
Fetching podspec for `Sensa-Stylesheet` from `../../Sensa-Stylesheet`
Downloading dependencies
Using Alamofire (4.8.0)
Using AsyncSwift (2.0.4)
Using FBSnapshotTestCase (2.1.4)
Using Freddy (3.0.3)
Using Hero (1.4.0)
Using Moya (10.0.2)
Using Nimble (7.3.1)
Using Nimble-Snapshots (6.3.0)
Using ObjcExceptionBridging (1.0.1)
Using Quick (1.3.2)
Using ReachabilitySwift (4.3.0)
Using Realm (3.11.1)
Using RealmSwift (3.11.1)
Using Result (3.2.4)
Using SSZipArchive (2.1.1)
Using Sensa-Model (1.0.46)
Using Sensa-Network (1.0.18)
Using Sensa-Shared (1.0.13)
Using Sensa-Stylesheet (1.0.6)
Using SideMenuController (0.2.4)
Using SlackTextViewController (1.9.6)
Using SnapKit (4.0.0)
Using SwiftMsgPack (1.0.0)
Using XCGLogger (6.1.0)
Generating Pods project
libs SideMenuController to Swift 3.2
libs SideMenuController to Swift 3.2
Integrating client project
Sending stats
Pod installation complete! There are 8 dependencies from the Podfile and 24 total pods installed.
I expect my project to build perfectly...
I got a build error:
<module-includes>:2:9: note: in file included from <module-includes>:2:
#import "Headers/Sensa_Shared-Swift.h"
^
/Users/Ysee/Library/Developer/Xcode/DerivedData/Sensa-Shared-ehkhrlhslibfzudxnrvcfrviclrv/Build/Products/Debug-iphoneos/Sensa-Shared/Sensa_Shared.framework/Headers/Sensa_Shared-Swift.h:175:9: error: 'Sensa_Shared/Sensa_Shared.h' file not found
#import <Sensa_Shared/Sensa_Shared.h>
^
<unknown>:0: error: could not build Objective-C module 'Sensa_Shared'
CocoaPods : 1.5.3
Ruby : ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
RubyGems : 2.7.4
Host : Mac OS X 10.13.6 (17G65)
Xcode : 10.1 (10B61)
Git : git version 2.17.2 (Apple Git-113)
Ruby lib dir : /usr/local/Cellar/ruby/2.5.0/lib
Repositories : artsy - https://github.com/artsy/Specs @ 520ae771e36cea8775ddb273dea4225b68b6e3aa
list-sensa-ios-specs - https://git.list.lu/sensa/iOS-Specs.git @ f96700b5c734253fe45a9386132b83de85a12c8c
master - https://github.com/CocoaPods/Specs.git @ 8213b169a2ef310ff0dba9cea4f715ed29cdda01
Sensa-Model - [email protected]:sensa/iOS-Specs.git @ f96700b5c734253fe45a9386132b83de85a12c8c
Sensa-Network - [email protected]:sensa/iOS-Specs.git @ f96700b5c734253fe45a9386132b83de85a12c8c
Sensa-Shared - [email protected]:sensa/iOS-Specs.git @ f96700b5c734253fe45a9386132b83de85a12c8c
Executable Path: /usr/local/bin/pod
cocoapods-deintegrate : 1.0.2
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.3.0
cocoapods-try : 1.1.0
source 'https://git.list.lu/sensa/iOS-Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'Sensa-Shared_Example' do
pod 'Sensa-Shared', :path => '../'
pod 'Sensa-Network', :path => '../../Sensa-Network'
pod 'Sensa-Model', :path => '../../Sensa-Model'
pod 'Sensa-Stylesheet', :path => '../../Sensa-Stylesheet'
target 'Sensa-Shared_Tests' do
inherit! :search_paths
pod 'Quick', '~> 1.3.1'
pod 'Nimble', '~> 7.3.0'
pod 'FBSnapshotTestCase' , '~> 2.1.4'
pod 'Nimble-Snapshots' , '~> 6.3.0'
end
end
libs = ['SideMenuController']
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if libs.include? target.to_s
puts "libs #{target} to Swift 3.2"
config.build_settings['SWIFT_VERSION'] = '3.2'
#else
#puts "libs #{target} to Swift 4.0"
#config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end
#
# Be sure to run `pod lib lint Sensa-Shared.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'Sensa-Shared'
s.version = '1.0.13'
s.summary = 'A short description of Sensa-Shared.'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://lu.sample_project'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'YMonnier' => '[email protected]' }
s.source = { :git => 'https://git.sample.lu/sample_project.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.ios.deployment_target = '9.0'
s.source_files = 'Sensa-Shared/Classes/**/*'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
var_resources = ['Sensa-Shared/Classes/**/*.xib']
s.resource_bundle = {
'Sensa-Shared' => var_resources
}
s.ios.vendored_frameworks = ['Sensa-Shared/Classes/Frameworks/SKMaps.framework']
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => ['-lObjC'] }
# Linked libs
s.dependency 'Sensa-Network', '~> 1'
s.dependency 'Sensa-Stylesheet', '~> 1'
s.dependency 'SnapKit', '4.0.0'
s.dependency 'SlackTextViewController', '1.9.6'
s.dependency 'SideMenuController', '0.2.4'
#s.dependency 'ScoutMaps-iOS-SDK', '~> 3.0.3'
s.dependency 'SSZipArchive', '2.1.1'
s.dependency 'Hero', '1.4.0'
end
Can you try adding Sensa_Shared.h to the public_header_files attribute in your Podspec?
@amorde still the same issue by adding:
s.public_header_files = 'Sensa-Shared/Classes/Sensa_Shared.h'
or
s.public_header_files = 'Sensa-Shared/Sensa_Shared.h'
or
s.public_header_files = 'Sensa_Shared.h'
Moreover, the Sensa_Shared.h file does not exist on my workspace development.
Ah gotcha. It looks like you're building a mixed Swift & Objective-C pod - if that's the case, Xcode will try to import <Sensa-Shared/Sensa_Shared.h> within the generated -Swift.h header. You'll need to create the header manually and add imports for the Objective-C classes that you want to expose to Swift.
CocoaPods generates an umbrella header automatically and imports it within the .modulemap, but Xcode doesn't use that when generating the -Swift.h header
@amorde thanks, it works now!
Awesome!
@YMonnier, can you please elaborate on how you fixed it? I'm encountering a similar issue and can't wrap my head around it.
Aye, can we get an elaboration on how this was resolved?
I created a file similar to Sensa_Shared.h to import objc header files used in Swift. However, my Example pods project starts throwing duplicate symbol errors. Which I wouldn't mind if this fixed the pod lib lint from failing.
But I am still receiving the <unknown>:0: error: could not build Objective-C module 'My_Pod'for my private pod
Can you open another issue with a sample that reproduces it? It’s difficult to troubleshoot these kind of issues based on basic info. The approach mentioned in my comment should work
Most helpful comment
Ah gotcha. It looks like you're building a mixed Swift & Objective-C pod - if that's the case, Xcode will try to import
<Sensa-Shared/Sensa_Shared.h>within the generated-Swift.hheader. You'll need to create the header manually and add imports for the Objective-C classes that you want to expose to Swift.CocoaPods generates an umbrella header automatically and imports it within the
.modulemap, but Xcode doesn't use that when generating the-Swift.hheader