Xcodebuild stops with cordova ios project - ios

I'm trying to build and archive (in Release and Debug mode) an ios project generated with apache cordova 4.0.0, via command line tool xcodebuild
These commands work ok:
cordova platform add ios
cordova prepare ios
cordova build ios
The ios project generated by cordova has a scheme called iHogar. After that, when I try to launch this command on the console:
xcodebuild -scheme iHogar -sdk iphoneos -configuration Debug
CODE_SIGN_IDENTITY="iPhone Distribution: S-N-A L-C-A, S- CO-P-Ñ-A DE
SE-U-O- Y R--A-E-U-OS (xxxxxxx)"
It stops at the beginning of the execution, and does not continue. The value of param CODE_SIGN_IDENTITY is modified due to privacy reasons.
Here is the output of the command, through console:
Build settings from command line:
CODE_SIGN_IDENTITY = iPhone Distribution: S-N-A L-C-A, S- CO-P-Ñ-A DE SE-U-O- Y R--A-E-U-OS (xxxxxxx)
SDKROOT = iphoneos8.1
And stops there without finishing the command (it hangs) , only stops with crtl+C
The certificate is ok, and also the provisioning profile. If I open the project with Xcode (version 6.1) everything goes ok, I can build and archive it without problems, with the same certificate and provisioning profile.
Has anyone experienced this behavior?
Thanks in advance

I have resolved this issue. The problem was that the cordova generated ios project hasn't got schemas. Those are created the first time you open the project with XCode. When the app has been created by cordova, is only created with targets.
In this scenario, that the generated app cannot be opened with XCode with human interaction, is better to build the app with the target option, like this:
xcodebuild -xcconfig "cordova/build.xcconfig" -project "iHogar.xcodeproj" ARCHS="armv7 armv7" -target "iHogar" -configuration Debug -sdk iphoneos build VALID_ARCHS="armv7 armv7s" CONFIGURATION_BUILD_DIR="build/device"
It's important to have the certificate to sign the app installed in the keychain, and the related provisioning profile downloaded.

I know you got around your issue, but as this is quite recent, have you considered upgrading to Cordova 5.1.1. This will build and code sign the app without the need to go into XCode.

Related

Can't debug react-native project from Xcode, but It's running from console

