Esempio n. 1
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (IOSNativeSettings.Instance.EnableForceTouchAPI && IOSNativeSettings.Instance.ForceTouchMenu.Count > 0)
        {
            ISD_PlistKey UIApplicationShortcutItems = new ISD_PlistKey();
            UIApplicationShortcutItems.Name = "UIApplicationShortcutItems";
            UIApplicationShortcutItems.Type = ISD_PlistKeyType.Array;

            foreach (var item in IOSNativeSettings.Instance.ForceTouchMenu)
            {
                var ShortcutItem = new ISD_PlistKey();
                ShortcutItem.Type = ISD_PlistKeyType.Dictionary;
                UIApplicationShortcutItems.AddChild(ShortcutItem);


                var ShortcutItemTitle = new ISD_PlistKey();
                ShortcutItemTitle.Name        = "UIApplicationShortcutItemTitle";
                ShortcutItemTitle.StringValue = item.Title;
                ShortcutItem.AddChild(ShortcutItemTitle);

                var ShortcutItemSubtitle = new ISD_PlistKey();
                ShortcutItemSubtitle.Name        = "UIApplicationShortcutItemSubtitle";
                ShortcutItemSubtitle.StringValue = item.Subtitle;
                ShortcutItem.AddChild(ShortcutItemSubtitle);


                var ShortcutItemType = new ISD_PlistKey();
                ShortcutItemType.Name        = "UIApplicationShortcutItemType";
                ShortcutItemType.StringValue = item.Action;
                ShortcutItem.AddChild(ShortcutItemType);
            }


            ISD_API.SetInfoPlistKey(UIApplicationShortcutItems);
        }


        if (IOSNativeSettings.Instance.EnablePermissionAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.Photos);
            ISD_API.AddFramework(ISD_iOSFramework.Contacts);
            ISD_API.AddFramework(ISD_iOSFramework.EventKit);
        }


        if (IOSNativeSettings.Instance.EnablePushNotificationsAPI)
        {
            ISD_PlistKey UIBackgroundModes = new ISD_PlistKey();
            UIBackgroundModes.Name = "UIBackgroundModes";
            UIBackgroundModes.Type = ISD_PlistKeyType.Array;

            ISD_PlistKey remoteNotification = new ISD_PlistKey();
            remoteNotification.Name        = "remote-notification";
            remoteNotification.StringValue = "remote-notification";
            remoteNotification.Type        = ISD_PlistKeyType.String;

            UIBackgroundModes.AddChild(remoteNotification);
            ISD_API.SetInfoPlistKey(UIBackgroundModes);
        }



        if (IOSNativeSettings.Instance.EnableInAppsAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.StoreKit);
        }

        if (IOSNativeSettings.Instance.EnableGameCenterAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.GameKit);

            ISD_PlistKey UIRequiredDeviceCapabilities = new ISD_PlistKey();
            UIRequiredDeviceCapabilities.Name = "UIRequiredDeviceCapabilities";
            UIRequiredDeviceCapabilities.Type = ISD_PlistKeyType.Array;

            ISD_PlistKey gamekit = new ISD_PlistKey();
            gamekit.StringValue = "gamekit";
            gamekit.Type        = ISD_PlistKeyType.String;
            UIRequiredDeviceCapabilities.AddChild(gamekit);


            ISD_PlistKey armv7 = new ISD_PlistKey();
            armv7.StringValue = "armv7";
            armv7.Type        = ISD_PlistKeyType.String;
            UIRequiredDeviceCapabilities.AddChild(armv7);


            ISD_API.SetInfoPlistKey(UIRequiredDeviceCapabilities);
        }

        if (IOSNativeSettings.Instance.UrlTypes.Count > 0)
        {
            ISD_PlistKey CFBundleURLTypes = new ISD_PlistKey();
            CFBundleURLTypes.Name = "CFBundleURLTypes";
            CFBundleURLTypes.Type = ISD_PlistKeyType.Array;



            foreach (SA.IOSNative.Models.UrlType url in IOSNativeSettings.Instance.UrlTypes)
            {
                ISD_PlistKey URLTypeHolder = new ISD_PlistKey();
                URLTypeHolder.Type = ISD_PlistKeyType.Dictionary;

                CFBundleURLTypes.AddChild(URLTypeHolder);


                ISD_PlistKey CFBundleURLName = new ISD_PlistKey();
                CFBundleURLName.Type        = ISD_PlistKeyType.String;
                CFBundleURLName.Name        = "CFBundleURLName";
                CFBundleURLName.StringValue = url.Identifier;
                URLTypeHolder.AddChild(CFBundleURLName);


                ISD_PlistKey CFBundleURLSchemes = new ISD_PlistKey();
                CFBundleURLSchemes.Type = ISD_PlistKeyType.Array;
                CFBundleURLSchemes.Name = "CFBundleURLSchemes";
                URLTypeHolder.AddChild(CFBundleURLSchemes);

                foreach (string scheme in url.Schemes)
                {
                    ISD_PlistKey Scheme = new ISD_PlistKey();
                    Scheme.Type        = ISD_PlistKeyType.String;
                    Scheme.StringValue = scheme;

                    CFBundleURLSchemes.AddChild(Scheme);
                }
            }

            foreach (ISD_PlistKey v in  SA.IOSDeploy.ISD_Settings.Instance.PlistVariables)
            {
                if (v.Name.Equals(CFBundleURLTypes.Name))
                {
                    SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Remove(v);
                    break;
                }
            }
            SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Add(CFBundleURLTypes);
        }



        if (IOSNativeSettings.Instance.EnableSocialSharingAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.Accounts);
            ISD_API.AddFramework(ISD_iOSFramework.Social);
            ISD_API.AddFramework(ISD_iOSFramework.MessageUI);



            string       QueriesSchemesName          = "LSApplicationQueriesSchemes";
            ISD_PlistKey LSApplicationQueriesSchemes = ISD_API.GetInfoPlistKey(QueriesSchemesName);
            if (LSApplicationQueriesSchemes == null)
            {
                LSApplicationQueriesSchemes      = new ISD_PlistKey();
                LSApplicationQueriesSchemes.Name = QueriesSchemesName;
                LSApplicationQueriesSchemes.Type = ISD_PlistKeyType.Array;
            }

            ISD_PlistKey instagram = new ISD_PlistKey();
            instagram.StringValue = "instagram";
            instagram.Type        = ISD_PlistKeyType.String;
            LSApplicationQueriesSchemes.AddChild(instagram);

            ISD_PlistKey whatsapp = new ISD_PlistKey();
            whatsapp.StringValue = "whatsapp";
            whatsapp.Type        = ISD_PlistKeyType.String;
            LSApplicationQueriesSchemes.AddChild(whatsapp);


            ISD_API.SetInfoPlistKey(LSApplicationQueriesSchemes);
        }


        if (IOSNativeSettings.Instance.ApplicationQueriesSchemes.Count > 0)
        {
            string       QueriesSchemesName          = "LSApplicationQueriesSchemes";
            ISD_PlistKey LSApplicationQueriesSchemes = ISD_API.GetInfoPlistKey(QueriesSchemesName);
            if (LSApplicationQueriesSchemes == null)
            {
                LSApplicationQueriesSchemes      = new ISD_PlistKey();
                LSApplicationQueriesSchemes.Name = QueriesSchemesName;
                LSApplicationQueriesSchemes.Type = ISD_PlistKeyType.Array;
            }


            foreach (var scheme in IOSNativeSettings.Instance.ApplicationQueriesSchemes)
            {
                ISD_PlistKey schemeName = new ISD_PlistKey();
                schemeName.StringValue = scheme.Identifier;
                schemeName.Type        = ISD_PlistKeyType.String;
                LSApplicationQueriesSchemes.AddChild(schemeName);
            }

            ISD_API.SetInfoPlistKey(LSApplicationQueriesSchemes);
        }



        if (IOSNativeSettings.Instance.EnableMediaPlayerAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.MediaPlayer);


            var NSAppleMusicUsageDescription = new ISD_PlistKey();
            NSAppleMusicUsageDescription.Name        = "NSAppleMusicUsageDescription";
            NSAppleMusicUsageDescription.StringValue = IOSNativeSettings.Instance.AppleMusicUsageDescription;
            NSAppleMusicUsageDescription.Type        = ISD_PlistKeyType.String;


            ISD_API.SetInfoPlistKey(NSAppleMusicUsageDescription);
        }


        if (IOSNativeSettings.Instance.EnableCameraAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.MobileCoreServices);


            var NSCameraUsageDescription = new ISD_PlistKey();
            NSCameraUsageDescription.Name        = "NSCameraUsageDescription";
            NSCameraUsageDescription.StringValue = IOSNativeSettings.Instance.CameraUsageDescription;
            NSCameraUsageDescription.Type        = ISD_PlistKeyType.String;


            ISD_API.SetInfoPlistKey(NSCameraUsageDescription);



            var NSPhotoLibraryUsageDescription = new ISD_PlistKey();
            NSPhotoLibraryUsageDescription.Name        = "NSPhotoLibraryUsageDescription";
            NSPhotoLibraryUsageDescription.StringValue = IOSNativeSettings.Instance.PhotoLibraryUsageDescription;
            NSPhotoLibraryUsageDescription.Type        = ISD_PlistKeyType.String;


            ISD_API.SetInfoPlistKey(NSPhotoLibraryUsageDescription);


            var NSPhotoLibraryAddUsageDescription = new ISD_PlistKey();
            NSPhotoLibraryAddUsageDescription.Name        = "NSPhotoLibraryAddUsageDescription";
            NSPhotoLibraryAddUsageDescription.StringValue = IOSNativeSettings.Instance.PhotoLibraryUsageDescription;
            NSPhotoLibraryAddUsageDescription.Type        = ISD_PlistKeyType.String;


            ISD_API.SetInfoPlistKey(NSPhotoLibraryAddUsageDescription);
        }

        if (IOSNativeSettings.Instance.EnableReplayKit)
        {
            ISD_API.AddFramework(ISD_iOSFramework.ReplayKit, weak: true);
        }


        if (IOSNativeSettings.Instance.EnableCloudKit)
        {
            ISD_API.AddFramework(ISD_iOSFramework.CloudKit, weak: true);
            string inheritedflag = "$(inherited)";
            ISD_API.AddFlag(inheritedflag, ISD_FlagType.LinkerFlag);
        }

        if (IOSNativeSettings.Instance.EnablePickerAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.AssetsLibrary, weak: true);
        }


        if (IOSNativeSettings.Instance.EnableContactsAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.Contacts, weak: true);
            ISD_API.AddFramework(ISD_iOSFramework.ContactsUI, weak: true);


            var NSContactsUsageDescription = new ISD_PlistKey();
            NSContactsUsageDescription.Name        = "NSContactsUsageDescription";
            NSContactsUsageDescription.StringValue = IOSNativeSettings.Instance.ContactsUsageDescription;
            NSContactsUsageDescription.Type        = ISD_PlistKeyType.String;


            ISD_API.SetInfoPlistKey(NSContactsUsageDescription);
        }

        if (IOSNativeSettings.Instance.EnableSoomla)
        {
            ISD_API.AddFramework(ISD_iOSFramework.AdSupport);
            ISD_API.AddLibrary(ISD_iOSLibrary.libsqlite3);

                        #if UNITY_5
            string soomlaLinkerFlag = "-force_load Libraries/Plugins/iOS/libSoomlaGrowLite.a";
                        #else
            string soomlaLinkerFlag = "-force_load Libraries/libSoomlaGrowLite.a";
#endif

            ISD_API.AddFlag(soomlaLinkerFlag, ISD_FlagType.LinkerFlag);
        }

        if (IOSNativeSettings.Instance.EnableUserNotificationsAPI)
        {
            ISD_API.AddFramework(ISD_iOSFramework.UserNotifications);
        }

        Debug.Log("ISN Postprocess Done");
    }
