/cocoapods-catalyst-support

Ruby extensions to help you configure your pods project so that pods not compiled for Catalyst can still be used for iOS devices

Primary LanguageRubyMIT LicenseMIT

cocoapods-catalyst-support

Requirements

Installation

$ gem install cocoapods-catalyst-support

Note: If you're using cocoapods action from fastlane, make sure to include gem 'cocoapods-catalyst-support' into your Gemfile. Don't forget to run bundle install after. For reference, see the Sample project.

Usage

These are the steps to follow:

  • Identify which pods don't compile for macOS architectures.
  • Follow installation instructions.
  • Open your terminal and run pod catalyst init in your project folder.
  • Configure your dependencies. Use ios or macos to make them available in one platform or the other:
catalyst_configuration do
  ios 'Firebase/Analytics' # This dependency will only be available for iOS
  macos 'AppCenter/Analytics' # This dependency will only be available for macOS
end
  • Run pod catalyst validate to validate your configuration
  • Run pod catalyst run and configure your catalyst dependencies

That's it! Simple as that.

Note: Make sure to read the Disclaimer section to understand what this library does and what it doesn't.

Commands

Command Description
pod catalyst Short version of pod catalyst run
pod catalyst init Set up your Podfile to use cocoapods-catalyst-support
pod catalyst run Configure your catalyst dependencies
pod catalyst validate Validate your catalyst configuration

Note: Make sure to run this commands in your project folder.

Disclaimer

Who is this for?

If you're using CocoaPods and your App supports macCatalyst, you might have run into this error:

ld: in Pods/Crashlytics/iOS/Crashlytics.framework/Crashlytics(CLSInternalReport.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file 'Pods/Crashlytics/iOS/Crashlytics.framework/Crashlytics' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

or maybe

Undefined symbols for architecture x86_64:
    "_OBJC_CLASS_$_UIWebView", referenced from:
    objc-class-ref in BNCDeviceInfo.o
    objc-class-ref in BranchViewHandler.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Perhaps the error came from the App Store:

ERROR ITMS-90276: "Missing Bundle Identifier. The application bundle contains a tool or framework ${PRODUCT_NAME} [com.myapp.myapp.pkg/Payload/MyApp.app/Contents/Resources/GoogleSignIn.bundle] that is missing the bundle identifier in its Info.plist file."

This library is meant to solve this issue so that your project compiles as usual before supporting macCatalyst. Thus, you won't need to modify your current project structure.

Additionally, you might be thinking of using some libraries only for macCatalyst. This library takes care of that too and lets you configure which libraries will be linked for macOS and which for iOS.

What does this library NOT DO?

It doesn't "magically" fix the pod. If the pod isn't built for sdk MacOS, then there's nothing that will make it compile for this architecture but the pod's author supporting macCatalyst.

What does this library DO?

It configures your pods project so that these "unsupported pods" are not linked when building for macOS and will strip those frameworks from the final Product. You'll still need to use the precompiler and remove features from your macCatalyst App:

#if !targetEnvironment(macCatalyst) 
    // code to be excluded at compilation time from your macOS app
#endif

The advantage is you still get to use them for iOS and iPadOS.

Example

require 'cocoapods-catalyst-support'

platform :ios, '12.0'
use_frameworks!

target 'Sample' do
  pod 'AppCenter/Analytics'
  pod 'Firebase/Analytics'
end

catalyst_configuration do
  verbose!

  ios 'Firebase/Analytics'
  macos 'AppCenter/Analytics'
end

post_install do |installer|
  installer.configure_catalyst
end

Troubleshooting

  • Make sure you're using the last version of the script.
  • Add verbose! to your catalyst_configuration and check if the library is being excluded.
  • Validate your catalyst_configuration by running pod catalyst validate.
  • Open an issue and specify:
    • cocoapods-catalyst-support version
    • Cocoapods version
    • Xcode version
    • Podfile

Support Open Source

If you love this script, understand all the effort it takes to maintain it and would like to support me, you can buy me a coffee by following this link:

Buy Me A Coffee

You can also sponsor me by hitting the GitHub Sponsor button. All help is very much appreciated.

License

cocoapods-catalyst-support is available under the MIT license. See the LICENSE file for more info.