0

I'm trying to update the Facebook SDK for an iOS project.

Initially I had version 11.2.1. With this everything works like charm.

After updating to 12.3.1 (the latest), it works well building for debug. However, when trying to build for Release, it fails with the following error.

<unknown>:0: error: module map file '/Users/XXX/Library/Developer/Xcode/DerivedData/App/Build/Products/Release-iphoneos/FBSDKCoreKit/FBSDKCoreKit.modulemap' not found
<unknown>:0: error: module map file '/Users/XXX/Library/Developer/Xcode/DerivedData/App/Build/Products/Release-iphoneos/FBSDKLoginKit/FBSDKLoginKit.modulemap' not found
<unknown>:0: error: module map file '/Users/XXX/Library/Developer/Xcode/DerivedData/App/Build/Products/Release-iphoneos/FBSDKShareKit/FBSDKShareKit.modulemap' not found

It also fails for version 12.0.0 (which is the next release after 11.2.1).

I have tried to install the SDK both via CocoaPods and via SPM (as detailed here). It fails in both cases.

Development enviroment/settings:

  • MacOS Big Sur 11.5.2
  • Testing on an iPhone 11 with iOS 14.8.1
  • Tried with both Xcode 12.5.1 and 13.2.1
  • Project uses Swift 5
  • Deployment target of the Project is set to iOS 13.0

There are several reports of this error here in Stack Overflow, in the SDK repo and also in the SDK old repo. After checking them, I have tested all the following, without success:

  • I'm opening the .xcworkspace, not the .xcproject (as stated here)
  • I have the same iOS version set in both the Project, the Targets and the Pods (as stated here)
  • I have performed several full clean-ups (pod clean + deintegrate, Product > Clean Build Folder in Xcode as well as deleting the Derived Data folder).
  • I've tried setting Validate Workspace to Yes (as explained here)
  • I've tried messing around with the Excluded Architectures settings as explained in many threads, but did not work (which didn't surprise me because those are targeted to running in simulators, and I'm doing so with a real device).
  • I've set "Build Active Architecture Only" to Yes even for release mode (as explained here)
  • I've played with the following stuff in the Podfile postinstall (suggested here)
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # Initially I only had this, which ensures that Pods have iOS 13.0 as target
      if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 13.0
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
      end
      
      # Then I also tried this
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      
      # Also tried setting this
      config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"

      # As well as this
      config.build_settings[“EXCLUDED_ARCHS[sdk=iphonesimulator*]“] = “arm64”
    end
  end
end

1 Answers1

1

I was finally able to solve the problem. I could not reproduce the issue on a new project, so it had to be either something of in the configuration of my existing project, or some caching issue of Xcode. In the end, it was the former.

In the Target I have configured for Release, heading to Build Settings > Swift Compiler - Custom Flags > Other Swift Flags (OTHER_SWIFT_FLAGS) I had the following values:

-Xcc -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/FBSDKCoreKit/FBSDKCoreKit.modulemap"
-Xcc -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/FBSDKLoginKit/FBSDKLoginKit.modulemap" 
-Xcc -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/FBSDKShareKit/FBSDKShareKit.modulemap"

I removed them and... Problem solved!

I don't know why these values where there in the first place, as this project was started by another developer. But, they seem to be unnecessary for SDK 11.X versions too.

However, the reason why they work in 11.X versions buy they do not in 12.X is that module maps are not actually present in the Build directory with the latter versions. That is, with 11.X versions, we can see the following in DerivedData directory:

$ ls -l DerivedData/XXX/Build/Products/Release-iphoneos/FBSDKCoreKit
FBSDKCoreKit.modulemap
FBSDKCoreKit-umbrella.h
// And a few more files

While with 12.X versions, there is just this:

$ ls -l DerivedData/XXX/Build/Products/Release-iphoneos/FBSDKCoreKit
PackageFrameworks

I'm fairly new into iOS development, so I'm not sure why this happens. But I imagine that it has something to do with this change introduced in version 12.0.0

Starting with version 12.0.0, CocoaPods and Swift Package Manager (SPM) are vending pre-built XCFrameworks. You no longer need to build the SDK when using CocoaPods or SPM, which should save you between a few seconds and a few minutes per build.