Esempio n. 2
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (IOSNativeSettings.Instance.EnableInAppsAPI)
        {
            string StoreKit = "StoreKit.framework";



            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(StoreKit))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = StoreKit;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }
        }

        if (IOSNativeSettings.Instance.EnableGameCenterAPI)
        {
            string GameKit = "GameKit.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(GameKit))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = GameKit;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }

            SA.IOSDeploy.Variable UIRequiredDeviceCapabilities = new SA.IOSDeploy.Variable();
            UIRequiredDeviceCapabilities.Name = "UIRequiredDeviceCapabilities";
            UIRequiredDeviceCapabilities.Type = SA.IOSDeploy.PlistValueTypes.Array;

            SA.IOSDeploy.Variable gamekit = new SA.IOSDeploy.Variable();
            gamekit.StringValue = "gamekit";
            gamekit.Type        = SA.IOSDeploy.PlistValueTypes.String;
            UIRequiredDeviceCapabilities.AddChild(gamekit);


            SA.IOSDeploy.Variable armv7 = new SA.IOSDeploy.Variable();
            armv7.StringValue = "armv7";
            armv7.Type        = SA.IOSDeploy.PlistValueTypes.String;
            UIRequiredDeviceCapabilities.AddChild(armv7);


            SA.IOSDeploy.ISD_Settings.Instance.AddOrReplaceNewVariable(UIRequiredDeviceCapabilities);
        }

        if (IOSNativeSettings.Instance.UrlTypes.Count > 0)
        {
            SA.IOSDeploy.Variable CFBundleURLTypes = new SA.IOSDeploy.Variable();
            CFBundleURLTypes.Name = "CFBundleURLTypes";
            CFBundleURLTypes.Type = SA.IOSDeploy.PlistValueTypes.Array;



            foreach (SA.IOSNative.Models.UrlType url in IOSNativeSettings.Instance.UrlTypes)
            {
                SA.IOSDeploy.Variable URLTypeHolder = new SA.IOSDeploy.Variable();
                URLTypeHolder.Type = SA.IOSDeploy.PlistValueTypes.Dictionary;

                CFBundleURLTypes.AddChild(URLTypeHolder);


                SA.IOSDeploy.Variable CFBundleURLName = new SA.IOSDeploy.Variable();
                CFBundleURLName.Type        = SA.IOSDeploy.PlistValueTypes.String;
                CFBundleURLName.Name        = "CFBundleURLName";
                CFBundleURLName.StringValue = url.Identifier;
                URLTypeHolder.AddChild(CFBundleURLName);


                SA.IOSDeploy.Variable CFBundleURLSchemes = new SA.IOSDeploy.Variable();
                CFBundleURLSchemes.Type = SA.IOSDeploy.PlistValueTypes.Array;
                CFBundleURLSchemes.Name = "CFBundleURLSchemes";
                URLTypeHolder.AddChild(CFBundleURLSchemes);

                foreach (string scheme in url.Schemes)
                {
                    SA.IOSDeploy.Variable Scheme = new SA.IOSDeploy.Variable();
                    Scheme.Type        = SA.IOSDeploy.PlistValueTypes.String;
                    Scheme.StringValue = scheme;

                    CFBundleURLSchemes.AddChild(Scheme);
                }
            }


            foreach (SA.IOSDeploy.Variable v in  SA.IOSDeploy.ISD_Settings.Instance.PlistVariables)
            {
                if (v.Name.Equals(CFBundleURLTypes.Name))
                {
                    SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Remove(v);
                    break;
                }
            }

            SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Add(CFBundleURLTypes);
        }



        if (IOSNativeSettings.Instance.EnableSocialSharingAPI)
        {
            string Accounts = "Accounts.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(Accounts))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = Accounts;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }



            string SocialF = "Social.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(SocialF))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = SocialF;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }

            string MessageUI = "MessageUI.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(MessageUI))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = MessageUI;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }

            string QueriesSchemesName = "LSApplicationQueriesSchemes";
            SA.IOSDeploy.Variable LSApplicationQueriesSchemes = SA.IOSDeploy.ISD_Settings.Instance.GetVariableByName(QueriesSchemesName);
            if (LSApplicationQueriesSchemes == null)
            {
                LSApplicationQueriesSchemes      = new SA.IOSDeploy.Variable();
                LSApplicationQueriesSchemes.Name = QueriesSchemesName;
                LSApplicationQueriesSchemes.Type = SA.IOSDeploy.PlistValueTypes.Array;
            }

            SA.IOSDeploy.Variable instagram = new SA.IOSDeploy.Variable();
            instagram.StringValue = "instagram";
            instagram.Type        = SA.IOSDeploy.PlistValueTypes.String;
            LSApplicationQueriesSchemes.AddChild(instagram);

            SA.IOSDeploy.Variable whatsapp = new SA.IOSDeploy.Variable();
            whatsapp.StringValue = "whatsapp";
            whatsapp.Type        = SA.IOSDeploy.PlistValueTypes.String;
            LSApplicationQueriesSchemes.AddChild(whatsapp);


            SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Remove(LSApplicationQueriesSchemes);
            SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Add(LSApplicationQueriesSchemes);
        }


        if (IOSNativeSettings.Instance.ApplicationQueriesSchemes.Count > 0)
        {
            string QueriesSchemesName = "LSApplicationQueriesSchemes";
            SA.IOSDeploy.Variable LSApplicationQueriesSchemes = SA.IOSDeploy.ISD_Settings.Instance.GetVariableByName(QueriesSchemesName);
            if (LSApplicationQueriesSchemes == null)
            {
                LSApplicationQueriesSchemes      = new SA.IOSDeploy.Variable();
                LSApplicationQueriesSchemes.Name = QueriesSchemesName;
                LSApplicationQueriesSchemes.Type = SA.IOSDeploy.PlistValueTypes.Array;
            }


            foreach (var scheme in IOSNativeSettings.Instance.ApplicationQueriesSchemes)
            {
                SA.IOSDeploy.Variable schemeName = new SA.IOSDeploy.Variable();
                schemeName.StringValue = scheme.Identifier;
                schemeName.Type        = SA.IOSDeploy.PlistValueTypes.String;
                LSApplicationQueriesSchemes.AddChild(schemeName);
            }

            SA.IOSDeploy.ISD_Settings.Instance.AddOrReplaceNewVariable(LSApplicationQueriesSchemes);
        }



        if (IOSNativeSettings.Instance.EnableMediaPlayerAPI)
        {
            string MediaPlayer = "MediaPlayer.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(MediaPlayer))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = MediaPlayer;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }


            var NSAppleMusicUsageDescription = new SA.IOSDeploy.Variable();
            NSAppleMusicUsageDescription.Name        = "NSAppleMusicUsageDescription";
            NSAppleMusicUsageDescription.StringValue = IOSNativeSettings.Instance.AppleMusicUsageDescription;
            NSAppleMusicUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddOrReplaceNewVariable(NSAppleMusicUsageDescription);
        }


        if (IOSNativeSettings.Instance.EnableCameraAPI)
        {
            string MobileCoreServices = "MobileCoreServices.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(MobileCoreServices))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = MobileCoreServices;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }



            var NSCameraUsageDescription = new SA.IOSDeploy.Variable();
            NSCameraUsageDescription.Name        = "NSCameraUsageDescription";
            NSCameraUsageDescription.StringValue = IOSNativeSettings.Instance.CameraUsageDescription;
            NSCameraUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;

            SA.IOSDeploy.ISD_Settings.Instance.AddOrReplaceNewVariable(NSCameraUsageDescription);



            var NSPhotoLibraryUsageDescription = new SA.IOSDeploy.Variable();
            NSPhotoLibraryUsageDescription.Name        = "NSPhotoLibraryUsageDescription";
            NSPhotoLibraryUsageDescription.StringValue = IOSNativeSettings.Instance.PhotoLibraryUsageDescription;
            NSPhotoLibraryUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddOrReplaceNewVariable(NSPhotoLibraryUsageDescription);
        }

        if (IOSNativeSettings.Instance.EnableReplayKit)
        {
            Debug.Log("Replay Kit enabled");

            string ReplayKit = "ReplayKit.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(ReplayKit))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name       = ReplayKit;
                F.IsOptional = true;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }
        }


        if (IOSNativeSettings.Instance.EnableCloudKit)
        {
            Debug.Log("Cloud Kit enabled");

            string CloudKit = "CloudKit.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(CloudKit))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name       = CloudKit;
                F.IsOptional = true;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }


            string inheritedflag = "$(inherited)";

            SA.IOSDeploy.ISD_Settings.Instance.AddLinkerFlag(inheritedflag);
        }

        if (IOSNativeSettings.Instance.EnablePickerAPI)
        {
            string AssetsLibrary = "AssetsLibrary.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(AssetsLibrary))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name       = AssetsLibrary;
                F.IsOptional = true;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }
        }


        if (IOSNativeSettings.Instance.EnableContactsAPI)
        {
            string Contacts = "Contacts.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(Contacts))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name       = Contacts;
                F.IsOptional = true;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }


            string ContactsUI = "ContactsUI.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(ContactsUI))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name       = ContactsUI;
                F.IsOptional = true;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }


            var NSContactsUsageDescription = new SA.IOSDeploy.Variable();
            NSContactsUsageDescription.Name        = "NSContactsUsageDescription";
            NSContactsUsageDescription.StringValue = IOSNativeSettings.Instance.CameraUsageDescription;
            NSContactsUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddOrReplaceNewVariable(NSContactsUsageDescription);
        }

        if (IOSNativeSettings.Instance.EnableSoomla)
        {
            string AdSupport = "AdSupport.framework";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsFreamworkWithName(AdSupport))
            {
                SA.IOSDeploy.Framework F = new SA.IOSDeploy.Framework();
                F.Name = AdSupport;
                SA.IOSDeploy.ISD_Settings.Instance.Frameworks.Add(F);
            }

            string libsqlite3 = "libsqlite3.dylib";
            if (!SA.IOSDeploy.ISD_Settings.Instance.ContainsLibWithName(libsqlite3))
            {
                SA.IOSDeploy.Lib L = new SA.IOSDeploy.Lib();
                L.Name = libsqlite3;
                SA.IOSDeploy.ISD_Settings.Instance.Libraries.Add(L);
            }



                        #if UNITY_5
            string soomlaLinkerFlag = "-force_load Libraries/Plugins/iOS/libSoomlaGrowLite.a";
                        #else
            string soomlaLinkerFlag = "-force_load Libraries/libSoomlaGrowLite.a";
                        #endif



            SA.IOSDeploy.ISD_Settings.Instance.AddLinkerFlag(soomlaLinkerFlag);
        }


        Debug.Log("ISN Postprocess Done");
    }
