Hi Uniteers, I have switched to XCode Beta version 7.0 Beta 6 and whenever I am building to iOS i have to manually set the “Enable Bitcode” from “ON” to “OFF” otherwise I can’t deploy the build. Is there a way to set the default value to “OFF” when building or do I have to do some post build processing?
Which Unity version are you on?
We will be shipping patch release with “off” as default soon.
I am using Unity 5.1.3f1 Personal
Hi Freaking-Pingo,
Do you get the solution for it? I’m having the same issue in my project.
Thanks.
I haven’t tested it yet, but a co-worker of mine stated after upgrading to Unity 5.2, bitcode is disabled by default.
Bit code is enabled for Unity 4.6 iOS exports… very inconvenient, we can’t use bit code yet (lots of 3rd party ad sdks don’t support it)… I have to manually disable it with every build. Or find a way to script that part,… like a zillion other parts with every build :-/
You can use Xcode API in a post process step to disable the bitcode setting.
Nice. Didn’t know that stuff existed. Will have to remember next time.
Built an iOS Xcode pjt and bit code was enabled. Unity 5.3.1p2. Has this issue been addressed?
Unity 5.3.1p3 also had bit code enabled by default. is that going to be addressed?
Unity 5.3 is expected to have Bitcode on by default if you are using IL2CPP scripting backend as it’s direction where iOS development is moving in general (it’s already mandatory for tvOS submissions).
If you depend on some specific plugin, which doesn’t ship with Bitcode you should reach plugin providers for Bitcode enabled version of plugin.
P.S. if you see Bitcode being enabled on for Mono backend builds, then it’s a bug and please let us know. (I believe fix was done for some patch release already).
Do you have an example of how to use this? I get into PBXPRoject but at that point I don’t know what kind of property to set or what strings to use. Any help would be appreciated.
Here’s some example code that seems to use these functions. Let us know if you get it to work and what helped.
This seems to work for me. Will check if it works in a cloud build and I can confirm then:
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using UnityEditor.iOS.Xcode;
using System.IO;
public class BL_BuildPostProcess
{
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
string target = proj.TargetGuidByName("Unity-iPhone");
proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");
File.WriteAllText(projPath, proj.WriteToString());
}
}
}
Thanks for this, saved me!
What do you do with this script? Just make a file in your assets folder or add it to a game object or what?
Ah, put it in your Editor folder and thats it? It works in the cloud build?
When building in the cloud, you first have to build an IOS project in unity normally? Can’t just commit the new file to the repo and expect unity cloud build to work?
Yeah, just add the file to your editor folder and commit it to the branch that your cloud build is directed.
This works great on my end.
Follow up question, is there a list of properties we could modify with BuildPostProcess? What I am looking to modify is the Language - Modules of the app to get rid of the inflate errors on cloud build.
Sorry for the late reply! Yes you put it in an Editor folder and it should work.
When Cloud building you do not need an iOS project. Just point it to your project depot on Git/Mercurial which needs to contain only the Assets and ProjectSettings folders. Do not include the library.
So easy!
You might run into build issues later, but this is all you need to get started.
I wish I knew where this list of properties can be found. I’ve asked around but not found it. Just been picking and choosing code examples.
Here’s what I have so far. Pick and use anything you need!
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using UnityEditor.iOS.Xcode;
using System.IO;
public class BL_BuildPostProcess
{
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
/* .xcodeproj/project.pbxproj */
//Get path to the PBX project
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
//Read the pbx project
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
//Get the build target
string target = proj.TargetGuidByName("Unity-iPhone");
//set ENABLE_BITCODE to false (this shouldn't be required in Unity 5.2+)
proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");
//Write back out the PBX project
File.WriteAllText(projPath, proj.WriteToString());
/* Info.plist */
// Read the Info.plist file
string plistPath = path + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root of plist
PlistElementDict rootDict = plist.root;
//Set Requires full screen = true. This was needed only with Xcode 9.
rootDict.SetBoolean("UIRequiresFullScreen",true);
//Adding background modes for remote notification (For Push notifications - OneSignal)
var bgModes = rootDict.CreateArray("UIBackgroundModes");
bgModes.AddString("remote-notification");
//Write out the Info.plist file
plist.WriteToFile(plistPath);
}
}
}