Search code examples
iosswiftxcodebuild-error

XCode Build Error - missing required module 'Algorithms'


Background

  1. I was trying to upgrade old project from xcode 11.3 into xcode 12.4. The code is still on Swift 4.2
  2. When try to build (any iOS device - arm64) every swift file in the project got same error:
 <unknown\>:0: error: missing required module '**Algorithms**'

3. After try to rebuild using xcode 11.3, then i found out that arm64-apple-ios.swiftinterface is actually adding import 'Algorithms' in top of the file

//swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.3.1 (swiftlang-1200.8.41 clang-1200.0.32.8)
// swift-module-flags: -target arm64-apple-ios9.0 -enable-objc-interop -enable-librar -swift-version 5 -enforce-exclusivi checked -Onone -module-name Charts
import Algorithms
@_exported import Charts
import CoreGraphics

Question

  • How to add this algorithms.h into the project/compilation process, so the project able to compile?

  • What caused the compiler to add this? is it because the build setting > Swift Language Version > Swift 4.2 ?

What i have tried

  • reinstall XCode Command Line Tools 12.4
  • Build Settings->Apple Clang - Language-C++ ->C++ Standard Library(libc++) refference:[https://stackoverflow.com/questions/25649385/algorithm-file-not-found]

Solution

  • The Problem now solved.

    It is appear that one of the library we are using, have dependency on new 'Algorithms' Swift ( https://github.com/apple/swift-algorithms ) . Therefore we can resolve by doing 2 way

    • adding the Algorithms Swift dependency to the projects
    • revert the library into before using Algorithms Swift

    Thanks.