Table of contents

Xcode - Undefined symbols for architecture i386, in release mode

Objective C Mar 28, 2021 Viewed 1.1K Comments 0

Issue

In Xcode, I try to run the target of simulator in release mode, the following error appears when building the project:

ld: warning: ignoring file /develop/O2O/ios/Pods/AMapFoundation/AMapFoundationKit.framework/AMapFoundationKit, missing required architecture i386 in file /develop/O2O/ios/Pods/AMapFoundation/AMapFoundationKit.framework/AMapFoundationKit (3 slices)
ld: warning: ignoring file /develop/O2O/ios/Pods/AMapSearch/AMapSearchKit.framework/AMapSearchKit, missing required architecture i386 in file /develop/O2O/ios/Pods/AMapSearch/AMapSearchKit.framework/AMapSearchKit (3 slices)
ld: warning: ignoring file /develop/O2O/ios/Pods/AMap3DMap/MAMapKit.framework/MAMapKit, missing required architecture i386 in file /develop/O2O/ios/Pods/AMap3DMap/MAMapKit.framework/MAMapKit (3 slices)
ld: warning: could not create compact unwind for _DES_read_password: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _DES_read_2passwords: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _RAND_load_file: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _RAND_write_file: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _ERR_print_errors_cb: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _ERR_print_errors: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _PEM_SealUpdate: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _PEM_X509_INFO_write_bio: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _PEM_read_bio_PrivateKey: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _process_pci_value: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _PKCS7_verify: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _PKCS7_decrypt: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _read_string_inner: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _pkey_GOST01cp_encrypt: stack subl instruction is too different from dwarf stack size
ld: warning: could not create compact unwind for _pkey_GOST01cp_decrypt: stack subl instruction is too different from dwarf stack size
Undefined symbols for architecture i386:
  "_OBJC_METACLASS_$_AMapRequestReformer", referenced from:
      _OBJC_METACLASS_$_AMapLocationUploadRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
      _OBJC_METACLASS_$_AMapLocationUploadSwitchRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_METACLASS_$_AMapRESTRequestReformer", referenced from:
      _OBJC_METACLASS_$_AMapLocationDistrictRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
      _OBJC_METACLASS_$_AMapLocationPOIKeywordsRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
      _OBJC_METACLASS_$_AMapLocationPOIAroundRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_AMapCoordinateConvert", referenced from:
      _AMapLocationCoordinateConvert in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapAnalyticsManager", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapFoundationUtility", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapFoundationCompression", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_MAAnnotationView", referenced from:
      objc-class-ref in RCTAMap3DManager.o
  "_AMapLogVersion30", referenced from:
      -[AMapReGeocodeManager requestReGeocodeInfoWithCoordinate:language:timeout:handler:] in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_MACircleRenderer", referenced from:
      objc-class-ref in RCTAMap3DManager.o
  "_AMapAuthUpdateNotification", referenced from:
      -[AMapLocationManager init] in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_AMapAuthKeyManifest", referenced from:
      -[AMapLocationManager handleCloudConfigs:] in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_MAPolylineRenderer", referenced from:
      objc-class-ref in RCTAMap3DManager.o
  "_AMapRequestHttpMethodPost", referenced from:
      -[AMapLocationDistrictRequestReformer method] in AMapLocationKit(AMapLocationKit-i386-master.o)
      -[AMapLocationPOIKeywordsRequestReformer method] in AMapLocationKit(AMapLocationKit-i386-master.o)
      -[AMapLocationPOIAroundRequestReformer method] in AMapLocationKit(AMapLocationKit-i386-master.o)
      -[AMapLocationUploadRequestReformer method] in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapServicesConfig", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_METACLASS_$_MAMultiPolyline", referenced from:
      _OBJC_METACLASS_$_CustomMAMultiPolyline in CustomMAMultiPolyline.o
  "_OBJC_METACLASS_$_MAPointAnnotation", referenced from:
      _OBJC_METACLASS_$_MANaviAnnotation in MANaviAnnotation.o
      _OBJC_METACLASS_$_MyMAPointAnnotation in MyMAPointAnnotation.o
  "_OBJC_CLASS_$_AMapReGeocodeSearchRequest", referenced from:
      objc-class-ref in RCTAMapManager.o
  "_OBJC_CLASS_$_AMapRESTRequestReformer", referenced from:
      _OBJC_CLASS_$_AMapLocationDistrictRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
      _OBJC_CLASS_$_AMapLocationPOIKeywordsRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
      _OBJC_CLASS_$_AMapLocationPOIAroundRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapAnalyticsRequestReformer", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_kAMapNetworkReachabilityChangedNotification", referenced from:
      -[AMapLocationUploadManagerOld init] in AMapLocationKit(AMapLocationKit-i386-master.o)
      -[AMapLocationUploadManager registerNotificationObservers] in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapPOIKeywordsSearchRequest", referenced from:
      objc-class-ref in RCTAMapManager.o
  "_OBJC_CLASS_$_AMapRidingRouteSearchRequest", referenced from:
      objc-class-ref in RCTAMap3DManager.o
  "_OBJC_CLASS_$_AMapWeatherSearchRequest", referenced from:
      objc-class-ref in RCTAMapWeather.o
  "_MAMapRectZero", referenced from:
      +[CommonUtility mapRectUnion:count:] in CommonUtility.o
      +[CommonUtility mapRectForOverlays:] in CommonUtility.o
      +[CommonUtility minMapRectForMapPoints:count:] in CommonUtility.o
      +[CommonUtility minMapRectForAnnotations:] in CommonUtility.o
  "_OBJC_CLASS_$_AMapRequestReformer", referenced from:
      _OBJC_CLASS_$_AMapLocationUploadRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
      _OBJC_CLASS_$_AMapLocationUploadSwitchRequestReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_AMapRequestHttpMethodGet", referenced from:
      -[AMapLocationUploadSwitchRequestReformer method] in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_MAPolyline", referenced from:
      objc-class-ref in MANaviRoute.o
      objc-class-ref in CommonUtility.o
  "_OBJC_CLASS_$_MAPolygonRenderer", referenced from:
      objc-class-ref in RCTAMapManager.o
  "_OBJC_CLASS_$_AMapCloudConfig", referenced from:
      _OBJC_CLASS_$_AMapReGeocodeCacheConfig in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_MAPinAnnotationView", referenced from:
      objc-class-ref in RCTAMap3DManager.o
      objc-class-ref in RCTAMapManager.o
  "_OBJC_CLASS_$_MAMultiPolyline", referenced from:
      objc-class-ref in RCTAMap3DManager.o
      objc-class-ref in MANaviRoute.o
      _OBJC_CLASS_$_CustomMAMultiPolyline in CustomMAMultiPolyline.o
  "_OBJC_CLASS_$_AMapTMC", referenced from:
      objc-class-ref in MANaviRoute.o
  "_OBJC_CLASS_$_AMapGeoPoint", referenced from:
      objc-class-ref in RCTAMap3DManager.o
      objc-class-ref in RCTAMapManager.o
  "_OBJC_METACLASS_$_AMapCloudConfig", referenced from:
      _OBJC_METACLASS_$_AMapReGeocodeCacheConfig in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_METACLASS_$_AMapPostDataRequestReformer", referenced from:
      _OBJC_METACLASS_$_AMapLocationReGeocodeReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapSearchAPI", referenced from:
      objc-class-ref in RCTAMap3DManager.o
      objc-class-ref in RCTAMapWeather.o
      objc-class-ref in RCTAMapManager.o
  "_MAMapPointForCoordinate", referenced from:
      +[MANaviRoute replenishPolylineWithStart:end:] in MANaviRoute.o
      +[MANaviRoute calcPointWithStartPoint:endPoint:rate:] in MANaviRoute.o
      +[MANaviRoute calcDistanceBetweenCoor:andCoor:] in MANaviRoute.o
      ___42+[CommonUtility minMapRectForAnnotations:]_block_invoke in CommonUtility.o
      +[CommonUtility polylineHitTestWithCoordinate:mapView:polylinePoints:pointCount:lineWidth:] in CommonUtility.o
  "_OBJC_CLASS_$_AMapPOIAroundSearchRequest", referenced from:
      objc-class-ref in RCTAMapManager.o
  "_OBJC_METACLASS_$_MAMapView", referenced from:
      _OBJC_METACLASS_$_RCTAMap in RCTAMap.o
      _OBJC_METACLASS_$_RCTAMap3D in RCTAMap3D.o
  "_OBJC_CLASS_$_AMapFoundationReachability", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_MACoordinateForMapPoint", referenced from:
      ___35+[MANaviRoute naviRouteForWalking:]_block_invoke in MANaviRoute.o
      +[MANaviRoute naviRouteForSegment:index:] in MANaviRoute.o
      +[MANaviRoute calcPointWithStartPoint:endPoint:rate:] in MANaviRoute.o
      +[CommonUtility fetchPointPolylinePoints:mapView:index:selected:] in CommonUtility.o
  "_OBJC_CLASS_$_AMapNetworkManager", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapPostDataRequestReformer", referenced from:
      _OBJC_CLASS_$_AMapLocationReGeocodeReformer in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapFoundationAES", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapServices", referenced from:
      objc-class-ref in AppDelegate.o
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_AMapStatistics", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_OBJC_CLASS_$_MAPolygon", referenced from:
      objc-class-ref in RCTAMapManager.o
  "_OBJC_CLASS_$_MAPointAnnotation", referenced from:
      _OBJC_CLASS_$_MANaviAnnotation in MANaviAnnotation.o
      objc-class-ref in RCTAMapManager.o
      _OBJC_CLASS_$_MyMAPointAnnotation in MyMAPointAnnotation.o
  "_OBJC_CLASS_$_MAMultiColoredPolylineRenderer", referenced from:
      objc-class-ref in RCTAMap3DManager.o
  "_OBJC_CLASS_$_AMapCacheFileManager", referenced from:
      objc-class-ref in AMapLocationKit(AMapLocationKit-i386-master.o)
  "_MAMetersBetweenMapPoints", referenced from:
      +[MANaviRoute replenishPolylineWithStart:end:] in MANaviRoute.o
      +[MANaviRoute calcDistanceBetweenCoor:andCoor:] in MANaviRoute.o
      +[CommonUtility distanceToPoint:fromLineSegmentBetween:and:] in CommonUtility.o
  "_OBJC_CLASS_$_MAUserLocation", referenced from:
      objc-class-ref in RCTAMap3DManager.o
  "_OBJC_CLASS_$_MAMapView", referenced from:
      _OBJC_CLASS_$_RCTAMap in RCTAMap.o
      _OBJC_CLASS_$_RCTAMap3D in RCTAMap3D.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution

