Build iPhone Application on build server - ios

Using the xcodebuild command it is fairly simple to build iPhone projects on a Mac based build server. However an issue I run into, when building a new project is that I need to install the provisioning profile on the machine.
I think it is not a very good practise to check in the provisioning profile along with the code (Is that right?). So how do I make sure that at build time the provisioning profiles are available via some sort of automated mechanism.

You could check the certificates and the private key into your source code control system assuming that they aren't publicly available.
Other than that there are two options, either use an automated system builder type tool, such as Chef or roll your own shell script to set up build machines.
You could create a Chef recipe that builds a new Jenkins based CI server, downloads the provisioning profile (and the private key) from an internal server and installs it into the Jenkins user's Library/MobileDevices/Provisioning Profiles directory (and login.keychain) on the new CI server.
You could also automate this part of the setup of the server using a shell script:
curl -O http://your_server/ABCD.mobileprovision
cp ABCD.mobileprovision ~/Library/MobileDevices/Provisioning\ Profiles
curl -O http://your_server/DeveloperCerts.p12
security import DeveloperCerts.p12 -P this_is_your_password -T codesign -T security

Related

Uploading iOS .ipa file to testflight via Jenkins

I might be late to the CI/CD party but better late than never. So far, I am able to setup Jenkins on a separate MAC which does not contain XCode. I use this MAC as a 24x7 small server for minor operations. A lot of time was wasted for archiving and then uploading that build to testflight for my iOS apps so I thought of setting up a CI/CD process.
After the Jenkins setup, I am able to generate the .ipa file for specified target (release/debug).
Now I want to upload this .ipa file to Testflight. This is what I know already:
Via ALTool: As per this answer, I should use AlTool. AlTool is nothing but the Application Loader inside XCode. I don't want to install XCode on this separate MAC, so this is not what I can work with.
Via shell script: If you see the question of the answer in the above point, the user has mentioned a script. I have tried that as well and it fails.
Via Shenzen: This is deprecated. On the Github page itself, they have mentioned to use Fastlane.
Via Testflight plugin: This is also deprecated.
So basically, what I feel is Jenkins alone itself can not distribute iOS builds to testflight, unless we use ALTool which requires XCode to be installed. Is there a workaround to do it purely via Jenkins?
Yes, there is a better option, strongly recommend Fastlane.
You can check here and here is specifically for TestFlight
You need to have Fastlane on the Jenkins but it is execution is easy and fast.
Also as we discussed you can implement connection by yourself using AppStoreConnect API
Fastlane Pilot action is a better option.
You need to add Environment Variables in Jenkins
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD - This is application-specific password generated on https://appleid.apple.com. Pilot automatically fetches password for a transporter from environment variable named FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD
FASTLANE_PASSWORD This is apple developer account password
Add below command in shell script of Jenkins
fastlane pilot upload — ipa IPA_PATH
Reference link

Continuous Integration with hybrid mobile app

I have a problem. I need to build a job in my Jenkins server hosted by macmini (localhost) to automatic build a deploy for my mobile hybrid apps. That's apps was building with ionic2, and need a deploy for Android (apk) and for iOS (ipa).
But when i run a build from Jenkins, with this shell command
I get this error
that's not all... because i try to execute, from the jenkins folder, the npm i and the result was this:
When i try to build my application from other "folder" and not from jenkins, they works correctly. How i can solve?
Without more information hard to say; you can either just script the things you do when you deploy "manually", or you might want to try a CLI tool like https://www.bitrise.io/cli or https://fastlane.tools which can auto-scan your project and configure a suitable configuration which is then easier to tweak.
In case of Bitrise CLI the base config can be generated with bitrise init in the repo root, and you can also use a visual editor to modify your configuration: https://discuss.bitrise.io/t/how-to-experiment-with-bitrise-configs-locally-on-your-mac-linux/1751
After a lot of time, just find the solution. Jenkins have a own "tools management". So i need to install, into jenkins, a property version of nodeJS, Npm and all other tools i need to deploy the application.
So, first of all you need to install property plugin (in my case nodejs).
After this, going into Jenkins Management System and configure a NodeJS version. That's all

UWP certificate issue on hosted agents

