build and deploy iOS app to local device using CLI - xcode

In switching from Cordova to Capacitor we seem to have lost the ability to deploy our app to physical devices using the command line. This is helpful so that our automated build process can push it out to a set of devices we have connected to the server. All the docs for deploying with Capacitor say to open Xcode and select a device for deployment. I'm trying with instruments to get the device ID and then xcodebuild to install it
instruments -s devices | grep -v Simulator | grep -e iPhone -e iPad
xcodebuild install -workspace ios/App/App.xcworkspace -scheme App -destination 'platform=iOS,id=76a....781'
And even though this ends with ** install succeeded ** the app has not been installed on the device

You can consider bumping your Capacitor version to v3.0.0 rc3.. The team is building upon a new command to run the app on device without opening the native ide.
npx cap run ios
Source Discussion Capacitor v3
Alternative - Use Ionic Appflow for deployments.
For Appflow builds on the cloud.. You can do two things there..
Live Deploy - if you have just made any changes to the code, the js, HTML, css side, then use LiveDeploy, this will be much faster for deploying to all the app users.
Native Builds - incase you have added any new plugin or made native configuration changes, then make a native build that can deploy it to test flight and then your tester's can download the updated version from there..
You can also set auto triggers for these workflows as well when you commit your code to the repository.

If waiting for Capacitor 3 is not an option these three lines work
xcodebuild -workspace ios/App/App.xcworkspace/ -scheme App -archivePath ./ios/App.xcarchive archive
xcodebuild -exportArchive -archivePath ./ios/App.xcarchive -exportOptionsPlist ./ios/App/export-development.plist -exportPath ./iOS
ios-deploy --debug --bundle ios/App.ipa

Related

Azure Pipelines iOS Fastlane beta hangs and fails because of timout

I am Using Azure Pipelines to build and deploy the Flutter Application.
I connect my Mac Mini as an Agent to the Azure Pipelines.
Agent Version: 2.173.0
Just as pretext it worked earlier. I am not sure which version it was, but the fact is now it is not working.
Under the hood, it is using Fastlane to
build
download signatures - Fastlane plugin
sign and upload to TestFlight - - Fastlane plugin
If I run the command from the terminal it is working fine:
bundle exec fastlane ios beta --verbose
But if I run it via pipeline it just stacks on a build log and just fails after an hour(timeout).
I have additionally checked during the run if any Dialog has shown up like xCode command tools install or anything. No, this was not the case.
The worst thing I could not determine what's going on because the logs hang as well.
set -o pipefail && xcodebuild -workspace Runner.xcworkspace -scheme Runner -destination 'generic/platform=iOS' -archivePath /Users/{almostGotMe}/Library/Developer/Xcode/Archives/2020-09-02/Runner\ 2020-09-02\ 07.43.05.xcarchive archive | tee /Users/{almostGotMe}/Library/Logs/gym/Runner-Runner.log | xcpretty
Azure Pipelines iOS Fastlane beta hangs and fails because of timout
Since the logs hang as well, we could not locate and analyze the cause of this issue. Fortunately, you could successfully build your Flutter Application in the earlier agent version.
So, the workaround to resolve this issue, we could re-install the old version agent to build this project.
To get the old version agent, we could check the logs of the previous successful pipeline. In the Initialize job, we can see the version information of the agent:
Then we could download old agent version from Github azure-pipelines-agent.

Xcode build succeeds however it does not downloads app on the simulator

Xcode build succeeds however it does not download app on the simulator through terminal.
I am using the below command in mac terminal to build my code, however, the build succeeds but the app does not get downloaded to my ios simulator as it does using the xcode application
xcrun xcodebuild -workspace MyApp.xcworkspace -scheme "Test App" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11,OS=13.2'
How can i successfully pull my code from Github and then successfully deploy on ios simulator with few lines?
After you build your content, run xcrun simctl install <UDID> <PATH> to install the app in the sim. Be sure you have booted it first as well ( which you can also use simctl for).

Jenkins&Xcode : Build crashes in ipad frequently

I'm currently generating an ios app with distribution profile. When I generate an ipa file from Xcode it works fine without any crashes when installed on an ipad but it crashes in most fields when generated from jenkins as a part CI process. Till now its working fine but the issue started while adding developed frameworks to the project. In jenkins I'm using below command line script for xcodebuild.
. xcodebuild -workspace ~/.jenkins/jobs/workspace/repo/Source/App/App.xcodeproj/project.xcworkspace -scheme App -configuration "release" -sdk iphoneos VALID_ARCHS="armv64 armv7 armv7s i386" archive PROVISIONING_PROFILE="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" CODE_SIGN_IDENTITY="iPhone Distribution: company Limited" -archivePath ~/Desktop/../App.xcarchive
Unable to find out the exact issue for the crash.
I suggest you to check the environment variable of your jenkins node.. if they are overriding your build variables.
Before this can you provide more details.

