Jenkins&Xcode : Build crashes in ipad frequently - xcode

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.

Related

build and deploy iOS app to local device using CLI

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

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).

xcodebuild fails to build SPM packages with catalyst support

I'm trying to build a mac catalyst project using the xcodebuild command line tool. The project was originally an iOS app that now supports mac catalyst. The project is using Cocoapods and Swift Package Manager as we have some libraries that don't support the latter. I'm using the following xcodebuild command
xcodebuild -workspace 'PROJECT.xcworkspace' -scheme 'MY_SCHEME' -configuration 'MY_CONFIG' CODE_SIGN_IDENTITY='MY_IDENTITY' ENABLE_BITCODE=YES ONLY_ACTIVE_ARCH=NO DEBUG_INFORMATION_FORMAT=dwarf-with-dsym
It fails with the following error
error: Signing for "RealmCore" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'RealmCore' from project 'RealmCore')
error: Signing for "Alamofire" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'Alamofire' from project 'Alamofire')
error: Signing for "Realm" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'Realm' from project 'Realm')
All the mentioned libraries were added using SPM. I don't understand why this fails. Do swift packages require a development team?
Also the problem only seems to be the addition of the mac catalyst target. I have a branch of the iOS app without catalyst support with the same SPM dependencies and xcodebuild works without problem.

xcodebuild can't find cocoapods libraries

I have an xcode project (build from Unity) that uses cocoapods to install Firebase dependencies. It builds fine through the xcode GUI but not using the xcodebuild invocation that I use for automated builds:
xcodebuild -archivePath "$ARCHIVE_PATH" -project "$(pwd)/repo/quantum_unity/Build/$PLATFORM/Unity-iPhone.xcodeproj" -sdk iphoneos -allowProvisioningUpdates -scheme 'Unity-iPhone' -configuration 'Release Development' archive DEVELOPMENT_TEAM=$TEAMID
The build fails to find the FirebaseCore library in linking.
What needs to change in how I invoke xcodebuild so it's able to find the pods installed by cocoapods?
I'm using xcode version 9.4.1.
Use -workspace and the xcworkspace instead of the project.
After installing via CocoaPods and depending on them, always use the Xcode workspace instead of the project.

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