2

i'm trying to Archive my code by Jenkins and CocoaPods.

But build error, it seems the project can find the module generated by CocoaPods.

i use swift to code and the project is build successfully in Xcode

the podfile is like:

platform :ios, '8.0'
use_frameworks!

target 'MyProject' do

pod 'AFNetworking'
pod 'ObjectMapper'

end

the error log in Jenkins is:

....
/Users/xxx/.jenkins/jobs/LIFE_iOS/workspace/MyProject/Core/Model/ItemResult.swift:10:8: error: no such module     'ObjectMapper'
import ObjectMapper
       ^

** BUILD FAILED **


The following build commands failed:
CompileSwift normal arm64 /Users/xxx/.jenkins/jobs/LIFE_iOS/workspace/MyProject/MGFramework/CustomViews/MartyJunior/MJTableViewTopCell.swift
...
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(5 failures)
Build step 'Xcode' marked build as failure
Finished: FAILURE
leo_luck
  • 151
  • 2
  • 8
  • Once you are done with pod install you should open your Xcode.workspace and build it not the .project. Try it – Santosh Jun 29 '16 at 16:43
  • thank you for reply, and it does work. And there is a new error, can you help me to fix it? ` === BUILD TARGET ObjectMapper OF PROJECT Pods WITH CONFIGURATION Release === Check dependencies Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings (“xxxxx”) has an AppID of “me.xxx.ios” which does not match your bundle identifier “org.cocoapods.ObjectMapper”. ** BUILD FAILED ** The following build commands failed: Check dependencies Build step 'Xcode' marked build as failure Finished: FAILURE` – leo_luck Jun 30 '16 at 05:16
  • Please mark below as the answer. And for your second issue, refer this: http://stackoverflow.com/questions/27973011/xcodebuild-different-provisioning-profile-for-target-dependency/29605731#29605731 – Santosh Jun 30 '16 at 11:28

3 Answers3

7

As pointed out by @Santosh, opening the workspace is the right thing to do when using the Xcode UI. As you are probably using xcodebuild on the command line (or Jenkins is), instead of specifying a project and a target, you have to run xcodebuild with a workspace and a scheme. Just wanted to add this, as you were asking for Jenkins.

So without CocoaPods, you could have done:

xcodebuild -project MyProject.xcodeproj -target MyTarget -configuration Release

Now, with CocoaPods, you have to:

xcodebuild -workspace MyProject.xcworkspace -scheme MyScheme -configuration

Flo
  • 2,309
  • 20
  • 27
  • Thanks, I Got the same error while trying to Build on VSTS. I kept 'configuration' param empty and it solved the problem. – Gili Ariel Dec 30 '19 at 11:04
2

Specify the workspace name in the Jenkins Project configuration. Follow Configure > build > Xcode > Advanced XCode build options -> XCode Workspace File. This enabled the jenkins to invoke the xcodebuild with workspace rather than project and that includes the pod dependencies. Make sure you have a build step of type execute shell "/usr/local/bin/pod install" prior to xcode build step.

Sanju Varghese
  • 487
  • 2
  • 4
0

Once you are done with pod install, you should open your .xcworkspace and not .xcodeproj. Please try it and let me know.

Santosh
  • 2,900
  • 1
  • 16
  • 16