Operating system macOS Mojave (version 10.14.5)
React Native Project 0.59.10
I'm working on one big react-native project. When I'm running react-native run-iso it runs emulator, and everything is perfect.
However, if I'll go into ios directory and try to build a project from Xcode, I'm getting the error. Library not found for -lBase64
I've tried:
Install different versions of Xcode
Remove some system files of xCode in the system. Reinstall Xcode
Tried run on Emulator and Physical device (Both failed)
Deleted build and pod directories out of ios directory
Meanwhile, this project is building from Xcode without a problem to my Colleague computer.
When I'm running through console I see:
info Building using
xcodebuild -workspace [name-of-the-app].xcworkspace -configuration Debug -scheme [name-of-the-app] -destination id=[some-long-id] -derivedDataPath build/[name-of-the-app
Maybe I have to define this parameter somewhere? Any solutions, any ideas?

xcodebuild produces different archive to Xcode 7.0.1

I am using xcodebuild to generate an archive from a workspace. I use the following command:
xcodebuild -workspace MyProject.xcworkspace -scheme "MyProject"
-destination generic/platform=iOS archive
-archivePath "../PathToArchive/MyProject.xcarchive
(I've spaced it out over multiple lines for readability)
This command generates a MyProject.xcarchive. However it generates a generic "Xcode Archive" rather than an "iOS App Archive." This cannot be submitted to the App Store.
If I archive the exact same workspace and scheme using Xcode.app version 7.0.1 (7A1001) instead of xcodebuild then I get an "iOS App Archive" which can be submitted to the App Store.
Inspecting the contents of these two xcarchives shows the main difference is the bundled Info.plist file. The one generated by Xcode.app contains an additional ApplicationProperties dict with versioning and signing details. The one generated by xcodebuild lacks these details in its Info.plist.
Copying the Xcode.app generated Info.plist into the xcarchive generated by xcodebuild "fixes" the archive, and it can be submitted to the App Store. This is not a solution however, as it means I cannot build on the command line.
Note that doing xcodebuild -version prints:
Xcode 7.0.1
Build version 7A1001
Edit: sometimes xcodebuild appears to generate a correct iOS App Archive instead of a Generic Archive. I'm not exactly sure why this happens. It's not consistent.
Are you using Cocoapods? If so try using the pre release version gem install cocoapods --pre . I had the issue because of a copy pods phase being somewhere it should not have been, please go through https://github.com/CocoaPods/CocoaPods/issues/4021 you should find a solution that fits you.
After a lot of frustration I have discovered the cause of xcodebuild producing incorrect xcarchive packages.
I had to disable the "Parallelize Build" option for the scheme I was building.
After un-ticking this option, the builds take a lot longer, but xcodebuild is consistently producing an "iOS App Archive" rather than a "Generic Archive." With "Parallelize Build" enabled xcodebuild would generate a "Generic Archive" 90% of the time, occasionally generating a correct archive.
Because I wanted my build times within Xcode to remain unaffected, I left the "Parallelize Build" option enabled for my schemes. I duplicated the schemes to be built with xcodebuild and un-ticked the option only for the deployment schemes.

Xcode 6.3.2 manual build and sign gives error on installation: Application signature not valid

When I´m running my automatic (command line) build, sign and upload script for my app, an error occurs when installing the app: 'Application signature not valid'.
It worked perfect for years before and stopped working 2 weeks ago (maybe due to Xcode update).
The same error occurs when I´m using HockeyApp for Mac OS to build the ipa and upload it.
When I´m doing the same manually in Xcode, then exporting it as .ipa, everything works well.
What could be the problem? I think xcodebuild is doing something different in the signing process than the manual Xcode .ipa-export.
My automatic build process (shortened)
xctool -workspace $WORKSPACE -scheme $SCHEME -configuration $BUILD_CONFIGURATION -sdk iphoneos clean archive
xcrun -log -sdk iphoneos PackageApplication -v "$PRODUCT_PATH" -o $OUTPUTDIR/$APPNAME.ipa" -sign "$DEVELOPER_NAME" -embed "$PROVISIONING_PROFILE"

"You can’t open the application because it is not supported on this type of Mac." xcodebuild

When I try to build my xcode project using the following command:
xcodebuild -workspace "Converse.xcworkspace" -sch
eme "Converse" -configuration “Debug” -sdk iphonesimulator7.1 -arch i386 ONLY_
ACTIVE_ARCH=NO
It builds fine, but when I try to double click on the app it generates, it says: You can’t open the application because it is not supported on this type of Mac. Does anyone know why this is happening?
iOS apps need the simulator to run. You can just, as you said run them from Xcode. If you do not have the project then you need to deploy them like :
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /Path/ToIso.app/AppName
Use Xcode, not xcodebuild, to run your app on the simulator.

Can't generate release build for Cordova iOS App

I am using Phonegap CLI 3.1 and XCode5. I want to generate the release build for iPhone Application through command line, I have valid distribution certificate and mobile provisioning profile. I want to generate the release build totally through command and don't want to use XCode GUI or Phonegap Build. I have tried too much with xcodebuild, xcrun and even corodva build command but none of them provide me the release build file (either in .app format or .ipa).
Method 1 (Use xcodebuild)
a) xcodebuild -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
** BUILD FAILED **
The following build commands failed:
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MainViewController.o MyApp/Classes/MainViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7s/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7s objective-c com.apple.compilers.llvm.clang.1_0.compiler
(3 failures)
Method 2 (Use corodova build and xcrun to sign the app)
a) cordova build ios -release
Compiling app on platform "ios" via command "/Users/Macuser/Desktop/MyApp/platforms/ios/cordova/build" --release Platform "ios" compiled successfully.
b) xcrun -sdk iphoneos PackageApplication -v "build/Release-iphoneos/MyApp.app" -o "build/Release-iphoneos/MyApp.ipa" --sign "iPhone Distribution: NAME (ID)" --embed "PROFILE_UUID.mobileprovision"
error: Failed to read entitlements from '/tmp/iyibGn3aUv/Payload/MyApp.app
The problem is that you do not have proper schemes. When phonegap project is generated it does not contain any schemes and thus linking to the phonegap files is incorrect.
Go to the phonegap generated project in console and put 'xcodebuild -list'
in the output you will get that there is no schemes in the project.
Open generated by phonegap project in the xcode - this will generate schemes.
Now you can build this using xcodebuild(Remember to fill up the proper scheme name):
xcodebuild -scheme YOURSCHEMENAME -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
For continous integration this is bad solution because you have to launch the xcode GUI to generate the schemes but I did not found any other solution for this problem. If someone know how to generate scheme using command line it would be nice of him to write it down.
First, you need to create your app in iTunes Connect (This is in the member center of your iOS developer account). If you've already created your profiles and certificates, then you can select the correct one in iTunes Connect. Here is where you name your app, set a price, write a description, and upload screen shots and a large icon. Make sure you fill in all information and upload all images for your app. You will know when you are done the status of your app changes to 'Waiting for Upload".
After you've created your app successfully in iTunes Connect, to generate an .IPA file for distribution (either for the AppStore or Ad-Hoc) in Xcode you need to select your Project in the file tree (at the top of the tree). Then make sure your 'Targets' is selected to the right.
Choose 'Build Settings". Then go to the section where is says Code Signing. For 'Release', make sure that the correct iPhone Distribution identity or profile is selected.
Below 'Release' it should say 'Any iOS SDK'. Make sure that it says 'IOS Distribution' next to it.
If you have the correct certificates and profiles in the keychain, you can now in the menu at the top choose Product > Archive.
If it doesn't build, then press the run button to build your project. Xcode should say that it is archiving.
After it archive's successfully, go to the Organizer. In the menu at the top choose Window > Organizer. Now click Archives.
If your project successfully archived you will see it here. First you need to Validate your project with iTunes Connect. You will need to enter your iOS Developer login info. Xcode 5 does a pretty good job of detecting the correct profiles so you should see it in there.
If your app validates then you can then distribute either to the App Store or as an Ad-Hoc distribution. Depending on which profile you have.
This is the process for distributing apps either Native or Phonegap. It doesn't matter, I've built both.
I would suggest doing it this way, in case your app doesn't validate. Xcode will then tell you what you need to do to fix. Then once you fix everything. Create a new archive and try until it validates.

Resources