Command xcodebuild failed with exit code 65 - NativeScript - ios

I have a NativeScript project that I am running on my desktop. When I clone it to my laptop, I get the following error message after I run tns run ios --emulator:
Build settings from command line:
ARCHS = i386 x86_64
CODE_SIGN_IDENTITY =
CONFIGURATION_BUILD_DIR = /mypath/exampleproject/platforms/ios/build/emulator
ONLY_ACTIVE_ARCH = NO
SDKROOT = iphonesimulator10.3
SHARED_PRECOMPS_DIR = /mypath/exampleproject/platforms/ios/build/sharedpch
VALID_ARCHS = i386 x86_64
xcodebuild: error: The workspace named "exampleproject" does not contain a scheme named "exampleproject". The "-list" option can be used to find the names of the schemes in the workspace.
Command xcodebuild failed with exit code 65
Could it be a naming thing? I started out naming the project one thing, then changed it, but changed back to the original because of the issues. I cloned it onto my Desktop into a different folder, and ran tns run ios --emulator and got the same issue, so it's definitely not a hardware problem.
I've been reviewing answers to the following problem here, but it seems like the solution was already integrated into the version of NativeScript that I am running.
Laptop:
NativeScript version 2.5.4
OS Version Sierra 10.12.1

Ok, so it's the simplest solution in the world:
The project was originally named Exampleproject (first letter capitalized), I pushed the code (so the project on git is exampleproject, and when I cloned it the resulting folder is exampleproject, so instead I just have to clone it into Exampleproject:
git clone https://example#bitbucket.org/myprojects/exampleproject.git Exampleproject

For reference, I'm building from the VS Code terminal in a NativeScript 6.5 project and using the command "tns run ios --force".
I got this same error, when yesterday it built fine but today it errors. Then I decided to open Xcode and realized it wanted to update, and that's due to my Mac updating over night. Once I updated Xcode the build and run worked fine.
Fissh

Related

react-native build failing due to PhaseScriptExecution error

Environment
Mac OS X Version 12.1 (Apple M1 chip)
Xcode Version 13.2.1
Simulator Version 13.2 (972.2)
react-native-cli 7.0.3
node v18.4.0
The Issue
This is my first time working on developing an app using React Native. I am trying to run my React Native project on Xcode's simulator, using npx react-native run-ios. However, I am encountering this error message.
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening MCompass.xcworkspace.
Command line invocation:
/Users/brx/Downloads/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MCompass.xcworkspace -configuration Debug -scheme MCompass -destination id=DC3C75E6-19FD-4B80-87B1-62BF6404ED20
...
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/brx/src/projects/test/MCompass/ios/build/MCompass.build/Debug-iphonesimulator/MCompass.build/Script-00DD1BFF1BD5951E006B06BC.sh (in target 'MCompass' from project 'MCompass')
(1 failure)
Between the first error message and ** BUILD FAILED **, there were many lines of output listing exports.
I've installed dependencies using both yarn and npm. I've also looked at several other threads with this same issue, but none of the solutions (such as having only one version of nvm or running react-native upgrade) have been successful. Does anyone have any tips?
I had my root folder name "REACT NATIVE", changing it to "REACT_NATIVE" fixed the error as the folder that contains your react native project cannot contain white spaces.
The second solution would be running Xcode with rosetta. This is only applicable for M1 chip macbooks as there are few times Xcode projects fail because of this reason. Please refer to below link for reference:
https://penny-huang.medium.com/xcode-how-to-run-ios-simulator-on-m1-mac-66101b9fccd8

Xcode build fail on m1 chip

I'm trying to build a flutter app in Xcode on my Mac (m1 chip). But it fails due to below error.
Command PhaseScriptExecution failed with a nonzero exit code
As the warning says, my guess is that the issue occur while it trying to build it for arm64. But I have already add aram64 in excluded arch list.
I'm running Xcode on rosetta & also its build successfully on iOS 12 & iOS 14 simulators but the issue comes when I try to build it on real device with iOS 14.3 and also in archive build. What I'm doing wrong here?
Command PhaseScriptExecution failed with a nonzero exit code
The error you've encountered could be due to many reasons. It would be better if you can isolate the issue by performing the workaround that was discussed in this GitHub post.
Sent here from:
#76302
So I was having this issue after trying every flutter clean / podfile
delete sequence under the sun. Turns out my flutter got stuck at an
old version that is evidently not compatible with the latest version
of xcode or something (who really knows).
So I had to run
flutter upgrade --force
flutter clean
delete Podfile and Podfile.lock
run pub get
re-run my build_runner stuff (you may not have this)
flutter run (to run the app on device with all this new stuff / regenerate podfile stuff)
Then I was finally able to get my ios archive to build with flutter build ipa.
FYI: The flutter upgrade command pushed me from 2.0.5 -> 2.2.1 on
the stable channel. Prior to this, I was just getting generic warnings
of Command PhaseScriptExecution failed with a nonzero exit code.

Flutter: App is not x86_64. Running lipo -info:, App is architecture: arm64

I built my project on a real iOS device and it was working fine but when I tried to run it on the simulator it gives me the below architecture error. Also, I have faced the same issue earlier and that time App was working fine for simulator and gave me the same error for the real device.
Non-fat binary /Users/dhavalkansara/Library/Developer/Xcode/DerivedData/Runner-dwtuugielmxutoatpwezjbbcemuy/Build/Products/Debug-iphonesimulator/Runner.app/Frameworks/App.framework/App is not x86_64. Running lipo -info:
Non-fat file: /Users/dhavalkansara/Library/Developer/Xcode/DerivedData/Runner-dwtuugielmxutoatpwezjbbcemuy/Build/Products/Debug-iphonesimulator/Runner.app/Frameworks/App.framework/App is architecture: arm64
Command /bin/sh failed with exit code 1
I tried multiple solutions available #25260, #22749, #23917 on GitHub but still facing the same issue.
Your project probably has a run-script build phase for removing simulator architecture (in order to avoid AppStore rejection).
This script is usually a variation of this one: http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/
If the project build runs such a script, the build might fail when the destination is a simulator and not a real device.
My suggestion: Find this script (in Target Settings -> Build Phases) and enclose it in:
if [[ "$CONFIGURATION" == "Release" ]]; then
[Put original script here]
fi
I am not sure about the actual reason behind this issue. I just deleted the project and Xcode's derived data from my system and then recloned the same project again and it was working fine in both simulator and real device.
So as per my experience, I am assuming that while running the build in release mode using flutter run --release command or by changing Xcode > Edit scheme > Run > Release there might be some changes within the default project settings and because of that I was getting " Could not build the precompiled application for the device." this error.
I have also raised an issue on GitHub for the same.

Error building app for ios in phonegap (for android is working fine)

I am developing an app with phonegap and I have always been testing the app using the android simulator and I have not had any problems, but I can not get it to work for iOS.
I'm working on a Mac OS mavericks and have installed Xcode.
When I run the command "phonegap run ios", I get the following:
[phonegap] detecting iOS SDK environment...
[phonegap] using the local environment
[phonegap] compiling iOS...
Build settings from command line:
ARCHS = i386
CONFIGURATION_BUILD_DIR = /Users/usuario/Desktop/desarrolloapp/nombreapp/platforms/ios/build/emulator
SDKROOT = iphonesimulator7.1
VALID_ARCHS = i386
xcodebuild: error: The project ‘NombreApp.xcodeproj’ does not contain a target named ‘NombreApp’.
[error] /Users/usuario/Desktop/desarrolloapp/nombreapp/platforms/ios/cordova/build: Command failed with exit code 65
Any idea about what's going on?
EDIT: I solve this doing:
Remove ios folder from platforms.
Run again (phonegap run ios).
Install ios-sim with command sudo npm install -g ios-sim.
All worked fine!
A lot of thanks.
Best regards.
Manually create target with name NombreApp in Xcode as given this link :
->
How to create or define a new target in a custom Xcode project template
Regards,

Cordova command-line build fails in /tmp on Mac

I get a linker error building a brand-new PhoneGap app from the command line. It creates a bunch of files, and if I open the created .xcodeproj in Xcode, it builds just fine. So what's wrong with my command-line environment?
$ phonegap create /tmp/buildtest-ios
$ cd /tmp/buildtest-ios
$ phonegap -V build ios
[phonegap] detecting iOS SDK environment...
[phonegap] Checking iOS requirements...
[phonegap] using the local environment
[phonegap] compiling iOS...
[phonegap] Generating config.xml from defaults for platform "ios"
[phonegap] Compiling app on platform "ios" via command "/private/tmp/buildtest-ios/platforms/ios/cordova/build"
[error] An error occurred while building the ios project.** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Ld /private/tmp/buildtest-ios/platforms/ios/build/emulator/HelloWorld.app/HelloWorld normal i386
(1 failure)
If I run the offending Ld command myself from the command line, I get "file not found". Does that mean the compiler failed and the linker error is just a red herring?
This is PhoneGap 3.3.0-0.18.0 on Mac OS X 10.9. I can create and build an Android app with this installation, no trouble. I get the exact same behavior if I use cordova directly. I've tried it on two Macs with the same symptom.
I finally discovered the answer using the cordova command-line tools. Cordova has a -d flag which is way more verbose than PhoneGap's -V flag. The linker was failing with a bunch of errors like
duplicate symbol _OBJC_METACLASS_$_CDVTimer in:
/private/tmp/buildtest-ios/platforms/ios/build/emulator/libCordova.a(CDVTimer.o)
/tmp/buildtest-ios/platforms/ios/build/emulator/libCordova.a(CDVTimer.o)
Note that /tmp on Mac is a symlink to /private/tmp, so these are pointing to the same file. No wonder they're duplicate symbols! So why is it trying to include the same file twice?
I tried creating a new test project in an empty folder /private/my-new-tmp2/buildtest-ios. Building it failed with the same error. So apparently something is weird with Cordova's iOS projects and the Ld linker in the /private directory on Mac OS X 10.9, and I'm the only person who's ever tried this. (As I said, building for Android works fine.)
In case someone else ever runs into the same problem, the solution is to build the project in /Users/me/some/directory rather than anywhere in /tmp or /private. Problem solved.
This may be because your framework references are corrupted or point to nowhere. In the left of XCode under 'Frameworks' and 'Resources' try re-adding anything you added yourself. Chances are with Cordova its a plugin SDK you are using that has been updated or deleted.
I had a similar issue while placing my project under /var/www/PROJECT on mac. I was getting the duplicate errors along with "../cordova/build: Command failed with exit code 65".
I was getting the duplicate errors because /var/www/ is also /private/var/www/
Solution was to move my project as described above to /Users/username/some-other-dir/...
I then ran phonegap run ios and all worked!

Resources