OneSignal / OneSignal-Unity-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Unity app with OneSignal. https://onesignal.com
Other
222 stars 61 forks source link

Can't build for iOS: building for iOS, but linking in dylib file built for Mac Catalyst #487

Open CyrilGC opened 2 years ago

CyrilGC commented 2 years ago

Description: I just updated the SDK from 2.14.6 to 3.0.1. Everything is fine on Android but on iOS, I get the following error when the Xcode project gets compiled:

building for iOS, but linking in dylib file (/Users/cyril/Library/Developer/Xcode/DerivedData/Unity-iPhone-braqpnxgmoetzydutycizcruiwpn/Build/Products/Debug-iphoneos/OneSignal.framework/OneSignal) built for Mac Catalyst, file '/Users/cyril/Library/Developer/Xcode/DerivedData/Unity-iPhone-braqpnxgmoetzydutycizcruiwpn/Build/Products/Debug-iphoneos/OneSignal.framework/OneSignal' for architecture arm64

This is similar to the issue described here: https://github.com/OneSignal/react-native-onesignal/issues/1234 I cleaned my cache, deleted everything in the derived data folder and I still get the same error.

Environment Unity version: 2020.3.26f1 One Signal SDK: 3.0.1

Steps to Reproduce Issue:

  1. Update the OneSignalSDK to 3.0.1 using Package Manager
  2. Build
jkasten2 commented 2 years ago

@CyrilGC Thanks for reporting. The error notes that OneSignal.framework was used. However OneSignal.xcframework should have been used instead.

I am not sure how that could have been used, however there are few things you can check for.

  1. Ensure you have delete the old Assets/OneSignal folder.
  2. Make sure you do a clean build to a new folder in Unity (instead of appending).
  3. Make sure you open the .xcworkspace file with XCode, instead of the .xcodeproj.

If the above doesn't help we will need some more details:

  1. Do you have any other plugins in your Project that have iOS components?
  2. Are you able to reproduce the issue with a new Unity project?
CyrilGC commented 2 years ago

@jkasten2 Thanks for the response. I needed to produce a build last week and went back to the older version of the plugin. I encountered the same error and was only able to get rid of it after cleaning my repo with git clean -fdx I was really hopeful that I could resolve the issue with the new SDK the same way, unfortunately, I'm still getting the same error.

I confirm that I deleted the Asset/OneSignal folder. I always clean up before building (it happens with the first build anyway, after the Xcode project is generated by Unity). I also confirm I'm opening the workspace and not the project. Opening the project only would result in a different error which has been reported by someone else in a different ticket.

We're using other plugins. I'm not sure if I can list them all here. One that we are using that could be relevant is the Unity Mobile Notification plugin. Note that the One Signal SDK is part of a shared project that is used as a custom package to 2 the projects. I have not tried a new Unity Project.

CyrilGC commented 2 years ago

@jkasten2 Good news, I was able to fix the issue. The pods were what was causing the issue. I started by cleaning my pods, then deintegrate and reinstall:

rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
sudo gem install cocoapods-clean
pod deintegrate
pod clean
pod install

I was then able to build the Xcode project. But after deleting the Xcode folder, and regenerating from Unity, there was no workspace generated anymore and I was getting the same error as here: https://github.com/OneSignal/OneSignal-Unity-SDK/issues/468

I then uninstall cocoapods: sudo gem uninstall cocoapods I then started getting an error from Unity where it couldn't install the pods. I unchecked the option "Use Shell to Execute Cocoapod Tool" in the iOS resolver, and it seems to be working correctly now. I can press build & run from Unity, and it works.

I'm not very familiar with Xcode and Cocoapods so I'm not sure what steps are really necessary in the end.

jkasten2 commented 2 years ago

@CyrilGC Good to hear you got it working! Hard to say what was the root cause was in your case. However the commands you listed above would ensure you have a clean Cocoapods setup, as well as Xcode's DerivedData reset to ensure nothing cache wise is carrying over.