Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple platform support for Single Target in podfile

Is there any way to add multiple platform support for a single target through podfile?

For example my project is common for both iOS and Mac. They consume the same code base. So instead of creating multiple target for the same code, I added support for both iOS and MacOSX in the same target. It builds fine.

Now I want to add a dependency through Cocoapods. I create a podfile and specify my target's dependency on the pod. The pod in question here supports multiple platform in a similar way i.e. single target.

But now while building my project it fails for iOS.

Specifying multiple platforms in Podfile for single target produces an error.

And if I just specify platform as only iOS or Mac then the project in question fails to build on other platform.

Has anyone experienced this before? How can I add multiple platform for a single target through podfile?

P.S. - I know I can achieve it by creating multiple targets in my project. But I want to keep that as my last option.

like image 233
Vikas Dadheech Avatar asked Jan 07 '19 13:01

Vikas Dadheech


People also ask

What does platform mean in Podfile?

It specifies the minimum OS version you are going to support for the pod project. If your applications project's deployment target is less than the pod project mentioned iOS version, you will get a warning if there any any APIs which are deprecated in the supported OS versions in the main project.

What is use frameworks in Podfile?

use_frameworks! in the Podfile means that we want the listed frameworks to be dynamically installed instead as static frameworks. Thank you but please give more details about dynamically install vs static install.


1 Answers

def import_pods

pod 'CorePlot'

end

target 'FirstAppWithMacOS' do
    # define your platform here.
    platform :ios, '9.0'
    import_pods
end

target 'FirstMacOSApp' do
    # define your platform here.
    platform :osx, '10.10'
    import_pods
end

See below image of my project :

enter image description here

like image 96
iNiravKotecha Avatar answered Sep 23 '22 10:09

iNiravKotecha