fermoya/cocoapods-catalyst-support

[BUG] fastlane integration pod install breaks

Closed this issue · 7 comments

I get Invalid `Podfile` file: cannot load such file -- cocoapods-catalyst-support. when running my Fastlane lane.

Love your contribution to Catalyst, have you tried integrating this require with Fastlane?

@leojkwan I haven't tried it with fastlane, but I'm curious, why would you? What are you executing from your lane? You'd just need to configure this once. The rest of the time you call pod install or pod update it should automatically be called in the post_install callback. Actually, pod catalyst run just calls pod install under the hood

@leojkwan I haven't tried it with fastlane, but I'm curious, why would you?

I'm not calling pod catalyst directly, My fastfile has a cocoapods action, which runs pod install. I need to run cocoapods to begin my fastlane beta lane as well as running remote CI tests. The issue is that Fastlane beta breaks when invoking the pod install step.

desc "Push a new beta build to TestFlight"
  lane :beta do
    cocoapods
    xcode_select("/Applications/Xcode.app")
    increment_build_number(xcodeproj: "Atrium.xcodeproj")
    build_app(workspace: "Atrium.xcworkspace", scheme: "Atrium")
    upload_to_testflight
  end

I don't have much experience with ruby scripts so not sure how to resolve the require 'cocoapods-catalyst-support' statement. :(

I can confirm my Podfile runs fine if I remove require 'cocoapods-catalyst-support' and the related code. Anyways, I'm settling with archiving my builds manually because your script is absolutely critical for getting catalyst builds out. Here is my podfile

require 'cocoapods-catalyst-support'

platform :ios, '13.0'
use_frameworks!

def ui_test_pods
  pod 'ViewControllerPresentationSpy', '~> 5.0'
end

def shared_firebase_pods
  pod 'GoogleUtilities'
  pod 'Firebase/Crashlytics'
end

target 'SuperFitAppClip' do
  pod 'Firebase/Analytics'
  #  https://github.com/CocoaPods/CocoaPods/issues/8206
  shared_firebase_pods
end


target 'Atrium' do
  shared_firebase_pods

  # Networking
  pod 'Moya/RxSwift'

  # Analytics/ Logging
  pod 'RxSwift'
  pod 'RxCocoa'
  pod "SkeletonView"
  pod 'Intercom'

  # Firebase
  pod 'Firebase/Auth'
  pod 'Firebase/Firestore'
  pod 'FirebaseFirestoreSwift'
  pod 'Firebase/Storage'
  pod 'Firebase/Functions'
  pod 'FirebasePerformance'
  pod 'FirebaseAnalytics'

  # Firebase Extensions
  pod 'CombineFirebase/Firestore'
  pod 'RxFirebase/Firestore'
  pod 'RxFirebase/Functions'

  # UI
  pod 'CRRefresh', :git => 'https://github.com/superfitapp/CRRefresh.git'
  pod "Colorful", "~> 3.0"
  pod 'UnsplashPhotoPicker'

  pod 'RxGesture'
  pod 'SwiftSpinner'
  pod 'ScrollableGraphView'
  pod 'LGButton'
  pod 'Moves'

  # Tools
  pod 'KeychainAccess'

  target 'SuperFitTests' do
    inherit! :search_paths
    ui_test_pods
  end
end

target 'UIKitCommonTests' do
  ui_test_pods
end

def fix_sign_locally(config)
  # https://github.com/CocoaPods/CocoaPods/issues/8891
  if config.build_settings['DEVELOPMENT_TEAM'].nil?
    config.build_settings['DEVELOPMENT_TEAM'] = 'GXS8378HLM'
  end
end


# Configure your macCatalyst dependencies
catalyst_configuration do
  # Uncomment the next line for a verbose output
  verbose!

  # These dependencies will only be available for iOS
  ios 'FirebaseAnalytics'
  ios 'FirebasePerformance'
  ios 'Firebase/Crashlytics'
  ios 'Intercom'
end


post_install do |installer|
  installer.configure_catalyst
  installer.pods_project.targets.each do |target|

    # https://github.com/CocoaPods/CocoaPods/issues/8891
    # Fix bundle targets' 'Signing Certificate' to 'Sign to Run Locally'
    if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
      target.build_configurations.each do |config|
        config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-'
      end
    end

    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'YES'
    end
  end

  installer.generated_projects.each do |project|
    project.build_configurations.each do |config|
      fix_sign_locally(config)
    end
    project.targets.each do |target|
      target.build_configurations.each do |config|
        fix_sign_locally(config)
      end
    end
  end
end

By the way, I had been using your script catalyst_archive_fix.rb prior, and everything worked fine! (That method did not need the require 'cocoapods-catalyst-support' line, as you know).

@leojkwan did you run gem install cocoapods-catalys-support? Also, if you're using bundle you should declare add it to your Gemfile

@leojkwan I've been doing some tests and I've come to a solution. First of all, you need to add cocoapods-catalyst-support to your Gemfile. It should look like this:

source 'https://rubygems.org'

gem 'cocoapods'
gem 'cocoapods-catalyst-support'
gem "fastlane"

Then run bundle install in your project root. Make sure your Gemfile.lock installs cocoapods-catalyst-support (0.1.2). Finally, just run your beta lane as usual.

I've added a Fastfile to the Sample project, you can use it as reference if you need to. Here's my lane:

lane :install_pods do
  cocoapods
end

and my output


Fernandos-MacBook-Pro:Sample fermoya$ fastlane install_pods
[✔] 🚀 
[20:42:24]: fastlane detected a Gemfile in the current directory
[20:42:24]: However, it seems like you didn't use `bundle exec`
[20:42:24]: To launch fastlane faster, please use
[20:42:24]: 
[20:42:24]: $ bundle exec fastlane install_pods
[20:42:24]: 
[20:42:24]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[20:42:26]: ------------------------------
[20:42:26]: --- Step: default_platform ---
[20:42:26]: ------------------------------
[20:42:26]: Driving the lane 'ios install_pods' 🚀
[20:42:26]: -----------------------
[20:42:26]: --- Step: cocoapods ---
[20:42:26]: -----------------------
[20:42:26]: $ bundle exec pod install
[20:42:27]: â–¸ Analyzing dependencies
[20:42:29]: â–¸ Downloading dependencies
[20:42:29]: â–¸ Generating Pods project
[20:42:29]: â–¸ Catalyst => Done! Your Catalyst dependencies are ready to go
[20:42:29]: â–¸ Integrating client project
[20:42:29]: â–¸ Pod installation complete! There are 2 dependencies from the Podfile and 12 total pods installed.
[20:42:29]: â–¸ [!] Automatically assigning platform `iOS` with version `14.3` on target `Sample` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
[20:42:29]: â–¸ [!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via `pod repo remove master`. To suppress this warning please add `warn_for_unused_master_specs_repo => false` to your Podfile.

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | cocoapods        | 3           |
+------+------------------+-------------+

[20:42:29]: fastlane.tools finished successfully 🎉

I've also added some notes to the README, see Installation section now.

Let me know if I can help with anything else. I've decided to create a gem as it's easier to distribute to users. Also, by using cocoapods-plugins I get some functionality for free like commands. I've created a couple of them that are useful, see here in case you didn't notice.

cocoapods-catalyst-support (0.1.2) did the trick! Thanks @fermoya !