iOS Building Errors - M4 compatibility issues

Hi everyone,

currently I am trying to build the Mattermost App v2.31.0 for iOS and not getting very far.

Hardware: MacBook Pro M4

Software:

  • Mattermost Mobile App v2.31.0
  • Ruby 3.2.0
  • Cocoapods 1.16.1
  • Xcode 16.1 (macOS 15.2)

When executing npm install, I get the error message

> cd ios && RCT_NEW_ARCH_ENABLED=0 arch -x86_64 pod install



arch: posix_spawnp: pod: Bad CPU type in executable` 

but the script is still running through (except the pod-Part of course). So I execute pod install manually in the ios-Directory and it works without any problems.

But when building the app in Xcode I am getting some weird errors:

.../mattermost-mobile/libraries/@mattermost/secure-pdf-viewer/ios/SecurePDFViewerManager.h:12:1 Cannot #include files inside '#pragma clang assume_nonnull'

and

.../mattermost-mobile/ios/Pods/Headers/Public/React-Fabric/react/renderer/components/view/YogaStylableProps.h:10:10 'yoga/style/Style.h' file not found

What am I doing wrong? Have somebody had similar problems?

Thanks for any help!

~ Jens

1 Like

Hi Jens,

I see you’re encountering some common issues when building Mattermost Mobile on Apple Silicon. These are known compatibility problems. Here are the solutions:

For the arch: posix_spawnp: pod: Bad CPU type in executable error:

This happens because you’re running an x86_64 pod command on M4 hardware. Instead of the manual workaround, try:

  1. Install CocoaPods for ARM64 architecture:
sudo gem install cocoapods
  1. Then run the iOS setup natively:
cd ios && pod install

For the SecurePDFViewerManager.h error: This is a pragma directive conflict. The fix is:

  1. Navigate to: libraries/@mattermost/secure-pdf-viewer/ios/SecurePDFViewerManager.h

  2. Move any #include or #import statements to before the #pragma clang assume_nonnull directive

  3. The structure should look like:

#import <Foundation/Foundation.h>
// ... other imports

#pragma clang assume_nonnull begin
// ... rest of the code

For the Yoga style error: This indicates React Native dependencies aren’t properly linked. Try:

  1. Clean everything:
cd ios
pod deintegrate
pod clean
pod install
  1. In Xcode: Product → Clean Build Folder

Alternative approach: Since you’re on M4, consider using the native ARM64 workflow instead of forcing x86_64 emulation, which should resolve most compatibility issues.

Let me know if you need help implementing any of these fixes!

Best,
Angelina

Hi Angelina,

thanks for your quick response!

The fix for the SecurePDFViewerManager.h works great, but cleaning everything up did not solve the errors with the Yoga style file.

I read this post [RN@0.75.2] `yoga/style/Style.h` file not found ¡ Issue #46208 ¡ facebook/react-native ¡ GitHub and modified my Podfile:

post_install do |installer|
    # Path to the Yoga headers in Private
    private_yoga_headers = "#{installer.sandbox.root}/Headers/Private/Yoga"
    # Path to the Yoga headers in Public
    public_yoga_headers = "#{installer.sandbox.root}/Headers/Public/Yoga"

    # Copy the Yoga headers from Private to Public
    FileUtils.mkdir_p(public_yoga_headers) unless Dir.exist?(public_yoga_headers)
    system("rsync -a #{private_yoga_headers}/ #{public_yoga_headers}")


    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
       # :ccache_enabled => true
    )
end

This seems to solve my problems with the Yoga style file, but now I have other issues:

.../libraries/@mattermost/secure-pdf-viewer/ios/SecurePDFViewerManager.mm:13:9 'react/renderer/components/RNSecurePdfViewerSpec/ComponentDescriptors.h' file not found

and

/Users/.../Library/Developer/Xcode/DerivedData/Mattermost-dmrkeotuomcqgydkdxtfoyckixom/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/secure-pdf-viewer.build/DerivedSources/secure_pdf_viewer-Swift.h:309:1 Duplicate interface definition for class 'SecurePdfViewerComponentView'

It looks like, that there is one compatibility issue after another. Regarding your alternative approach: How do I not force x86_64 emulation? I am already using an ARM64 Pod application, so what else do I have to do?

Best,

Jens

Is there a recommend Apple architecture for building the mobile app? It seems Apple silicon is not the best choice… Or are there ways to fix the compatibility issues?

Best,

Jens

Glad to hear the SecurePDFViewer header fix worked :white_check_mark:

For the Yoga issue: your Podfile patch (copying Yoga headers from Private → Public) is the right workaround — it’s basically the same approach others in the RN community have taken until the upstream patch lands.

The new errors you’re seeing:

  1. ComponentDescriptors.h not found

    • This comes from React Native’s new architecture (Fabric). The secure-pdf-viewer package hasn’t fully updated to RN 0.75+ header paths.

    • Fix: In SecurePDFViewerManager.mm, replace

      #import <react/renderer/components/RNSecurePdfViewerSpec/ComponentDescriptors.h>

      with the relative path to where RN actually installs those Fabric headers, e.g.:

      (or point Xcode’s HEADER_SEARCH_PATHS to include ${PODS_ROOT}/Headers/Private/React-Fabric).

  2. Duplicate interface definition for SecurePdfViewerComponentView

    • This happens when the Fabric codegen generates a Swift bridging header and the module already defines the same interface.

    • Temporary workaround:

      • Delete the secure_pdf_viewer-Swift.h import if it’s being pulled twice.

      • Or, disable Fabric for this module by setting in package.json build scripts:

        RCT_NEW_ARCH_ENABLED=0

        and then reinstall pods.

About “not forcing x86_64 emulation”:
You’re already on the right track. On M4 you should:

  • Remove all arch -x86_64 from scripts (since that only works on Intel/ Rosetta).

  • Run CocoaPods natively (pod install without the arch prefix).

  • Make sure Ruby and Node are ARM builds too (so everything runs cleanly in arm64).

So at this point, it’s less about local setup and more about upstream module compatibility. SecurePDFViewer and Yoga haven’t fully caught up with RN 0.75 + Xcode 16 yet.

For you easiness, I have draft those Podfile + patch commands (so you can just copy-paste) to handle the SecurePDFViewer + Yoga issues together.

1. Podfile (updated)

Replace your current post_install with this:
post_install do |installer|
-— Fix Yoga header issue ----
private_yoga_headers = “#{installer.sandbox.root}/Headers/Private/Yoga”public_yoga_headers = “#{installer.sandbox.root}/Headers/Public/Yoga”
FileUtils.mkdir_p(public_yoga_headers) unless Dir.exist?(public_yoga_headers)system(“rsync -a #{private_yoga_headers}/ #{public_yoga_headers}”)
-— React Native default post-install ----
react_native_post_install(installer,config[:reactNativePath],:mac_catalyst_enabled => false,)
-— Patch SecurePDFViewer search paths ----
installer.pods_project.targets.each do |target|if target.name == ‘secure-pdf-viewer’target.build_configurations.each do |config|config.build_settings[‘HEADER_SEARCH_PATHS’] ||= [‘$(inherited)’]config.build_settings[‘HEADER_SEARCH_PATHS’] << “${PODS_ROOT}/Headers/Private/React-Fabric”endendendend
2. SecurePDFViewerManager.mm patch
Inside libraries/@mattermost/secure-pdf-viewer/ios/SecurePDFViewerManager.mmreplace this import:#import <react/renderer/components/RNSecurePdfViewerSpec/ComponentDescriptors.h>
with#import <react/renderer/components/view/ComponentDescriptors.h>

(Fabric headers moved in RN 0.75+, this points to the correct location.)

3. Disable Duplicate Interface Generation (Workaround)

If you still hit the Duplicate interface for SecurePdfViewerComponentView error,add this to the top of SecurePDFViewerManager.mm

:#define RCT_NEW_ARCH_ENABLED 0

That forces this module to build in the old architecture mode, avoiding duplicate Fabric definitions.
4. Clean + Reinstall Commands

Run these in project root:

# Clean everything
watchman watch-del-all
rm -rf node_modules ios/Pods ios/build
npm install

# Install pods natively on M4 (no x86_64!)
cd ios && pod install && cd ..

# Clean Xcode cache
xed ios
# Then in Xcode: Product > Clean Build Folder

With this setup:

  1. Yoga headers are always copied into Public automatically.
  2. SecurePDFViewer gets the right header search paths.
  3. Fabric duplication is disabled until the library updates.
  4. No more arch -x86_64 hacks (all ARM64).
1 Like