xcode build fails with error code 65 without indicative message

I'm experiencing weird behaviour with my iPhone CI job (running in TeamCity). Every once in a while our build fails without any indicative error in the build log. The build reaches the last stage of codesign validation and I get ** BUILD FAILED ** message immediately after.
These are the last lines of the log of a good and bad builds -
Bad Build
[15:00:56] : [CodeSign] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Library/TeamCity/buildAgent/work/dc055fa257f562be/DerivedData/MyProject/Build/Products/AdHoc-iphoneos/MyProject.app
[15:00:58]W: [Step 3/6] ** BUILD FAILED **
Good Build
[14:09:13] : [CodeSign] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Library/TeamCity/buildAgent/work/dc055fa257f562be/DerivedData/MyProject/Build/Products/AdHoc-iphoneos/MyProject.app
[14:09:13] : [Step 3/6] ** BUILD SUCCEEDED **
Because it's running in a CI I looked for user interaction problems (opening the keychain...etc') but usually xcodebuild spews the relevant errors.
Is there any other log I can dig into to find the cause of the build failures?
EDIT:
Seems I had the same problem like build failed jenkins iOS no error.
I also had a similar problem, in my case it was caused by the fact I'm using both Xcode 7.2 and Xcode 6.4 side by side. When the simulator of Xcode 6.4 is open (iOS Simulator 8.4) and I try to start a test from the commandline using Xcode 7.2 I get this 65 error.
Eg. when iOS Simulator 8.4 is open:
# sudo xcode-select -s "/Applications/Xcode 7.2.app/Contents/Developer"
# xcodebuild test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -workspace "/path/to/MyWorkspace.xcworkspace" -scheme "MyProject" -destination "platform=iOS Simulator,name=iPhone 6,OS=9.2"
(cut)
** TEST FAILED **
# echo $?
65
Solution is to kill the simulator before starting the test:
# killall "iOS Simulator"
# killall "Simulator"
The process is called "iOS Simulator" for XCode 6.4 and earlier and called "Simulator" for later XCode versions.
Had the same problem as build failed jenkins iOS no error
tl;dr - CopyPNG failed because of two images with the same name.
You need to remove platform ios - cordova platform rm ios, and then add platform - cordova platform add ios. now build ios - cordova build ios
I hit this when updating to Xcode 8, in my case it was because I had set the PROVISIONING_PROFILE_SPECIFIER setting incorrectly
For Xcode version 13
The following is what worked for me, this is aimed at Xcode version 13, hoping to be helpful
My React native project was cloned, i was able to run the app in android, but while running on iOS it showed error code 65.
After trying most of the solutions and failing, i got it fixed finally. This is what worked for me, and could be useful for some people hopefully.
Clone the project again(not necessary, just telling you what was done)
npm install
pod install (in iOS directory)
If Xcode shows error code 65, if there is legacy deprecation issue --> go to Xcode -->file --> workspace settings --> Check the box at the end of the window saying "do not show diagnostic issue about build system deprecation
run the project again
This is what fixed it for me.
My issue came up after updating to the latest version of Xcode. To resolve, I performed the following steps.
Completely quit Xcode and the Simulator. I had a zombie Simulator process running that I found and closed through Activity Monitor. Be sure no processes for Xcode or Simulator are running.
In Xcode, open the project found in the ios folder of your react-native project.
Xcode may suggest some recommended updates to modules. I accepted their recommendations.
Close Xcode, relaunch your react-native app

Run installed application on iPad (device) from Mac Terminal

I build the application for iPad (from a Terminal) using:
xcodebuild ARCHS=armv7 ONLY_ACTIVE_ARCH=NO VALID_ARCHS=armv7 -scheme MyApp -sdk iphoneos build
Then I deploy it to my iPad using fruitstrap:
./fruitstrap -b Mobile/DerivedData/MyApp/Build/Products/Debug-iphoneos/MyApp.app/
At the next step I have a problem: I need to run the installed application from a Terminal to be able to run the nightly-iterations on Hudson CI.
Any ideas on how to do it?

Resources