react-native-maps: IOS Build Error: `unsupported Swift architecture` and `could not build module 'GoogleMapsUtils'`

Summary

When building the App with "react-native": "0.72.3", "expo": "^49.0.3", and "react-native-maps": "1.7.1",, the IOS build getting fail with the following errors:

› Compiling react-native-maps Pods/react-native-google-maps » AIRGoogleMapHeatmapManager.m


❌  (/Users/expo/workingdir/build/ios/build/Build/Products/Debug-iphonesimulator/Google-Maps-iOS-Utils/GoogleMapsUtils.framework/Headers/GoogleMapsUtils-Swift.h:310:2)

  308 | 
  309 | #else
> 310 | #error unsupported Swift architecture
      |  ^ unsupported Swift architecture
  311 | #endif
  312 | 


❌  (node_modules/react-native-maps/ios/AirGoogleMaps/AIRGoogleMapHeatmap.h:7:9)

   5 | //
   6 | 
>  7 | #import "GMUHeatmapTileLayer.h"
     |         ^ could not build module 'GoogleMapsUtils'
   8 | 
   9 | @interface AIRGoogleMapHeatmap : UIView
  10 | 

› Compiling react-native-maps Pods/react-native-google-maps » AIRGoogleMapHeatmap.m


❌  (/Users/expo/workingdir/build/ios/build/Build/Products/Debug-iphonesimulator/Google-Maps-iOS-Utils/GoogleMapsUtils.framework/Headers/GoogleMapsUtils-Swift.h:310:2)

  308 | 
  309 | #else
> 310 | #error unsupported Swift architecture
      |  ^ unsupported Swift architecture
  311 | #endif
  312 | 

› Compiling react-native-maps Pods/react-native-google-maps » AIRGoogleMapCircleManager.m

    Run script build phase 'Start Packager' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'TilleliDev' from project 'TilleliDev')

    Run script build phase 'Bundle React Native code and images' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'TilleliDev' from project 'TilleliDev')

    Run script build phase '[CP-User] [RNFB] Core Configuration' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'TilleliDev' from project 'TilleliDev')

    Run script build phase '[CP-User] [RNFB] Crashlytics Configuration' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'TilleliDev' from project 'TilleliDev')

    Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'fmt' from project 'Pods')

    Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'ReactCommon' from project 'Pods')

    Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'React-utils' from project 'Pods')

    Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'React-runtimescheduler' from project 'Pods')

▸ ** BUILD FAILED **

▸ The following build commands failed:

▸ 	CompileC /Users/expo/workingdir/build/ios/build/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-google-maps.build/Objects-normal/arm64/AIRGoogleMapHeatmapManager.o /Users/expo/workingdir/build/node_modules/react-native-maps/ios/AirGoogleMaps/AIRGoogleMapHeatmapManager.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-google-maps' from project 'Pods')

▸ (1 failure)

2023-07-12 14:32:18.575 xcodebuild[5352:16454] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)

** BUILD FAILED **



The following build commands failed:

	CompileC /Users/expo/workingdir/build/ios/build/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-google-maps.build/Objects-normal/arm64/AIRGoogleMapHeatmapManager.o /Users/expo/workingdir/build/node_modules/react-native-maps/ios/AirGoogleMaps/AIRGoogleMapHeatmapManager.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-google-maps' from project 'Pods')

(1 failure)

Exit status: 65


+-------------+-------------------------+

|           Build environment           |

+-------------+-------------------------+

| xcode_path  | /Applications/Xcode.app |

| gym_version | 2.213.0                 |

| sdk         | iPhoneOS16.4.sdk        |

+-------------+-------------------------+

Reproducible sample code

import MapView from 'react-native-maps';

export default function App() {
  return (
    <MapView
      style={{flex: 1}}
      initialRegion={{
        latitude: 42,
        longitude: 30,
        latitudeDelta: 1,
        longitudeDelta: 1,
      }}
    />
  );
}

Steps to reproduce

Build the app

Expected result

Successful build

Actual result

Fail IOS build

