couchbase/couchbase-lite-ios

Compiling issue after upgrading to Xcode 13.2.1

matsunanaro opened this issue · 1 comments

Describe the bug
After upgrading Xcode to 13.2.1, it failed to build a Flutter plugin based on the CouchbaseLite-Swift cocoapod (v2.8.4).
See the Build Errors Log below.

To Reproduce

Basically, we're trying to build a Flutter plugin with a Cocoapod that in turn is based on the CouchbaseLite-Swift Pod.
To reproduce the building errors, please follow the instruction on this project page to build the example app.

Below is the pod spec file used:

Pod::Spec.new do |s|
  s.name             = 'couchbase_lite'
  s.version          = '0.0.1'
  s.summary          = 'Community edition of Couchbase Lite.  Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.'
  s.description      = <<-DESC
Community edition of Couchbase Lite.  Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.
                       DESC
  s.homepage         = 'http://example.com'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'Your Company' => 'email@example.com' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.public_header_files = 'Classes/**/*.h'
  s.dependency 'Flutter'
  s.dependency 'CouchbaseLite-Swift', '~> 2.8.4'

  s.ios.deployment_target = '11.0'
  s.osx.deployment_target  = '10.11'
end

Expected behavior
No compilation failure.

Build Errors Log

Xcode build done.                                            4.0s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/xxxxx/Code/GitHub/couchbase_lite/ios/Classes/CBManager.swift:10:8: warning: '/Users/xxxxx/Code/GitHub/couchbase_lite/example/ios/Pods/CouchbaseLite-Swift/iOS/CouchbaseLiteSwift.framework/Modules/CouchbaseLiteSwift.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo' is either malformed or generated by a different Swift version. Note that it uses an unstable format and may leak internal project details, it should not be distributed alongside modules
    import CouchbaseLiteSwift
           ^
    Command CompileSwiftSources failed with a nonzero exit code
    <unknown>:0: error: unable to load standard library for target 'arm64-apple-ios9.0'
    /Users/xxxxx/Code/GitHub/couchbase_lite/ios/Classes/CBManager.swift:10:8: error: module compiled with Swift 5.3.2 cannot be imported by the Swift 5.5.2 compiler: /Users/xxxxx/Code/GitHub/couchbase_lite/example/ios/Pods/CouchbaseLite-Swift/iOS/CouchbaseLiteSwift.framework/Modules/CouchbaseLiteSwift.swiftmodule/arm64.swiftmodule

Platform (please complete the following information):

  • Device: iPhone 12 Pro Max Simulator
  • OS: iOS 15.2
  • Couchbase Version CouchbaseLiteSwift 2.8.4

Additional context
The project was built on on an Intel based 2019 MacBook Pro with macOS Monterrey version 12.1

The building error was caused by the fact that Xcode 13.2.1 would, by default, import the arm64-simulator binary as well as those from other supported architectures. Since the (M1) arm64-simulator binary was not available in the CouchbaseLite-Swift Pod, the issue was resolved by excluding the arm64-simulator architecture from our PodSpec configuration file:

  s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'}
  s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'}

I hereby close this issue as it was a false alarm.