cordova-ios icon indicating copy to clipboard operation
cordova-ios copied to clipboard

Macbook M1 : App won't build on simulator but works fine on device

Open bhandaribhuminpfizer opened this issue 3 years ago • 6 comments

Problem

App won't build on the simulator but works fine on the device

After adding the below setting for a run on the simulator will cause the issue:


Xcode -> Target Project -> Build Setting -> Excluded Architectures > "arm64"

Xcode -> Pod Target -> Build Setting -> Excluded Architectures > "arm64"

ionic info


Ionic:

   Ionic CLI          : 6.13.1 (/Users/bhuminbhandari/.nvm/versions/node/v10.17.0/lib/node_modules/@ionic/cli)
   Ionic Framework    : ionic-angular 3.9.10
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0, ios 6.2.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 15 other plugins)

Utility:

   cordova-res : 0.15.3
   native-run  : 1.3.0

System:

   Android SDK Tools : 26.1.1 (/Users/bhuminbhandari/Library/Android/sdk)
   ios-deploy        : 1.11.4
   NodeJS            : v10.17.0 (/Users/bhuminbhandari/.nvm/versions/node/v10.17.0/bin/node)
   npm               : 6.11.3
   OS                : macOS Big Sur

Xcode v12.5 (12E262) Xcode Error:

Undefined symbol: _CDVPageDidLoadNotification

Undefined symbol: _CDVPluginResetNotification

Undefined symbol: _OBJC_CLASS_$_CDVWebViewProcessPoolFactory

Undefined symbol: _CDVPluginHandleOpenURLNotification

Undefined symbol: _OBJC_METACLASS_$_CDVViewController

Undefined symbol: _OBJC_CLASS_$_CDVPlugin

Undefined symbol: _OBJC_METACLASS_$_CDVPlugin

Undefined symbol: _OBJC_CLASS_$_CDVViewController

Undefined symbol: _OBJC_METACLASS_$_CDVCommandDelegateImpl

Undefined symbol: _OBJC_CLASS_$_CDVPluginResult

Undefined symbol: _OBJC_METACLASS_$_CDVAppDelegate

Undefined symbol: _OBJC_CLASS_$_CDVCommandDelegateImpl

Undefined symbol: _OBJC_CLASS_$_CDVCommandQueue

Undefined symbol: _OBJC_METACLASS_$_CDVCommandQueue

Undefined symbol: _OBJC_CLASS_$_CDVInvokedUrlCommand

Undefined symbol: _OBJC_CLASS_$_CDVAppDelegate


Screenshot 2021-05-24 at 11 17 24 AM

Xcode Build Setting

Screenshot 2021-05-24 at 11 19 43 AM

bhandaribhuminpfizer avatar May 24 '21 05:05 bhandaribhuminpfizer

Same here

chorauoc avatar Jun 26 '21 08:06 chorauoc

I found a workaround, close xcode, and then open it with Rosetta.

lalmanzar avatar Jul 12 '21 13:07 lalmanzar

i have the same problem in new apple chip and xcode 13 (Configured for open with Rosetta) image

I found that by cordova run ios it works instead of running by xcode, it can build, but it probably doesn't load the same classes, because the application is all Visually Unconfigured, down here the difference between the two

built with cordova run -------------------------------------------- How it should be:

ecd182b0-8ee3-4666-a980-be595fcbd506 )

eddskt avatar Sep 29 '21 14:09 eddskt

@bhandaribhuminpfizer Why did you change any settings in Xcode. It works fine for me on a new Cordova project. Please make sure you use the latest version of the cordova-ios platform.

NiklasMerz avatar Oct 08 '21 20:10 NiklasMerz

@NiklasMerz As I mentioned in the previous message ionic info I'm using the latest cordova-ios but I think this could be a new Mac M1 processor. @eddskt I agreed the project works in simulator <= 13.7

bhandaribhuminpfizer avatar Oct 11 '21 03:10 bhandaribhuminpfizer

Exact same issue on M1 mac. Cordova iOS 6.2.0... Solution.

Running xcode with Rosetta is a workaround. However I did find a solution.

I had already set my xcode targets to Excluded Architecture for "Any iOS Simulator SDK" = arm64

But turns out you also have to add for CordovaLib sub project. Once I added there, the error is gone and simulator works fine from xcode or ionic cordova emulate ...

sjdrew avatar Dec 30 '21 19:12 sjdrew

@sjdrew Can you please tell me how to add CordovaLib sub project xcode I cant find it

bhutada1992 avatar Oct 21 '22 14:10 bhutada1992

I did not have to add, CordovaLib was part of Cordova project, its just that I also had to set the exclude on that folder in the Project tree otherwise this library still had the wrong architecture for simulator.

sjdrew avatar Oct 21 '22 18:10 sjdrew

I did not have to add, CordovaLib was part of Cordova project, its just that I also had to set the exclude on that folder in the Project tree otherwise this library still had the wrong architecture for simulator.

How did you exclude the cordova

NullVoidKage avatar Jun 20 '23 13:06 NullVoidKage

App won't build on the simulator but works fine on the device

After adding the below setting for a run on the simulator will cause the issue:

Xcode -> Target Project -> Build Setting -> Excluded Architectures > "arm64"

Xcode -> Pod Target -> Build Setting -> Excluded Architectures > "arm64"

M1 IS an Arm64 architecture chip. If you're excluding arm64 for simulator, then naturally the simulator won't be able to run on M1 macs natively. I'm not understanding the rationale is for excluding architectures. Nik asked this question above and no one has actually gave him an answer.

When building for a physical device, ARM64 should be the only architecture because that is the only chip available on modern devices. For simulators, there are two possible architectures that the simulator may run on: 1) x86_64 (Intel macs), and 2) ARM64 (M-chip macs). You'll going to want to at least build for your current architecture, which is the default setting.

If you're a library author providing native frameworks, you'll probably want to build both an x86_64 framework and a arm64 framework for your simulator variant build and package them into a xcframework bundle along with your iOS arm64 build.

If you're having trouble running your app on a simulator with M1, it is possible that you have a plugin that is shipping native frameworks that lacks an arm64 build. There are plenty of old frameworks out there that predates M1 macs (even today) so they don't have an arm64 build bundled in their framework for the simulator. The cordova-plugin-googlemaps plugin is one example of this (they are still using Google Maps SDK v3 for iOS, when v7.3.0 is required for m1 support).

I'm closing this issue because this doesn't appear to describe a bug with Cordova, rather it appears to be a case of misunderstanding XCode configuration and raising an issue due to misconfiguration of native settings.

If you have any questions, then I'd recommend asking for support at our GitHub Discussions. If you believe there is still a bug with Cordova framework on M1 macs, then I'd recommend first making sure it can be reproduced in a minimal reproduction app, preferably in the hello world template app to clearly demonstrate the issue (rather than an issue of third-party code). If that can be done, then please do raise a new issue.

breautek avatar Jun 20 '23 13:06 breautek