React Native Maps Version

1.7.1

What platforms are you seeing the problem on?

iOS (Google Maps)

React Native Version

0.72.3

What version of Expo are you using?

SDK 49

Device(s)

null

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 4
  • Comments: 20

Most upvoted comments

Try this plugin, It may resolve.

// react-native-maps-plugin.js
const fs = require("fs");
const path = require("path");
const { withDangerousMod } = require("expo/config-plugins");
const generateCode = require("@expo/config-plugins/build/utils/generateCode");

// https://github.com/react-native-maps/react-native-maps/issues/4793#issuecomment-1671269814
const googleMapsIosSiliconWorkaroundPodCode = `pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'`;

/** @type { import('expo/config-plugins').ConfigPlugin } */
const withPlugin = (expoConfig) => {
  return withDangerousMod(expoConfig, [
    "ios",
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        "Podfile"
      );

      const contents = fs.readFileSync(filePath, "utf-8");

      const addCode = generateCode.mergeContents({
        newSrc: googleMapsIosSiliconWorkaroundPodCode,
        tag: "withGoogleMapsIOSWorkaroundPlugin",
        anchor: /\s*get_default_flags\(\)/i,
        src: contents,
        comment: "#",
        offset: 2,
      });

      if (!addCode.didMerge) {
        console.warn(
          "WARNING: Couldn't add custom plugin Podfile code from app.plugin.js to the project's ios/Podfile."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withPlugin;
// app.json
"plugins": [
      "./react-native-maps-plugin",
    ],

As mentioned here : https://github.com/react-native-maps/react-native-maps/pull/4757#issuecomment-1604959747 https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md#enabling-google-maps

Same problem here.

I’m getting this error when I try to build a dev-client with this command:

npx eas build --profile development-simulator --platform ios

The development-simulator profile inside eas.json:

{
  "cli": {
    "version": ">= 0.34.0"
  },
  "build": {
    "development-simulator": {
      "developmentClient": true,
      "distribution": "internal",
      "ios": {
        "simulator": true
      }
    },
    "debug": {
      "android": {
        "buildType": "apk",
        "image": "latest"
      }
    },
    "production": {}
  }
}

Package versions:

"react-native-maps": "1.7.1"
"expo": "^49.0.0"
"react-native": "0.72.3"

Have the same without expo. “react-native-maps”: “1.7.1”

While building module 'GoogleMapsUtils' imported from /Users/.../Documents/Projects/.../node_modules/react-native-maps/ios/AirGoogleMaps/AIRGoogleMapHeatmap.h:7:
In file included from <module-includes>:2:
/Users/.../Library/Developer/Xcode/DerivedData/...-gakpmozuyejlgzbcqlqnauqzhrwl/Build/Products/Release-iphonesimulator/Google-Maps-iOS-Utils/GoogleMapsUtils.framework/Headers/GoogleMapsUtils-Swift.h:310:2: error: unsupported Swift architecture
#error unsupported Swift architecture
 ^
1 error generated.
In file included from /Users/.../Documents/Projects/.../node_modules/react-native-maps/ios/AirGoogleMaps/AIRGoogleMapHeatmapManager.m:8:
/Users/.../Documents/Projects/.../node_modules/react-native-maps/ios/AirGoogleMaps/AIRGoogleMapHeatmap.h:7:9: fatal error: could not build module 'GoogleMapsUtils'
#import "GMUHeatmapTileLayer.h"
 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

P.S.

My error was fixed after adding to Podfile before rn_maps_path

# The following line is only needed if building on an Apple silicon Mac without rosetta.
pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'

Try this plugin, It may resolve.

// react-native-maps-plugin.js
const fs = require("fs");
const path = require("path");
const { withDangerousMod } = require("expo/config-plugins");
const generateCode = require("@expo/config-plugins/build/utils/generateCode");

// https://github.com/react-native-maps/react-native-maps/issues/4793#issuecomment-1671269814
const googleMapsIosSiliconWorkaroundPodCode = `pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'`;

/** @type { import('expo/config-plugins').ConfigPlugin } */
const withPlugin = (expoConfig) => {
  return withDangerousMod(expoConfig, [
    "ios",
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        "Podfile"
      );

      const contents = fs.readFileSync(filePath, "utf-8");

      const addCode = generateCode.mergeContents({
        newSrc: googleMapsIosSiliconWorkaroundPodCode,
        tag: "withGoogleMapsIOSWorkaroundPlugin",
        anchor: /\s*get_default_flags\(\)/i,
        src: contents,
        comment: "#",
        offset: 2,
      });

      if (!addCode.didMerge) {
        console.warn(
          "WARNING: Couldn't add custom plugin Podfile code from app.plugin.js to the project's ios/Podfile."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withPlugin;
// app.json
"plugins": [
      "./react-native-maps-plugin",
    ],

As mentioned here : #4757 (comment) https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md#enabling-google-maps

This worked for me too thanks @SohelIslamImran

For folks who use expo sdk 50, it works without any expo plugin - you just need to use these versions:

 "react-native-maps": "1.10.0"
 "expo": "^50.0.0"

Try this plugin, It may resolve.

// react-native-maps-plugin.js
const fs = require("fs");
const path = require("path");
const { withDangerousMod } = require("expo/config-plugins");
const generateCode = require("@expo/config-plugins/build/utils/generateCode");

// https://github.com/react-native-maps/react-native-maps/issues/4793#issuecomment-1671269814
const googleMapsIosSiliconWorkaroundPodCode = `pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'`;

/** @type { import('expo/config-plugins').ConfigPlugin } */
const withPlugin = (expoConfig) => {
  return withDangerousMod(expoConfig, [
    "ios",
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        "Podfile"
      );

      const contents = fs.readFileSync(filePath, "utf-8");

      const addCode = generateCode.mergeContents({
        newSrc: googleMapsIosSiliconWorkaroundPodCode,
        tag: "withGoogleMapsIOSWorkaroundPlugin",
        anchor: /\s*get_default_flags\(\)/i,
        src: contents,
        comment: "#",
        offset: 2,
      });

      if (!addCode.didMerge) {
        console.warn(
          "WARNING: Couldn't add custom plugin Podfile code from app.plugin.js to the project's ios/Podfile."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withPlugin;
// app.json
"plugins": [
      "./react-native-maps-plugin",
    ],

As mentioned here : #4757 (comment) https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md#enabling-google-maps

This works for me!, thanks @SohelIslamImran

@LucasLFurini But this happens with the build in expo, when I run the command eas build --platform ios we get this error, in these described versions. I can’t imagine how the simulator on mac could interfere.

To select the version with Rosetta you need to click here: image There will be Iphone 14 Pro (Rosetta)

Updated Workaround Adding on to @chanphiromsok’s reply

Was stuck on this for a few hours until I found this thread. This workaround is not specific to react-native-maps though. It should ideally be in the expo’s repo.

💻 Machine: MacBook Pro M1 🙅 XCode Version: 15.3 (since there is a slight difference in XCode UI) 🫛 Pod Version: 1.15.2 📦 Package Versions:

"expo": "~50.0.14",
"react-native": "0.73.6"

Steps

  1. From your project’s directory terminal, open up the ios folder’s xcworkspace in XCode by running the following, replacing <your_app_name> to whatever is populate in your ios folder. This step will open up XCode at the correct project directory.
open ios/<your_app_name>.xcworkspace
  1. Get all the possible destinations to build to by following this from Menu Bar: Product > Destination > Show All Run Destinations 1-show-run-destinations

  2. Now, you should be able to see the iOS Simulators with (Rosetta) support. Select the simulator with Rosetta for your project. 2-select-rosetta-support

  3. Ensure the top of XCode shows that you are building your app for that specific simulator with (Rosetta), then click on the ▶️ button to build. 3-build

  4. In your project, run npm start from the project root (not ios folder) to check your expo server is running of course.


Hope this helps! 🍻

For folks who use expo sdk 50, it works without any expo plugin - you just need to use these versions:

 "react-native-maps": "1.10.0"
 "expo": "^50.0.0"

i can confirm! expo will update doctor to recommend 1.10.0 for SDK 50

@chanphiromsok

It works great) Thank you and your colleague.

One of my Team tell me to do this for M1 user and it works and config plugin for me also works

Screenshot 2024-01-05 at 1 55 23 in the afternoon

Try this plugin, It may resolve.

// react-native-maps-plugin.js
const fs = require("fs");
const path = require("path");
const { withDangerousMod } = require("expo/config-plugins");
const generateCode = require("@expo/config-plugins/build/utils/generateCode");

// https://github.com/react-native-maps/react-native-maps/issues/4793#issuecomment-1671269814
const googleMapsIosSiliconWorkaroundPodCode = `pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'`;

/** @type { import('expo/config-plugins').ConfigPlugin } */
const withPlugin = (expoConfig) => {
  return withDangerousMod(expoConfig, [
    "ios",
    async (config) => {
      const filePath = path.join(
        config.modRequest.platformProjectRoot,
        "Podfile"
      );

      const contents = fs.readFileSync(filePath, "utf-8");

      const addCode = generateCode.mergeContents({
        newSrc: googleMapsIosSiliconWorkaroundPodCode,
        tag: "withGoogleMapsIOSWorkaroundPlugin",
        anchor: /\s*get_default_flags\(\)/i,
        src: contents,
        comment: "#",
        offset: 2,
      });

      if (!addCode.didMerge) {
        console.warn(
          "WARNING: Couldn't add custom plugin Podfile code from app.plugin.js to the project's ios/Podfile."
        );
        return config;
      }

      fs.writeFileSync(filePath, addCode.contents);

      return config;
    },
  ]);
};

module.exports = withPlugin;
// app.json
"plugins": [
      "./react-native-maps-plugin",
    ],

As mentioned here : #4757 (comment) https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md#enabling-google-maps

pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'

Thank you so much! Quick solution 🚀

Looking into figuring out how to get the logs from xcode now.

@ml242, there should be a link at the bottom of the build page to access the Xcode logs

Also having build issues with RNM 1.7.1 and Expo 48.

Looking into figuring out how to get the logs from xcode now.

Moving RNM back to 1.3 fixed it but causes other issues with the default pins rendering.

completely unhelpful:

Thread 2 name: Thread 2 Crashed: 0 libsystem_kernel.dylib 0x00000001f0cfe558 __pthread_kill + 8 (:-1) 1 libsystem_pthread.dylib 0x0000000211b43118 pthread_kill + 268 (pthread.c:1670) 2 libsystem_c.dylib 0x00000001b92e3178 abort + 180 (abort.c:118) 3 libc++abi.dylib 0x0000000211a81bf8 abort_message + 132 (:-1) 4 libc++abi.dylib 0x0000000211a71444 demangling_terminate_handler() + 348 (:-1) 5 libobjc.A.dylib 0x00000001aae5dea4 _objc_terminate() + 144 (objc-exception.mm:498) 6 libc++abi.dylib 0x0000000211a80fbc std::__terminate(void (*)()) + 16 (:-1) 7 libc++abi.dylib 0x0000000211a80f60 std::terminate() + 56 (:-1) 8 libdispatch.dylib 0x00000001b9282ec0 _dispatch_client_callout + 40 (object.m:563) 9 libdispatch.dylib 0x00000001b928a534 _dispatch_lane_serial_drain + 668 (queue.c:3885) 10 libdispatch.dylib 0x00000001b928b0a4 _dispatch_lane_invoke + 384 (queue.c:3976) 11 libdispatch.dylib 0x00000001b9295cdc _dispatch_workloop_worker_thread + 648 (queue.c:6507) 12 libsystem_pthread.dylib 0x0000000211b3cddc _pthread_wqthread + 288 (pthread.c:2618) 13 libsystem_pthread.dylib 0x0000000211b3cb7c start_wqthread + 8 (:-1)