Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by sagi · Jun 04, 2013 at 01:11 PM · packageios4plist

custom .plist file not added to ios project

Hi, I have a custom .plist file I would like to have unity add to the resulting xcode project. I put it in Assets/Plugins/iOS along with a library (.a) file. The library gets included in the project correctly, but the .plist file is nowhere to be found. How can I get it to be added to the project as a file, just like Info.plist?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by sumiguchi · Nov 10, 2013 at 05:50 AM

Rename you file plist file to have a txt extension.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jctz · Sep 22, 2014 at 10:18 PM 0
Share

That didn't seem to work for me. I tried NewFile.plist.txt as well as NewFile.txt. I'm using Unity 4.5.3, is there a new way? I just want to insert a set of custom plist files into the root of my generated xcode project and have it recognized by the build.

avatar image
1

Answer by David-Berger · Nov 12, 2015 at 01:17 PM

.plist usually need to be merged with the Info.plist of the iOS project and the .plist files are not uploaded. (Not sure what you need them for except adding info to Info.plist?)

You however can add the information you need via post process steps using the XCode Manipulation API which can be found here: https://bitbucket.org/Unity-Technologies/xcodeapi

Have a look in the forums for examples and how to use if if you are stuck. There is a lot of information available there about it, especially in the iOS and Unity Cloud Build forums.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by $$anonymous$$ · Oct 06, 2016 at 04:19 PM

As an example here's the code I use to set NSCameraUsageDescription. This file must be in an assets Editor/ folder

 using UnityEngine;
 using System.Collections;
 using UnityEditor.Callbacks;
 using UnityEditor;
 using UnityEditor.iOS.Xcode;
 using System;
 using System.IO;
 using System.Linq;
 using Mk.Common;
 using System.Collections.Generic;
 
 public class GveBuild {
 
     private const string NSCameraUsageDescription = "NSCameraUsageDescription";
 
     [PostProcessBuildAttribute(1)]
     public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
         Debug.Log("GveBuild.OnPostprocessBuild " + target + " " + pathToBuiltProject);
         switch (target) {
             case BuildTarget.iOS:
                 string plistFilePath = pathToBuiltProject + Path.DirectorySeparatorChar + "Info.plist";
                 // 10/5/16 The code that uses Xcode is flagged as missing in editor, but it compiles when we return to Unity and works
                 // when build is run.
                 // Q: why doesn't this work? A: 2nd link says it is fixed in 5.4.2, we'll see
                 // https://issuetracker.unity3d.com/issues/ios-monodevelop-unityeditor-dot-ios-dot-xcode-namespace-isnt-recognised-in-monodevelop
                 // https://issuetracker.unity3d.com/issues/unity-does-not-include-unityeditor-dot-ios-dot-xcode-in-project-file
                 
                 // Read the existing plist file
                 try {
                     PlistDocument plist = new PlistDocument();
                     plist.ReadFromFile(plistFilePath);
                     Debug.Log("GveBuild.OnPostprocessBuild successfully read " + plistFilePath + ": " + ValueToString(plist.root));
 
                     // Add our modifications
                     if (plist.root.values.ContainsKey(NSCameraUsageDescription)) {
                         Debug.LogError("GveBuild.OnPostprocessBuild key already set? Do not overwrite: " + NSCameraUsageDescription + " = " + ValueToString(plist.root.values[NSCameraUsageDescription]));
                     } else {
                         plist.root.values[NSCameraUsageDescription] = new PlistElementString("Camera is not used by our application (API reference is due to Unity libraries)");
                         Debug.Log("GveBuild.OnPostprocessBuild added NSCameraUsageDescription = " + ValueToString(plist.root.values[NSCameraUsageDescription]));
                     }
 
                     // Write the modified file
                     string plistPathNew = plistFilePath + ".new";
                     plist.WriteToFile(plistPathNew);
 
                     // Replace the original file. Note subsequent build steps modify the plist file further (e.g. currently facebook entries are added after this script runs)
                     if (true) {
                         // Delete the old file
                         File.Delete(plistFilePath);
                     } else {
                         // Keep the old file for diff while testing
                         string plistPathOld = plistFilePath + ".orig";
                         File.Move(plistFilePath, plistPathOld);
                     }
                     File.Move(plistPathNew, plistFilePath);
                     Debug.Log("GveBuild.OnPostprocessBuild successfully updated " + plistFilePath);
                 } catch (Exception e) {
                     Debug.LogError("GveBuild.OnPostprocessBuild PList error " + e);
                 }
                 break;
 
             default:
                 // nada
                 break;
         }
     }
 
     /// <summary>
     /// Utility to get value of a PlistElement as string
     /// </summary>
     private static string ValueToString(PlistElement element) {
         if (element is PlistElementString) {
             return ((PlistElementString)element).value;
         } else if (element is PlistElementInteger) {
             return ((PlistElementInteger)element).value.ToString();
         } else if (element is PlistElementBoolean) {
             return ((PlistElementBoolean)element).value.ToString();
         } else if (element is PlistElementDict) {
             Dictionary<string, PlistElement> values;
             return ((PlistElementDict)element).values.Select(x => x.Key + " : " + ValueToString(x.Value)).Join();
         } else {
             return element.ToString();
         }
     }
 }
 
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fdo_decea · Nov 20, 2018 at 11:20 AM 0
Share

Hi @$$anonymous$$ ,

I got an issue message from App Store Connect when I was trying to upload an .ipa file built from Unity Cloud Build.

Error $$anonymous$$essage :

$$anonymous$$issing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSPhotoLibraryUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data

I was wondering if your script could work for me if I change the NSCameraUsageDescription by NSPhotoLibraryUsageDescription ..

Another question about the script usage.. must that public static function be called from anywhere, otherwise it's an event called automatically when the app is building for iOS platform ? I mean, must I call it from another place, message , etc (Start(), Awake (),...)? ?

Thank you very much in advance

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Engine script assemblies not accessible in my package 1 Answer

Package Manager is just grey. 2 Answers

Vuforia 10.4.4 doesnt appear to be importing 1 Answer

Etcetera image capture issue : image flips 0 Answers

Unity Export Package things go missing 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges