[Bug]: iOS BuildPostProcessor.cs - Missing UNITY_IOS flag?
What happened?
When building for Windows, Mac, Android or WebGL I get the following error:
Library/PackageCache/[email protected]/Editor/BuildPostProcessor.cs(56,19): error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?) Library/PackageCache/[email protected]/Editor/BuildPostProcessor.cs(60,19): error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?) Library/PackageCache/[email protected]/Editor/PBXProjectExtensions.cs(28,19): error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?) Library/PackageCache/[email protected]/Editor/BuildPostProcessor.cs(83,26): error CS0246: The type or namespace name 'PBXProject' could not be found (are you missing a using directive or an assembly reference?) Library/PackageCache/[email protected]/Editor/PBXProjectExtensions.cs(33,53): error CS0246: The type or namespace name 'PBXProject' could not be found (are you missing a using directive or an assembly reference?) Library/PackageCache/[email protected]/Editor/PBXProjectExtensions.cs(36,53): error CS0246: The type or namespace name 'PBXProject' could not be found (are you missing a using directive or an assembly reference?)
Which makes sense, since the BuildPostProcessor script contains iOS specific code that is not excluded on non-iOS platforms. I can build locally in my Windows Unity Editor, but not on the build pipeline which is a Linux machine. Not sure what makes the difference and I am suprised it works locally.
Steps to reproduce?
1. On linux, install the One Signal plugin, Core and iOS
2. Start a build for a non iOS platform
3. Observe that the build fails with the errors mentioned above
What did you expect to happen?
The build should complete successfully
Unity version
2020.3.23
OneSignal Unity SDK version
3.0.2
Platform
Android, Other
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@pettersaiteppeland Thanks for reporting, I took a quick look a the source and don't see anything limiting the code from compile, with UNITY_IOS or the .meta file. We will look into preventing this in a future update.
@jkasten2 Did you try building on a Linux machine?
For now, we have embeded the iOS package and added the UNITY_IOS #if check

OneSignal Unity SDK version 3.0.3 BuildPostProcessor.cs PBXProjectExtensions.cs also have this problem @jkasten2
Do you have any temporary fix for that? I've added the if IOS code, but those files are refreshed during build process
@CCOdawid
My current approach is to put com.onesignal.unity.ios
Move to project and add #if UNITY_IOS
@jkasten2 The problem is when trying to compile the project without the Unity iOS module installed. As the BuildPostProcessor is trying to use iOS specific code. Just applying the #532 PR would fix that https://github.com/OneSignal/OneSignal-Unity-SDK/blob/f93cbbeceda3ee68089b9c660d8e94980e894cdd/com.onesignal.unity.ios/Editor/BuildPostProcessor.cs#L56