Reputation: 1199
I have a set of snippets for iOS, MacOS, WatchOS and TvOS that I would like to embed in a Cocoapod library (possibly supporting also Carthage as well).
The tricky part for me is that I have targets for all the platforms (iOS, MacOS TvOS etc...) but some of the files are targeted only in a subset of them.
In my Xcode project I divided the code in folders like:
Library_Common
(target all)Library_iOS
(target iOS)Library_WatchOS
(target WatchOS)Library_MacOS
(target MacOS)This because, for example, the iOS part of the library may need UIKit
and the MacOS
may need other frameworks not available for iOS.
How can I setup the podspec in such a way that this library can be embedded in all the platforms?
Is there a way to do it or is better to split it in different libraries? The problem of this approach would be that the Library_Common
part would be repeated for each one.
Upvotes: 0
Views: 751
Reputation: 1199
I finally found what I was looking for and seems to be specified in the podspec
documentation itself. Unfortunately I didn't saw it before:
https://guides.cocoapods.org/syntax/podspec.html#group_multi_platform_support
This means, in my case I have the following settings:
s.source_files = "MyLibrary_common/**/*.{h,m}"
s.ios.source_files = "MyLibrary_iOS/**/*.{h,m}"
s.osx.source_files = "MyLibrary_macOS/**/*.{h,m}"
s.tvos.source_files = "MyLibrary_tvOS/**/*.{h,m}"
s.watchos.source_files = "MyLibrary_watchOS/**/*.{h,m}"
Upvotes: 0