Esempio n. 3
0
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
    {
        if (IOSNativeSettings.Instance.EnableInAppsAPI)
        {
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.StoreKit);
        }

        if (IOSNativeSettings.Instance.EnableGameCenterAPI)
        {
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.GameKit);

            SA.IOSDeploy.Variable UIRequiredDeviceCapabilities = new SA.IOSDeploy.Variable();
            UIRequiredDeviceCapabilities.Name = "UIRequiredDeviceCapabilities";
            UIRequiredDeviceCapabilities.Type = SA.IOSDeploy.PlistValueTypes.Array;

            SA.IOSDeploy.Variable gamekit = new SA.IOSDeploy.Variable();
            gamekit.StringValue = "gamekit";
            gamekit.Type        = SA.IOSDeploy.PlistValueTypes.String;
            UIRequiredDeviceCapabilities.AddChild(gamekit);


            SA.IOSDeploy.Variable armv7 = new SA.IOSDeploy.Variable();
            armv7.StringValue = "armv7";
            armv7.Type        = SA.IOSDeploy.PlistValueTypes.String;
            UIRequiredDeviceCapabilities.AddChild(armv7);


            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(UIRequiredDeviceCapabilities);
        }

        if (IOSNativeSettings.Instance.UrlTypes.Count > 0)
        {
            SA.IOSDeploy.Variable CFBundleURLTypes = new SA.IOSDeploy.Variable();
            CFBundleURLTypes.Name = "CFBundleURLTypes";
            CFBundleURLTypes.Type = SA.IOSDeploy.PlistValueTypes.Array;



            foreach (SA.IOSNative.Models.UrlType url in IOSNativeSettings.Instance.UrlTypes)
            {
                SA.IOSDeploy.Variable URLTypeHolder = new SA.IOSDeploy.Variable();
                URLTypeHolder.Type = SA.IOSDeploy.PlistValueTypes.Dictionary;

                CFBundleURLTypes.AddChild(URLTypeHolder);


                SA.IOSDeploy.Variable CFBundleURLName = new SA.IOSDeploy.Variable();
                CFBundleURLName.Type        = SA.IOSDeploy.PlistValueTypes.String;
                CFBundleURLName.Name        = "CFBundleURLName";
                CFBundleURLName.StringValue = url.Identifier;
                URLTypeHolder.AddChild(CFBundleURLName);


                SA.IOSDeploy.Variable CFBundleURLSchemes = new SA.IOSDeploy.Variable();
                CFBundleURLSchemes.Type = SA.IOSDeploy.PlistValueTypes.Array;
                CFBundleURLSchemes.Name = "CFBundleURLSchemes";
                URLTypeHolder.AddChild(CFBundleURLSchemes);

                foreach (string scheme in url.Schemes)
                {
                    SA.IOSDeploy.Variable Scheme = new SA.IOSDeploy.Variable();
                    Scheme.Type        = SA.IOSDeploy.PlistValueTypes.String;
                    Scheme.StringValue = scheme;

                    CFBundleURLSchemes.AddChild(Scheme);
                }
            }

            foreach (SA.IOSDeploy.Variable v in  SA.IOSDeploy.ISD_Settings.Instance.PlistVariables)
            {
                if (v.Name.Equals(CFBundleURLTypes.Name))
                {
                    SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Remove(v);
                    break;
                }
            }
            SA.IOSDeploy.ISD_Settings.Instance.PlistVariables.Add(CFBundleURLTypes);
        }



        if (IOSNativeSettings.Instance.EnableSocialSharingAPI)
        {
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.Accounts);
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.Social);
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.MessageUI);



            string QueriesSchemesName = "LSApplicationQueriesSchemes";
            SA.IOSDeploy.Variable LSApplicationQueriesSchemes = SA.IOSDeploy.ISD_Settings.Instance.GetVariableByName(QueriesSchemesName);
            if (LSApplicationQueriesSchemes == null)
            {
                LSApplicationQueriesSchemes      = new SA.IOSDeploy.Variable();
                LSApplicationQueriesSchemes.Name = QueriesSchemesName;
                LSApplicationQueriesSchemes.Type = SA.IOSDeploy.PlistValueTypes.Array;
            }

            SA.IOSDeploy.Variable instagram = new SA.IOSDeploy.Variable();
            instagram.StringValue = "instagram";
            instagram.Type        = SA.IOSDeploy.PlistValueTypes.String;
            LSApplicationQueriesSchemes.AddChild(instagram);

            SA.IOSDeploy.Variable whatsapp = new SA.IOSDeploy.Variable();
            whatsapp.StringValue = "whatsapp";
            whatsapp.Type        = SA.IOSDeploy.PlistValueTypes.String;
            LSApplicationQueriesSchemes.AddChild(whatsapp);


            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(LSApplicationQueriesSchemes);
        }


        if (IOSNativeSettings.Instance.ApplicationQueriesSchemes.Count > 0)
        {
            string QueriesSchemesName = "LSApplicationQueriesSchemes";
            SA.IOSDeploy.Variable LSApplicationQueriesSchemes = SA.IOSDeploy.ISD_Settings.Instance.GetVariableByName(QueriesSchemesName);
            if (LSApplicationQueriesSchemes == null)
            {
                LSApplicationQueriesSchemes      = new SA.IOSDeploy.Variable();
                LSApplicationQueriesSchemes.Name = QueriesSchemesName;
                LSApplicationQueriesSchemes.Type = SA.IOSDeploy.PlistValueTypes.Array;
            }


            foreach (var scheme in IOSNativeSettings.Instance.ApplicationQueriesSchemes)
            {
                SA.IOSDeploy.Variable schemeName = new SA.IOSDeploy.Variable();
                schemeName.StringValue = scheme.Identifier;
                schemeName.Type        = SA.IOSDeploy.PlistValueTypes.String;
                LSApplicationQueriesSchemes.AddChild(schemeName);
            }

            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(LSApplicationQueriesSchemes);
        }



        if (IOSNativeSettings.Instance.EnableMediaPlayerAPI)
        {
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.MediaPlayer);


            var NSAppleMusicUsageDescription = new SA.IOSDeploy.Variable();
            NSAppleMusicUsageDescription.Name        = "NSAppleMusicUsageDescription";
            NSAppleMusicUsageDescription.StringValue = IOSNativeSettings.Instance.AppleMusicUsageDescription;
            NSAppleMusicUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(NSAppleMusicUsageDescription);
        }


        if (IOSNativeSettings.Instance.EnableCameraAPI)
        {
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.MobileCoreServices);


            var NSCameraUsageDescription = new SA.IOSDeploy.Variable();
            NSCameraUsageDescription.Name        = "NSCameraUsageDescription";
            NSCameraUsageDescription.StringValue = IOSNativeSettings.Instance.CameraUsageDescription;
            NSCameraUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(NSCameraUsageDescription);



            var NSPhotoLibraryUsageDescription = new SA.IOSDeploy.Variable();
            NSPhotoLibraryUsageDescription.Name        = "NSPhotoLibraryUsageDescription";
            NSPhotoLibraryUsageDescription.StringValue = IOSNativeSettings.Instance.PhotoLibraryUsageDescription;
            NSPhotoLibraryUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(NSPhotoLibraryUsageDescription);
        }

        if (IOSNativeSettings.Instance.EnableReplayKit)
        {
            var ReplayKit = SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.ReplayKit);
            ReplayKit.IsOptional = true;
        }


        if (IOSNativeSettings.Instance.EnableCloudKit)
        {
            var CloudKit = SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.CloudKit);
            CloudKit.IsOptional = true;


            string inheritedflag = "$(inherited)";
            SA.IOSDeploy.ISD_Settings.Instance.AddLinkerFlag(inheritedflag);
        }

        if (IOSNativeSettings.Instance.EnablePickerAPI)
        {
            var AssetsLibrary = SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.AssetsLibrary);
            AssetsLibrary.IsOptional = true;
        }


        if (IOSNativeSettings.Instance.EnableContactsAPI)
        {
            var Contacts = SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.Contacts);
            Contacts.IsOptional = true;

            var ContactsUI = SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.ContactsUI);
            ContactsUI.IsOptional = true;


            var NSContactsUsageDescription = new SA.IOSDeploy.Variable();
            NSContactsUsageDescription.Name        = "NSContactsUsageDescription";
            NSContactsUsageDescription.StringValue = IOSNativeSettings.Instance.CameraUsageDescription;
            NSContactsUsageDescription.Type        = SA.IOSDeploy.PlistValueTypes.String;


            SA.IOSDeploy.ISD_Settings.Instance.AddVariable(NSContactsUsageDescription);
        }

        if (IOSNativeSettings.Instance.EnableSoomla)
        {
            SA.IOSDeploy.ISD_Settings.Instance.AddFramework(SA.IOSDeploy.iOSFramework.AdSupport);
            SA.IOSDeploy.ISD_Settings.Instance.AddLibrary(SA.IOSDeploy.iOSLibrary.libsqlite3);

                        #if UNITY_5
            string soomlaLinkerFlag = "-force_load Libraries/Plugins/iOS/libSoomlaGrowLite.a";
                        #else
            string soomlaLinkerFlag = "-force_load Libraries/libSoomlaGrowLite.a";
                        #endif

            SA.IOSDeploy.ISD_Settings.Instance.AddLinkerFlag(soomlaLinkerFlag);
        }


        Debug.Log("ISN Postprocess Done");
    }