I'm trying to run UWP build using Team Foundation Server and App Center and it gives me this error.
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3090,5): Error MSB3325: Cannot import the following key file: AppCenterTest.UWP_TemporaryKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_480BF88F6934FA8C
I tried creating a private agent for Team Foundation Server which fixed the issue for Team Foundation Server only since the certificate is installed on my private agent. But for App Center by default is running a hosted agent.
How to resolve this issue? Thanks.
Instead of Creating a test certificate in Package.appxmanifest > Packaging > Choose Certificate. I create the certificate in my UWP project Properties > Signing > Choose a strong name key file: > New. This steps resolved my issue.
Take a look at below statement:
Select the right type of build agent
Choose the type of build agent that you want VSTS to use when it
executes the build process. A hosted build agent is deployed with the
most common tools and sdks, and it will work for most scenarios, see
the Software on the hosted build server article. However, you can
create a custom build agent if you need more control over the build
steps. You can use the following table to help you make that decision.
Note: If you plan to target the Windows Anniversary Update SDK (Build 14393) you will need to set up your custom build agent, since the hosted build pool only supports SDK 10586 and 10240. More information to choose a UWP version
Besides, if you use a Git repository, add the certificate file of your project to the repository so that the build agent can sign the appx package. If you don’t do this, the Git repository will ignore the certificate file. To add the certificate file to your repository, right-click the certificate file in Solution Explorer, and then in the shortcut menu, choose the Add Ignored File to Source Control command.
More details please refer this tutorial: Set up automated builds for your UWP app

Gitlab CD for iOS on server

I'm trying to create Continuous Deployment pipeline for an iOS project with Gitlab tools.
It's suggested to use own mac in order to run tests and Archive in this tutorial.
So, there, probably, should be a way to create runner on a server, not on own machine, right? Because otherwise the owner of the Apple distribution signature would be the onlyone who can trigger deployment process.

Upload .ipa file using bitrise services w/o xcode

Since I do not own a Apple Mac, I need to upload my .ipa file
which is ready with me to iTunesConnect for putting it
on AppleAppStore ..
Not sure about bitrise workflows etc, since I have joined bitrise
short time back. Will I need to learn workflows and take
the full curve of bitrise learnings?
Is there any easy steps reckoner via bitrise just to deploy an ipa file on appleStore thru iTunesconnect without using Mac/XCode personally ??
Thanks
The recommended way is to build your app (.ipa) with https://www.bitrise.io , as that way the building & code signing of the .ipa is handled automatically.
If you don't want to build your app on bitrise.io and just want to upload it to iTunes Connect, you have two ways to do this depending on where you store your .ipa that you want to send to iTunes Connect.
You store the .ipa in a repository
You store the .ipa elsewhere (Dropbox, Amazon S3, etc.) and you want to download the .ipa from there.
In the first case:
Create a new app on Bitrise with the repository that you use to store the .ipa. (To add a repository which doesn't include an iOS project select the Do you want to configure the build manually? option in the Validation setup section.)
After that go to the Workflow tab, click on the Manage Workflow button and remove all the steps except the Git Clone and the Activate SSH key. (docs for accessing and managing the workflow: http://devcenter.bitrise.io/docs/add-your-first-step-to-your-apps-workflow)
Add a Script Step and after that one of the iTunes Connect Steps (Deliver or Shenzen).
Click on the Script Step and copy this to the content input:
Script:
#!/bin/bash
set -e
set -x
ipa_relative_path_in_repository="${BITRISE_SOURCE_DIR}/relative/path/to.ipa"
envman add --key BITRISE_IPA_PATH --value "${ipa_relative_path_in_repository}"
In the second case:
Create a new app on Bitrise with the repo you use to store your app.
Go to Manage workflow
Remove every step
Add a Script Step and after that one of the iTunes Connect Steps (Deliver or Shenzen).
Click on the Script Step and copy this to the content input:
Script:
#!/bin/bash
set -e
set -x
ipa_download_url="INSERT_YOUR_IPA_DOWNLOAD_URL_HERE"
ipa_download_location="${BITRISE_DEPLOY_DIR}/ipa-to-upload.ipa"
echo "ipa_download_location: ${ipa_download_location}"
wget -O "$ipa_download_location" "$ipa_download_url"
envman add --key BITRISE_IPA_PATH --value "${ipa_download_location}"

Resources