Part 2: How to Setup Jenkins to build iOS .ipa and run unit tests.
A robust and agile mobile application development environment requires continuous integration and delivery. It also requires an integrated and automated unit testing process that helps bring applications to market successfully. This two-part series details my work done at Red Hat Open Innovation Labs and as a Mobile Technical Account Manager to capture these mobile innovations in a useful, repeatable way. In part one of this two-part series, I broke down the steps to create and unit test a native iOS application using Red Hat’s Mobile Application Platform. In part two, I’ll show how Jenkins can be used to automate continuous integration and unit testing of that Mobile app.
Requirements
-
Xcode 7.3
-
Jenkins
-
Mac OSX El Capitan
// Fix Jenkins user
After installing Jenkins we need to setup the Jenkins user
-
In mac, go to system-preferences-Users and Groups-unlock-right click on the empty user you see. Specify Full name, and reset the password. Now we have a valid Jenkins user.
2. Run these commands to give Jenkins admin rights and add to developer group
sudo dseditgroup -o edit -a jenkins -t user admin
sudo dscl . append /Groups/_developer GroupMembership jenkins
Move your iPhone developer certificates to system.
Since Jenkins will be running as a system process, not as a user application, we need to give it access to the developer certificates.
-
Using Keychain application, find your iPhoneDeveloper certificate in login
-
Make sure to expand it to see the iOS developer part
-
Select both and copy
-
Select system and paste those two items
Logout and Login into your mac machine as Jenkins user
Add the following plugins to Jenkins
-
Git
-
Xcode Integration
-
Junit Plugin
Add SSH keys to jenkins
Add Credentials needed to do git clone. Under Credentials create a new system credential. Specify the username (same as in Red Hat Mobile Application Platform portal) and you can either generate new ssh keys or copy paste a key directly. Keep passphrase empty.
Change Xcode build folder
The new Xcode places the builds in a common folder that the Xcode plugin has issues getting to, so we need to make it relative to the workspace.
-
Go to Xcode--->Preferences---> Locations
-
For Derived Data select as shown below
Run Jenkins as Agent
In order for Jenkins to launch the simulator, it needs to be running as an Agent and not as a daemon. Follow these steps:
-
sudo cp /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist
-
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
-
sudo launchctl load /Library/LaunchAgents/org.jenkins-ci.plist
Setup a new Jenkins item
Create a new Jenkins project using freestyle option and the following settings. We actually need two build steps as you will see one for *.ipa and one for running unit tests on simulator.
-
Give your project a name.
-
Select Git, paste the git url from Red Hat Mobile Application Platform and select the right credentials.
-
Make sure the right branch is selected, here we have master
4. We need three build steps:
-
Execute shell for running pod install since our Red Hat Mobile Application Platform template uses pods
2. First Xcode build step to build and archive *.ipa
-
Select Clean before build
-
Select Generate archive
-
Set Configuration for Debug
-
Select Pack application and build ipa
-
${BUILD_DATE} for ipa filename
-
Output directory to artifacts
-
3. Advanced Xcode build options
-
Xcode Schema File to helloword-ios-app
-
Xcode Workspace File to helloworld-ios-app
-
Build output directory /Users/Shared/Jenkins/Home/workspace/iOSBuildAndTest/DerivedData
4.Second build step for running unit tests
-
Specify Target to limit it to testing: helloworld-ios-appTest
-
Clean before build NO ← make sure this is NO or else it deletes the artifacts
-
Configuration Debug
Advanced Xcode build options
-
Clean test reports = yes
-
Xcode Schema file: helloworld-ios-app
-
SDK = iphonesimulator
-
Custom xcodebuild arguments= test -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3'
-
Xcode Workspace file = helloworld-ios-app
Post build steps
-
Add Archive the artifacts and place the url to DerivedData/artifacts/*.ipa
-
Add Publish JUnit test result report specify url to test-reports/*.xml
Results should look like this
This concludes part two of our tutorial for setting up Jenkins to build iOS native applications. In part one of our tutorial we added unit tests to our Red Hat Mobile Application Platform native iOS application.
Juana Nakfour is a Senior Mobile Technical Account Manager with over 15 years advanced R&D experience in the telecommunications industry. Juana’s focus is broad and include wireless communication networks, embedded/mobile devices and microservices.
A Red Hat Technical Account Manager (TAM) is a specialized product expert who works collaboratively with IT organizations to strategically plan for successful deployments and help realize optimal performance and growth. The TAM is part of Red Hat’s world class Customer Experience and Engagement organization and provides proactive advice and guidance to help you identify and address potential problems before they occur. Should a problem arise, your TAM will own the issue and engage the best resources to resolve it as quickly as possible with minimal disruption to your business.
저자 소개
유사한 검색 결과
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.