Start a new topic

Unity side ios setup

Hi,


I've successfully followed the steps here:


http://www.wikitude.com/external/doc/documentation/latest/unity/setupguideunity.html#setup-guide-unity-plugin


and have a running sample.


ios version and camera description can be set in unity in the PlayerSettings.


Could you tell me how I can set embedded binary and bitcode:no on the unity side.

Surely I don't have to make these changes in xcode manual everytime I run from unity?


Thanks.


Hi, 


This is what worked for me using Unity 2017.2.0f2.

  

	public static void OnPostProcessBuild(BuildTarget buildTarget, string path) {
		if (buildTarget == BuildTarget.iOS) {
			string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

			PBXProject pbxProject = new PBXProject();
			pbxProject.ReadFromFile(projectPath);
			
			string target = pbxProject.TargetGuidByName("Unity-iPhone"); 
			
			string frameworkPath = "Frameworks/Plugins/iOS/WikitudeNativeSDK.framework";
			string fileGuid = pbxProject.FindFileGuidByProjectPath(frameworkPath);
			
			pbxProject.AddFileToBuild(target, fileGuid);
			pbxProject.AddFileToEmbedFrameworks(target, fileGuid);
			foreach (var configName in pbxProject.BuildConfigNames()) {
				var configGuid = pbxProject.BuildConfigByName(target, configName);
				pbxProject.SetBuildPropertyForConfig(configGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
			}

			pbxProject.WriteToFile(projectPath);
		}
	}

 

Please let me know if it works for you as well,


Best regards,

Alexandru 

Alternatively could you change the way the library is included so that it is not an embedded library and fix it up so that I do not have to turn of bitcode that way the unity lack of functionality to fix these up becomes not a problem ?


Hi, 


Looking at the 2017.2 beta documentation, I can see that they added a new method to the PBXProjectExtensions, called AddFileToEmbedFrameworks. Additionally, if this doesn't do what you want, there is a change in behavior for AddCopyFilesBuildPhase. The last parameter can now specify a way to add embedded frameworks.


It would be nice if Unity would mention this more explicitly, either in the ticket, or in the release notes, so you don't have to diff the documentation for information.


Lastly, the bitcode setting is not needed, as the WikitudeNativeSDK.framework now properly supports bitcode. However, it has to be an embedded binary at the moment.


Best regards,

Alexandru

Unity 2017.2.0f2:


I tried:


                const string frameworkLocationInProj = "Frameworks/Plugins/iOS";

                const string frameworkName = "/WikitudeNativeSDK.framework";

                string fileGuid = pbxProject.AddFile(frameworkLocationInProj + frameworkName, "Frameworks/" + frameworkName, PBXSourceTree.Source);

                PBXProjectExtensions.AddFileToEmbedFrameworks(pbxProject, target, fileGuid); 


which looked correct in xcode, but still couldn't find the framework at runtime.


I then tried:


                string frameworkPath = pbxProject.AddFile("Frameworks/Plugins/iOS/WikitudeNativeSDK.framework", "Frameworks/WikitudeNativeSDK.framework", PBXSourceTree.Source);

                pbxProject.AddFileToBuild(target, frameworkPath);                

                string embedPhase = pbxProject.AddCopyFilesBuildPhase (target, "Embed Frameworks", "", "10");

                pbxProject.AddFileToBuildSection (target, embedPhase, frameworkPath);  


which looked right in xcode but gave 'no code signature found' during installation.



Thanks, well spotted I was looking in PRXProject and they had hidden it away in extensions.


One step closer but still no joy, I get the same result as this on this post: https://forum.unity3d.com/threads/how-to-use-xcode-api-for-embedding-frameworks.488120/

System.Exception: The given GUID 033966F41B18B03000ECD701 does not refer to a known build section


   public static class MyBuildPostprocess
 {
 [PostProcessBuild(999)]
 public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
 {
 if (buildTarget == BuildTarget.iOS)
 {
 string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

 PBXProject pbxProject = new PBXProject();
 pbxProject.ReadFromFile(projectPath);
 
 string target = pbxProject.TargetGuidByName("Unity-iPhone"); 
 pbxProject.SetBuildProperty(target, "ENABLE_BITCODE""NO");
 
 const string defaultLocationInProj = "Plugins/iOS";
 const string coreFrameworkName = "/WikitudeNativeSDK.framework";
 
 string framework = Path.Combine(defaultLocationInProj, coreFrameworkName);
 string fileGuid = pbxProject.AddFile(framework, "Frameworks/" + framework, PBXSourceTree.Sdk);
 
 pbxProject.AddFileToEmbedFrameworks(target, fileGuid);
 
 pbxProject.WriteToFile (projectPath);
 }
 }
 }


Sure I've guessed at what those paths should be but the the fact the exception is about the build section I'm not convinced that is the problem.


Would it be possible for you sort this out and post what the correct code should be.


I haven't tried AddCopyFilesBuildPhase.


Thanks.





Unity 5.6.1. Xcode 8.3.3.

Hi,


When building from Unity, if you select Append instead of Replace, the Xcode settings for Bitcode and Embedded Binary will stay the same, so you don't need to reset them every time you run. 


Unfortunately, Unity doesn't have a way to make these changes in the Editor. The Bitcode setting can be set through scripting by using the PBXProject API, but last I checked there is no API for setting Embedded Binaries.


Is there a particular reason why you cannot use Append when building?


Best regards,

Alexandru.

Ah yes Append does relieve the problem somewhat, thank you.


Presumably this means we won't be able to use remote building such as Cloud Build or Team City which will be a big problem for us.


Is there a work around for that, or will this problem go away in future Wikitude releases or perhaps you could request from Unity the ability to set Embedded Binaries in a future version.


Thanks.

I've tried and failed to resolve this issue, I've updated my findings here: 

https://issuetracker.unity3d.com/issues/embedded-binaries-function-in-xcode-manipulation-api


Although I'm not sure anyone from Unity is actually following that thread, there should be a big resolution failed button.


Is it possible for you to push Unity on this, I assume you would get more traction than a single developer?


Alternatively could you share your solution if you have one, having to manually make all the builds is a massive pain.


Thanks.



Hi,


As far as I know there is no workaround at the moment for this issue. We've also struggled with this problem, and what we ended up doing is modifying the PBXProject API to support it. The source code is publicly available here. There is also an open feature request on their issue tracker, which says that the issue is "Fixed in a future release" so I'm hopeful it will actually be released soon.


You can find more details about how to modify the sources here.


Best regards,

Alexandru.

Login or Signup to post a comment