3

I want to assemble/compile a workspace with cocoapods on it but without:

  • Archiving.
  • Need to setup credentials or pem files.

Something like: xcodebuild assemble

I want to know if the code compiles but not generate an archive or a deployed artifact.

I tried fastlane/gym but it tries to create an archive.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Daniel Gomez Rico
  • 15,026
  • 20
  • 92
  • 162
  • 2
    xcodebuild -scheme build – Marcel May 17 '18 at 14:41
  • @Marcel when I run that I got errors, but from xcode it compiles and run on the emulator `Exiting early, found no Swift version in executables.` – Daniel Gomez Rico May 22 '18 at 16:10
  • Looks like you don't have the language version set in the build settings, try opening the project in xcode and check the target's build settings. Are you by any chance using cocoapods? – Marcel May 23 '18 at 11:25
  • Sorry, missed that in the question, you are using cocoapods. Try the workaround you can find on the following page: https://github.com/CocoaPods/CocoaPods/issues/5521 – Marcel May 24 '18 at 11:19
  • @Marcel the info was not in the question, I edited it. Thanks for helping – Daniel Gomez Rico May 26 '18 at 15:57

1 Answers1

8

Using xcodebuild

You can compile a project with the following command:

xcodebuild <path to project> -scheme <scheme name> build

Because you are using cocoapods, you should compile using the workspace, instead of the project, like this:

xcodebuild -workspace <path to workspace file> -scheme <scheme name> build

If the swift version is not set in the cocoapods target there is a workaround by adding the following to your Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.1'
   end
  end
end

Using fastlane

Another way is using build_app from fastlane, like:

build_app(scheme: 'YourScheme',
          workspace: 'YourProject.xcworkspace',
          skip_archive: true,
          skip_package_ipa: true,
          include_bitcode: false)

I prefer this way, since it makes it simpler and uses xcpretty that will print the output nicer than xcodebuild.

Marcel
  • 6,393
  • 1
  • 30
  • 44