I tried to build my existing Unity 2019.4.40 app with Xcode 14, but ran into build errors due to missing Bitcode. After searching on Apple’s forums, I found out that this can be resolved by enabling Bitcode for all build targets under the Pods project, but it is pretty annoying to do this manually after any build. Can this be automated somehow?
Funny side note: I just learned that Xcode 14 deprecates Bitcode:
So why the heck is it enfording Bitcode enablement now for an existing Unity project that built just fine with Xcode 14?! This does not make any sense to me.
I’m having the same issue on Unity 2020.3.39 with a project that was working before I upgraded to Xcode 14. I get the Bitcode build error for one of the 3rd party Pods I’m using
I added the following to my podfile until this can be resolved. I only needed it for one target. You could remove the if check if you need it for more than a named target.
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "MSAL"
puts "Processing for enable bit code"
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'YES'
end
end
end
end
How do you modify the podfile from within Unity?
I need a custom podfile for my project so I’m adding my podfile as a post build process using this api and putting a File.Copy to move it to the correct location : : Unity - Scripting API: Build.IPostprocessBuildWithReport.OnPostprocessBuild
Thanks for the clarification!
@waldgeist Thanks for opening this thread. I attempted to update to latest 2020 LTS hoping Unity introduced a fix, but alas no.
I had a separate question; are you also finding that the Xcode project created by Unity no longer retains the “Display Name”, “Version”, and “Build” anymore? I only recently updated to Xcode 14.
Oh. Just checked this with Unity 2019.4, and yes: these infos are indeed missing. Any more “surprises”?
Damn. I knew I should never update to the latest macOS. Now I am forced to use Xcode 14 or downgrade my Mac again.
Still missing any info why Xcode is all of the sudden requiring Bitcode?
Apprently because of this: https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes
Specifically this part:
Currently looking for a solution too.
Fixed all my builds by doing this:
[PostProcessBuild(999)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget != BuildTarget.iOS)
{
return;
}
var projPath = PBXProject.GetPBXProjectPath(path);
var project = new PBXProject();
project.ReadFromFile(projPath);
var mainTargetGuid = project.GetUnityMainTargetGuid();
foreach (var targetGuid in new[] {mainTargetGuid, project.GetUnityFrameworkTargetGuid()})
{
project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
}
project.WriteToFile(projPath);
}
Confirm this resolved my problem, since there is no “Enable Bitcode” in building settings in xcode 14, this process will add that option there for every target
Where to add that code?
Guys please give few more details, not everyone is an experience developer
Simply add this as .cs script anywhere in Assets folder
Sorry to rev thread, but I’m getting an error when trying to compile this as a script:
error CS0106: The modifier 'public' is not valid for this item
Any idea how to go about fixing this?
This method has to be put in a class. The example provided does not define any class.
Ah, thanks a lot, that did it!
I’m getting new errors, saying that the type or namespace for ‘BuildTarget’, ‘PostProcessBuildAttribute’, and ‘PostProcessBuild’ could not be found. Do i need to define these variables in the script, or import a specific namespace?
Apologies if I’m missing something very obvious, I am very new to programming in Unity.
Correct, this error usually shows up when you need to import a namespace. in this case it looks like you need at least “using UnityEditor” and “using UnityEditor.Callbacks” at the top of the file
If you’re using the included Visual Studio, you can get hints on the needed namespace by right clicking the error in VS and looking at “quick actions and refactoring” in the context menu
Otherwise you can check the documentation, most example code will have the necessary includes