Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.8k stars 601 forks source link

Upgrading from Nimble 9.2.1 to Nimble 11.2.1 (Latest) could not be built as it could not build module header nimble #1030

Open caolaningenie opened 1 year ago

caolaningenie commented 1 year ago

What did you do?

Upgraded Pod to install 11.2.1, it had been 9.2.1.

What did you expect to happen?

I expected the tests to run successfully.

What actually happened instead?

I am getting two errors that I have been unable to workout as to why they are happening:

  1. Build/Products/Debug-iphonesimulator/Nimble/Nimble.framework/Headers/Nimble-Swift.h:797:9: error build: Include of non-modular header inside framework module 'Nimble.Swift': '/Users/caolanowens/Developer/iOS-Feedback-AaaS/Pods/Nimble/Sources/Nimble/Nimble.h'.
  2. error build: Could not build Objective-C module 'Nimble'.

Environment

List the software versions you're using:

Please also mention which package manager you used and its version. Delete the other package managers in this list:

Project that demonstrates the issue

I am unable to provide the project as it is company project. Whenever I do create a clean project I do not have any issues. It is a possibliity that there is an issue with our build settings but after much research and changes I am left with the same result. I have added our Podfile below, hopefully this can help.

#source 'https://github.com/CocoaPods/Specs.git'
#source 'https://cocoapods-cdn.netlify.app/'
#source 'https://cdn.cocoapods.org/'

platform :ios, '14.0'

project 'Project.xcodeproj'

inhibit_all_warnings!

def use_pods
  pod 'SwiftLint'
  pod 'Alamofire'
  pod 'SwiftyJSON'
  pod 'Alamofire-SwiftyJSON'
  pod 'PureLayout'
  pod 'RxSwift'
  pod 'RxCocoa'
  pod 'RxDataSources'
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'
  pod 'RealmSwift'
  pod 'RxRealm'
  pod 'Action'
  pod 'Firebase/Core', '< 10.0'
  pod 'Firebase/Analytics', '< 10.0'
  pod 'Firebase/Crashlytics', '< 10.0'
  pod 'OneSignalXCFramework', '>= 3.0.0', '< 4.0'
  pod 'ReachabilitySwift'
  pod 'Backgroundable'
  pod 'KeychainSwift'
  pod 'DeviceKit'
  pod 'LiveChat'
  pod 'CSV.swift'
  pod 'Mixpanel-swift'
end

def test_pods
  pod 'Quick', '6.1.0'
  #pod 'Nimble', '< 8.0'
  pod 'Nimble', '11.2.1'
  pod 'RxTest'
  pod 'RxBlocking'
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'
  pod 'RealmSwift'
  pod 'RxSwift'
  pod 'RxCocoa'
  pod 'KeychainSwift'
  pod 'OHHTTPStubs/Swift'
  pod 'Mixpanel-swift'
end

target 'Project' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  use_pods
  pod 'LocalCompanyPod', :path => '../LocalCompanyPod/',  :inhibit_warnings => false

end

target 'Project-Tests' do
  use_frameworks!
  test_pods
  pod 'LocalCompanyPod', :path => '../LocalCompanyPod/',  :inhibit_warnings => false
end

target 'ProjectUITests' do
  use_frameworks!
  test_pods
end

post_install do |installer|
  installer.pods_project.targets.each do |target|

          target.build_configurations.each do |config|
            # Xcode 12 fix for iOS 8 warning
            config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'

            # this build setting must not be applied to Quick and Nimble
            # as it breaks them
            if (!['Quick'].include? target.name) && (!['Nimble'].include? target.name)
            # trying to stop app extensions breaking build cos clash with pods
            config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
            end

           if config.name == 'Test'
                config.build_settings['ENABLE_TESTABILITY'] = 'YES'
           end

            if ['PromiseKit'].include? target.name
              config.build_settings['SWIFT_VERSION'] = '4.0'
            end

            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'

          end
  end
  installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
    configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
  end
end

Additional

I have went through the commit history of Nimble and locally cloned the project to run through the commit history where possible, however, came up short. I did notice one thing that could be suspicious and a reason for this issue:

Specify header_dir in the podspec: 296d2830312f005dee21fe52a95afbaf6cb8a219.

When I remove this line it didn't have any intended affect on the fix but I thought it was worth mentioning.