Cordova command-line build fails in /tmp on Mac - ios

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!

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

Command xcodebuild failed with exit code 65 - NativeScript

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

Xcode - clang failed with exit code 1. Plugin cause?

I'm getting an odd error in Xcode when I try to Archive my app.
I'm using Ionic and the Ionic CLI tools. The app has been built for Android and is in beta on the Google Play store.
In Xcode I get this error:
clang: error: no such file or directory: '/Users/SubjectiveEffect/myApp/platforms/ios/CardsApp/Plugins/de.appplant.cordova.plugin.email-composer/APPEmailComposer.m'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
So it looks like there is some error with the de.appplant email plugin. The email plugin works in Android but it doesn't work in Ionic View on iOS. I wasn't sure if this was that the plugin isn't Ionic View compatible or not.
Anyone have any ideas?
Upate:
I uninstalled this plugin and I now get the same error, but from a different plugin!
clang: error: no such file or directory: '/Users/SubjectiveEffect/myApp/platforms/ios/CardsApp/Plugins/com.danielcwilson.plugins.googleanalytics/UniversalAnalyticsPlugin.m'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
So I'm pretty sure this is a plugin problem.
Anyone have any idea why or how I can fix it? I'm installing from the command line on a Mac with the standard cordova commands as seen on ngCordova.
edit: To be clear - those folders do not, indeed, exist. The plugins work fine in Android though...
Your error is quite strange, probably something happened to the structure folders..
I would try doing something like this:
Before doing this test make a backup copy of platforms/ios.
cd my-folder-app/
ionic platform remove ios
ionic platform add ios
Now should need to copy from backup and paste for example the icons, splash screens to the fresh platforms/ios folder and re-apply some eventual changes that you did.
ionic build ios
And then open xcode:
Run the app on emulator or device to test if works
Disconnect the device
Select the schema and iOS Device
If you need configure the schema, first you need to edit it:
Select Archive from the left panel, and from the right there is Build Configuration: select Release if you want publish the app or Debug if you want install the app on a test device. And click Close.
From the top menu: Product > Archive
Good luck!
UPDATE:
To be sure that your errors not depends to the ionic project make this test please:
cd projects-folder/
ionic start myTestApp tabs
cd myTestApp/
ionic platform add ios
ionic build ios
And now follow the same steps on xcode to archive the app.
I never really found out what was happening.
What I did was remove the iOS platform and re-add it. This just created more errors although for some reason the correct folders were there. I also then found my Android build wouldn't work.
I removed everything and re-added it all, updating Ionic too.
Then XCode would open but freeze. Hard freeze. The only way to quit it was to force close the Mac. I even uninstalled XCode and re-installed it. Same thing.
Finally I used the command line to erase all presets in XCode so it would open fresh without any projects loaded. Now it works, and the Android version seems to be working too.
I've no idea where the error started and so I can't rightly tag anyone as correct as that would be misleading. The solution: cleans and burn, start again. :)

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,

calabash-ios setup clang: error: no such file or directory 'UIKit'

I am currently porting an existing mobile web application to IOS using PhoneGap. I wanted to test the IOS application using Frank/Calabash. I am currently facing the same issue using either of the test frameworks. For both Frank and Calabash when I try to build the app I get the following error
clang: error: no such file or directory: 'UIKit'
clang: error: no such file or directory: 'AVFoundation'
clang: error: no such file or directory: 'CoreMedia'
In fact these frameworks do exist in the iPhoneOS6.1 SDK.
To narrow down the problem I created a demo HelloWorld PhoneGap application and tried Frank and Calabash but got the same error.
Demo app is available at https://github.com/jmadan/phonegap-hello.git
XCODE version used = 4.6.3
Cordova version = 3.0.3
IOS version = 10.8.4
Has anyone else faced the same issue??? If Yes then any suggestions?
We had the same error using calabash and frank. To fix this it was a bit hit and miss but we found that running the cordova build again to create the whole ios app fresh eg. no frank or calabash stuff in there, then putting only calabash into it worked and was able to compile and run tests.
How ever you may later run into issues with CDVViewController.h not being found or you could find that it works but if your trying to automate your tests through an ant script etc. then it will complain about not running the cucumber command in the correct place where cordova compiled your .app file so beware of this. You may need to do some clever file copying and edit your APP_BUNDLE_PATH when you get to this point.
Hope that helps...

Resources