In Xcode, go to select: Project -> Build Settiongs -> Build active Architecture Only -> Release -> Yes.

setting Build active Architecture Only to Yes

1. Architectures

By default Architectures declared as Standard Architectures (arm64, armv7). Here you are going to specify the architectures your application is going to support. Here is the complete list of available architectures for both simulator and device specific build.

Go to Terminal and execute the following command from the project root directory.

xcodebuild -showBuildSettings -scheme <application name> -sdk iphonesimulator | grep ARCHS

Output:

ARCHS = i386 x86_64
ARCHS_STANDARD = i386 x86_64
ARCHS_STANDARD_32_64_BIT = i386 x86_64
ARCHS_STANDARD_32_BIT = i386
ARCHS_STANDARD_64_BIT = x86_64
ARCHS_STANDARD_INCLUDING_64_BIT = i386 x86_64
ARCHS_UNIVERSAL_IPHONE_OS = i386 x86_64
VALID_ARCHS = i386 x86_64

Now execute the following command to get a supported device specific architectures.

xcodebuild -showBuildSettings -scheme <application name> -sdk iphoneos | grep ARCHS

Output:

ARCHS = armv7 arm64
ARCHS_STANDARD = armv7 arm64
ARCHS_STANDARD_32_64_BIT = armv7 arm64
ARCHS_STANDARD_32_BIT = armv7
ARCHS_STANDARD_64_BIT = arm64
ARCHS_STANDARD_INCLUDING_64_BIT = armv7 arm64
ARCHS_UNIVERSAL_IPHONE_OS = armv7 arm64
VALID_ARCHS = arm64 arm64e armv7 armv7s

2. Build Active Architecture Only

This is the bool value which specifies the architectures Xcode is going to build for all the valid architectures or only for the one on which the app is currently being run on by looking to the target selected for.

BuildSetting is Simulator

By default in Debug mode Build Active Architecture Only value is Yes. What this mean that Xcode will build the architecture which is specified in the target. Refer the above image were Xcode will build the architecture which is compatible for Simulator.

For Release mode, the default value will be No. When we specify the value for Build Active Architecture Only as No, Xcode will build all the architectures which are specified under Valid Architectures.

If you are uploading build to Appstore make sure Xcode will generate only device specific architectures. We can’t upload simulator specific architectures. To summarise, architectures the Xcode will build is the list Valid Architectures intersected with Architectures.

Updated Mar 28, 2021