googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.29k stars 348 forks source link

Support for multiple targets with Cocoapods #205

Open twomedia opened 5 years ago

twomedia commented 5 years ago

Is there a way to add dependencies for specific targets? Currently, I have multiple extensions (Apple Watch, Today Extension) which require some CocoaPods dependencies. Is there an existing or planned feature for this?

stewartmiles commented 5 years ago

At the moment there isn't a way to do this if you're talking about Xcode targets.

If you are adding extra targets to Unity's generated Xcode project programmatically?

If you're talking about targets that you're manually configuring using pre/postprocessing steps in Unity script. I guess the only way to do that at the moment would be to provide different *Dependencies.xml files in your project and rename them to enable / disable them based upon the selected target.

e.g you may have

when you select the Apple TV target you could then rename the tvOSDependencies.xml.disabled file to tvOSDependencies.xml before the build is initiated and the iOS resolver will include just those dependencies.

twomedia commented 5 years ago

I'm using the Unity Editor PBXProjectExtensions class to add the extensions in a post-process step. This means in the unity editor my target is always iOS. Somehow I need a way to specify what target the dependencies are for so that I can achieve a generated podfile like the one below. Hopefully, this could be added as a feature in the future as it would be a very handy addition.

target 'PixelStarships' do
    platform :ios, '8.0'

    pod 'Realm'
    pod 'libPusher' #, '~> 1.6.1' #tested

    #Attribution
    pod 'AppLovinSDK' # upgraded from AppLovin-SDK
    pod 'Branch'

    #Ad Networkds
    pod 'mopub-ios-sdk' #, '5.4.1' #tested
    pod 'TapjoySDK' #tested
    pod 'ChartboostSDK' #tested
    pod 'AppsFlyerFramework' #, '~> 4.5.8.0' #tested
    pod 'OneSignal' #, '~> 1.13.2' #tested
    pod 'AdColony' #, '~> 2.6.2'
    pod 'Google-Mobile-Ads-SDK'

    # Google (AdMob)
    pod 'MoPub-AdMob-Adapters' #, '7.37.0.4'

    # AppLovin
    pod 'MoPub-Applovin-Adapters' #, '6.2.0.0'

    # AdColony
    pod 'MoPub-AdColony-Adapters' #, '3.3.5.4'

    # Chartboost
    pod 'MoPub-Chartboost-Adapters' #, '7.3.0.4'

    # Unity Ads
    pod 'MoPub-UnityAds-Adapters'

    # Tapjoy
    pod 'MoPub-TapJoy-Adapters' #, '12.2.0.4'

    # ironSource
    pod 'MoPub-IronSource-Adapters' #, '6.8.1.0.0'

    #facebook
    pod 'FacebookSDK'
    pod 'FacebookSDK/LoginKit'
    pod 'FacebookSDK/ShareKit'
    pod 'FacebookSDK/PlacesKit'

    pod 'FBSDKMessengerShareKit'
    pod 'FBAudienceNetwork'

    #analytics
    pod 'Fabric'
    pod 'Crashlytics'
    pod 'Firebase/Core'
end

target 'PixelStarshipsWatchOS Extension' do
    platform :watchos, '2.0'

    pod 'Realm'
end

target 'PixelStarshipsWidget' do

    pod 'libPusher' #, '~> 1.6.1'
    pod 'SDWebImage', '~>3.6'
end
stewartmiles commented 5 years ago

@twomedia I imagine you could do this by adding a target filter in the Pod data structure.

https://github.com/googlesamples/unity-jar-resolver/blob/ff47ad3a90f1234d8bf1b1f3030be81d4251f88f/source/IOSResolver/src/IOSResolver.cs#L41

Then if multiple targets are associated with the Pod I would imagine this code could generate each target section in the podfile.

https://github.com/googlesamples/unity-jar-resolver/blob/ff47ad3a90f1234d8bf1b1f3030be81d4251f88f/source/IOSResolver/src/IOSResolver.cs#L1730

stewartmiles commented 5 years ago

We're happy to take pull requests ;)

twomedia commented 5 years ago

@stewartmiles Thanks for the pointers! When I get a chance I'll see if I can get something working & submit a pull request.