OneSignal-Unity-SDK icon indicating copy to clipboard operation
OneSignal-Unity-SDK copied to clipboard

[Bug]: iOS BuildPostProcessor.cs - Missing UNITY_IOS flag?

Open pettersaiteppeland opened this issue 3 years ago • 5 comments

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 avatar May 28 '22 07:05 pettersaiteppeland

@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 avatar May 31 '22 18:05 jkasten2

@jkasten2 Did you try building on a Linux machine? For now, we have embeded the iOS package and added the UNITY_IOS #if check bilde

pettersaiteppeland avatar Jun 08 '22 12:06 pettersaiteppeland

OneSignal Unity SDK version 3.0.3 BuildPostProcessor.cs PBXProjectExtensions.cs also have this problem @jkasten2

s-pumpkin avatar Aug 20 '22 11:08 s-pumpkin

Do you have any temporary fix for that? I've added the if IOS code, but those files are refreshed during build process

CCOdawid avatar Aug 22 '22 08:08 CCOdawid

@CCOdawid
My current approach is to put com.onesignal.unity.ios Move to project and add #if UNITY_IOS

yolin0120 avatar Aug 22 '22 08:08 yolin0120

@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

PinkiiVoodoo avatar Oct 28 '22 07:10 PinkiiVoodoo

Added this fix in the 3.0.6 release with #556 Feel free to reopen if you are still experiencing issues

shepherd-l avatar Nov 18 '22 17:11 shepherd-l