You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
use_native_modules! skipped the react-native dependency 'react-native-unity-view'. No podspec file was found. in IOS only. #136
Since 0.60 RN has moved to CocoaPods as default for dependency management. It would be best to add a Podspec for this project. @f111fei any plans to do so?
We are successfully using Pods to manage react-native-unity-view (we're using a forked version of this library, since it may be unmaintained; see #141).
For anyone interested:
Add a Podspec file at root of react-native-unity-view. You will need to adjust the s.source value to match your fork's location. We are using an add-podspec branch as per the below:
Fix the header search paths for RNUnityView after it is compiled as a target of your Pods project during pod install. This ensures that the Pods-managed version of RNUnityView can find files in the UnityExport directory as well as React dependencies. This is what works for us:
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'RNUnityView'
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] ||= "$(inherited)"\
" $(PODS_ROOT)/../../node_modules/React/**"\
" $(PODS_ROOT)/../../node_modules/react-native/React/**"\
" $(PODS_ROOT)/../UnityExport/Classes"\
" $(PODS_ROOT)/../UnityExport/Classes/Unity"\
" $(PODS_ROOT)/../UnityExport/Libraries"\
" $(PODS_ROOT)/../UnityExport/Libraries/libil2cpp/include"\
" $(PODS_ROOT)/../UnityExport/Libraries/bdwgc/include"
end
end
end
end
cd ios && pod install
Notes:
If you have header/library/framework search paths to UnityExport files in your parent project, you can probably remove them as the Pods-managed RNUnityView will receive its own updated paths as per step 3 above.
We found that once RNUnityView is managed by Pods, the target RNUnityView Xcode project in the Pods project of our Workspace did not preserve the header search paths set to the Xcode project in this project repository. Hence, the extra step to update the header search paths in the post_install hook.
Make extra sure to avoid setting recursive header search paths to the UnityExport directory. We had done this while troubleshooting RNUnityView being unable to find UnityExport deps. And there are files, such as /UnityExport/Libraries/libil2cpp/include/icalls/mscorlib/System/String.h, that name collide with standard C++ library headers, causing builds to fail (often with hard to debug errors like 'limits' file not found)
One more thing. On our CI, the Podspec wasn't passing validation because the description field in package.json passed to summary attribute in Podspec was an empty string. We fixed by updating package.json like so, from the README:
"description": "Integrate unity3d within a React Native app. Add a react native component to show unity. Works on both iOS and Android.",
@marlon-wiprud can you send your ios/Podfile? Your React deps should all be managed there.
@ziyoshams is right, that the header search paths of RNUnityView will determine whether or not it can find React files. The problem is that CocoaPods works by accumulating all Podfile dependencies into a custom Pods project. In that process, header search paths set in this lib's RNUnityView.xcodeproj get nuked.
You can inspect what's set after running pods install by looking at the Targets listed in the Pods project in your workspace. So with Pods selected in the main nav, hit the dropdown or expand the project sidebar:
Select RNUnityView, and look at "Build Settings > Header Search Paths". You should see this:
Looking back at this, I think RNUnityView does not explicitly need to have React paths added once it's also managed using CocoaPods along with React Native. So these two lines can be removed from step 3 above:
We had remnants of getting Pods working in React Native < 0.60 in our Podfile, which required removing React deps from the Pods project within post_install hook.
Hi @benjarwar, thank you for the .podspec! I was able to pass through the .a files not being found; however, I got this error now in the Linking step of the build process, any chances you might have encounter it?
Not sure if I am missing something. I have made the link process manually:
add RNUnityView.xcodeproj to the Libraries folder of my XCode Project;
add libRNUnityView.a to the Link Binary With Libraries;
I have exported my unity project and added to ios folder, like this: ios/UnityExport.
I did not add the UnityConfig.xconfig file to XCode (not using it at all). Is it needed now that we are using CocoaPods?
I also do not have the UnityExport folder inside my XCode project, do I need to move it manually? If yes, should I also copy the resources?
@gustavobuttenbender Yes you need UnityConfig.xconfig because it contains needed flags for compiler. The thing you don't need is to link the library manually. Linking is taken care by podspec.
@ziyoshams Ok! Do you know how should I use the UnityConfig.xconfig with CocoadPods? Should I merge the .config into my PODS-{PROJECT_TARGET}.xconfig file?
@ziyoshams but currently I point to the PODS-{TARGET}.debug/release in my root Project configuration. I couldn't just start pointing to UnityConfig.xconfig, right?
Not sure why, but it's compiling without errors for me now. But I have a really weird bug now (iOS), that only occurs after adding react-native-unity-view-reinvented: The whole layout of my app seems to be reversed. For example If i left align text, the text will be right aligned and vise versa. Also flexDirection seems to be reversed, as by default elements are arranged from bottom to top.
Even with the default react native example app, the same effect occurs.
@megasus that issue has happened to me in 2 different projects after integrating RN Unity View. It might be related to where you added the #import line in the UnityConfig.xcconfig file.
Turns out that the #import line has to be added at the bottom of the file, not at the top.
@jeserodz First of all, thanks a lot for all your work, brought me quite a step further.
Unfortunately I am not able to build integrate RNUnityView completely... I always end up in the error [...]/node_modules/react-native-unity-view-reinvented/ios/UnityUtils.mm:39:5: error: use of undeclared identifier 'UnityInitStartupTime' UnityInitStartupTime();
Do you have any hint what this could be? Or even better, a demo project which you managed to get it running? Again, thanks you very much for your help!
@nicost71 Can you give a try removing that line and running the app? I have integrated this to multiple Unity + RN projects lately, and one of them showed this issue. After removing the line and building to see what would happen, it worked as expected.
About the root cause of the error, we would need to look further, but I think it might be related to the Unity version used when exporting to Xcode.
@jeserodz I am using Unity 2019.2.14f1 together with "react-native-unity-view-reinvented": "^1.4.2" and "react-native": "0.61.5"...
When I comment this line of code I got the error posted below. When I uncommented it again, I did not get the "UnityInitStartupTime()" Error anymore for some reason, but the same as with the commented code: [...]//UnityExport/Classes/DynamicLibEngineAPI.mm:138:14: fatal error: 'Classes/iPhone_Sensors.h' file not found #include "Classes/iPhone_Sensors.h"
If I change this line to "#include "iPhone_Sensors.h", the code compiles "forever" (over 45 mins now...)
As I am rather new to RN + Unity, I am quite struggling, if my entire setup is correctly working (with settings taken from Podfile, and no manual "hacks"). Do you have any "demo-project" you are willing to share with us, demonstrating a working setup? I know it's asked a lot, but I am sure many would profit from your expertise :-)
@nicost71 - I'll try to put together a working example project for you to reference. I'm sorry I am not able to share the codebases of the projects I'm working with this library.
However, the error you mentioned is progress in the setup. Remove "Classes/" from "Classes/iPhone_Sensors.h" and build again. (you'll notice that the file iPhone_Sensors.h is actually in the same directory as DynamicLibEngineAPI.mm).
@jeserodz Thanks so much! An example project will for sure help me (and certainly others) building RN&Unity Apps, and push this even further. As mentioned before, I did try with stripping the "Classes/" from the include, which (btw. same result as removing the references to DynamicLibEngineAPI.mm) resulted in building forever...
@sburaksak not sure, and I'm no longer working on a React Native/Unity project. I do remember having issues when we tried exporting with 2019 Unity builds, which seemed to have compatibility issues with this library (which has not been well-maintained for quite some time). I believe we were stuck on Unity 2018.2.5f1.
@ziyoshams hi, when i try to run the example from the repo you posted, i get this build error in xcode Undefined symbols for architecture arm64: "_onUnityMessage", referenced from: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36 in Assembly-CSharp.o (maybe you meant: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
i've done correctly all the steps, i'm on unity 2019.3.0f6. Any idea how to solve this problem?
@fabioglimb I have not run the example app from that repo. I just followed the installation steps for my project and it is pretty stable. I have seen that error that you are getting and I think it was related to Unity Versions. I can't confirm the Unity version that I used since I no longer work on that project. Try implementing it to your own project, maybe you won't get that error.
Activity
ziyoshams commentedon Oct 4, 2019
This is fine as long as you add the library manually.
benjarwar commentedon Nov 7, 2019
Since
0.60RN has moved to CocoaPods as default for dependency management. It would be best to add a Podspec for this project. @f111fei any plans to do so?benjarwar commentedon Nov 19, 2019
We are successfully using Pods to manage
react-native-unity-view(we're using a forked version of this library, since it may be unmaintained; see #141).For anyone interested:
react-native-unity-view. You will need to adjust thes.sourcevalue to match your fork's location. We are using anadd-podspecbranch as per the below:package.json, adding ahomepageattribute required by Podspecpod install. This ensures that the Pods-managed version of RNUnityView can find files in theUnityExportdirectory as well as React dependencies. This is what works for us:cd ios && pod installNotes:
UnityExportfiles in your parent project, you can probably remove them as the Pods-managed RNUnityView will receive its own updated paths as per step 3 above.post_installhook.UnityExportdirectory. We had done this while troubleshooting RNUnityView being unable to find UnityExport deps. And there are files, such as/UnityExport/Libraries/libil2cpp/include/icalls/mscorlib/System/String.h, that name collide with standard C++ library headers, causing builds to fail (often with hard to debug errors like'limits' file not found)ziyoshams commentedon Nov 20, 2019
Awesome job
benjarwar commentedon Nov 20, 2019
One more thing. On our CI, the Podspec wasn't passing validation because the
descriptionfield inpackage.jsonpassed tosummaryattribute in Podspec was an empty string. We fixed by updatingpackage.jsonlike so, from the README:marlon-wiprud commentedon Nov 21, 2019
Finally getting a chance to try out some of these solutions - thanks a ton for supplying the approach you took @benjarwar .
After implementing the above steps, I am running into this error:
Property 'eventDispatcher' not found on object of type 'RCTBridge *'wondering if anyone else has encountered this?
ziyoshams commentedon Nov 21, 2019
@marlon-wiprud Any error that is related to React is your
Header Search Pathsfor this package.benjarwar commentedon Nov 21, 2019
@marlon-wiprud can you send your
ios/Podfile? Your React deps should all be managed there.@ziyoshams is right, that the header search paths of
RNUnityViewwill determine whether or not it can find React files. The problem is that CocoaPods works by accumulating all Podfile dependencies into a customPodsproject. In that process, header search paths set in this lib's RNUnityView.xcodeproj get nuked.You can inspect what's set after running
pods installby looking at the Targets listed in thePodsproject in your workspace. So withPodsselected in the main nav, hit the dropdown or expand the project sidebar:Select
RNUnityView, and look at "Build Settings > Header Search Paths". You should see this:benjarwar commentedon Nov 21, 2019
Looking back at this, I think RNUnityView does not explicitly need to have React paths added once it's also managed using CocoaPods along with React Native. So these two lines can be removed from step 3 above:
We had remnants of getting Pods working in React Native <
0.60in our Podfile, which required removing React deps from the Pods project withinpost_installhook.gustavobuttenbender commentedon Nov 26, 2019
Hi @benjarwar, thank you for the .podspec! I was able to pass through the
.afiles not being found; however, I got this error now in the Linking step of the build process, any chances you might have encounter it?Not sure if I am missing something. I have made the link process manually:
Librariesfolder of my XCode Project;Link Binary With Libraries;I have exported my unity project and added to ios folder, like this:
ios/UnityExport.I did not add the
UnityConfig.xconfigfile to XCode (not using it at all). Is it needed now that we are using CocoaPods?I also do not have the UnityExport folder inside my XCode project, do I need to move it manually? If yes, should I also copy the resources?
Any help would be much appreciated. Thanks!
ziyoshams commentedon Nov 26, 2019
@gustavobuttenbender Yes you need
UnityConfig.xconfigbecause it contains needed flags for compiler. The thing you don't need is to link the library manually. Linking is taken care by podspec.gustavobuttenbender commentedon Nov 26, 2019
@ziyoshams Ok! Do you know how should I use the
UnityConfig.xconfigwith CocoadPods? Should I merge the.configinto myPODS-{PROJECT_TARGET}.xconfigfile?ziyoshams commentedon Nov 26, 2019
@gustavobuttenbender You don't do anything else with that file besides the steps in the docs.
gustavobuttenbender commentedon Nov 26, 2019
@ziyoshams but currently I point to the
PODS-{TARGET}.debug/releasein my root Project configuration. I couldn't just start pointing toUnityConfig.xconfig, right?ziyoshams commentedon Nov 27, 2019
@gustavobuttenbender In
UnityConfigfile you should have a line that includes youpods. Open that file and you should see something like this:3 remaining items
megasus commentedon Dec 6, 2019
@gustavobuttenbender Have you managed to get it running? I have the same set of errors.
My steps:
ios/${XcodeProjectName}/#include "../Pods/Target Support Files/Pods-YOU-PROJECT-NAME/Pods-YOU-PROJECT-NAME.debug.xcconfig"to top of UnityConfigDid I miss sth.?
megasus commentedon Dec 9, 2019
Not sure why, but it's compiling without errors for me now. But I have a really weird bug now (iOS), that only occurs after adding react-native-unity-view-reinvented: The whole layout of my app seems to be reversed. For example If i left align text, the text will be right aligned and vise versa. Also flexDirection seems to be reversed, as by default elements are arranged from bottom to top.
Even with the default react native example app, the same effect occurs.
jeserodz commentedon Dec 9, 2019
@megasus that issue has happened to me in 2 different projects after integrating RN Unity View. It might be related to where you added the
#importline in theUnityConfig.xcconfigfile.Turns out that the #import line has to be added at the bottom of the file, not at the top.
See here for more details.
megasus commentedon Dec 10, 2019
@jeserodz Amazingly, that worked. Thank you!
nicost71 commentedon Dec 18, 2019
@jeserodz First of all, thanks a lot for all your work, brought me quite a step further.
Unfortunately I am not able to build integrate RNUnityView completely... I always end up in the error
[...]/node_modules/react-native-unity-view-reinvented/ios/UnityUtils.mm:39:5: error: use of undeclared identifier 'UnityInitStartupTime' UnityInitStartupTime();Do you have any hint what this could be? Or even better, a demo project which you managed to get it running? Again, thanks you very much for your help!
jeserodz commentedon Dec 18, 2019
@nicost71 Can you give a try removing that line and running the app? I have integrated this to multiple Unity + RN projects lately, and one of them showed this issue. After removing the line and building to see what would happen, it worked as expected.
About the root cause of the error, we would need to look further, but I think it might be related to the Unity version used when exporting to Xcode.
nicost71 commentedon Dec 18, 2019
@jeserodz I am using Unity 2019.2.14f1 together with "react-native-unity-view-reinvented": "^1.4.2" and "react-native": "0.61.5"...
When I comment this line of code I got the error posted below. When I uncommented it again, I did not get the "UnityInitStartupTime()" Error anymore for some reason, but the same as with the commented code:
[...]//UnityExport/Classes/DynamicLibEngineAPI.mm:138:14: fatal error: 'Classes/iPhone_Sensors.h' file not found #include "Classes/iPhone_Sensors.h"If I change this line to "#include "iPhone_Sensors.h", the code compiles "forever" (over 45 mins now...)
As I am rather new to RN + Unity, I am quite struggling, if my entire setup is correctly working (with settings taken from Podfile, and no manual "hacks"). Do you have any "demo-project" you are willing to share with us, demonstrating a working setup? I know it's asked a lot, but I am sure many would profit from your expertise :-)
jeserodz commentedon Dec 18, 2019
@nicost71 - I'll try to put together a working example project for you to reference. I'm sorry I am not able to share the codebases of the projects I'm working with this library.
However, the error you mentioned is progress in the setup. Remove "Classes/" from "Classes/iPhone_Sensors.h" and build again. (you'll notice that the file
iPhone_Sensors.his actually in the same directory asDynamicLibEngineAPI.mm).However,
DynamicLibEngineAPI.mmcan actually be removed altogether in most cases. Checkout this jiulongw/swift-unity#120 (comment)nicost71 commentedon Dec 18, 2019
@jeserodz Thanks so much! An example project will for sure help me (and certainly others) building RN&Unity Apps, and push this even further. As mentioned before, I did try with stripping the "Classes/" from the include, which (btw. same result as removing the references to DynamicLibEngineAPI.mm) resulted in building forever...
sburaksak commentedon Feb 12, 2020
@megasus I followed your steps, but could not get successfully build.
Errors are below. Can you help me, thank you so much?
@jeserodz I am using reinvented fork, what should for this error? @benjarwar
benjarwar commentedon Feb 12, 2020
@sburaksak not sure, and I'm no longer working on a React Native/Unity project. I do remember having issues when we tried exporting with 2019 Unity builds, which seemed to have compatibility issues with this library (which has not been well-maintained for quite some time). I believe we were stuck on Unity
2018.2.5f1.ziyoshams commentedon Mar 1, 2020
For folks who are using latest Unity, i can confirm that https://github.com/asmadsen/react-native-unity-view package works very well with minimal effort.
fabioglimb commentedon Apr 7, 2020
@ziyoshams hi, when i try to run the example from the repo you posted, i get this build error in xcode
Undefined symbols for architecture arm64: "_onUnityMessage", referenced from: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36 in Assembly-CSharp.o (maybe you meant: _UnityMessageManager_onUnityMessage_m8A904C01129EA827FDD76B08B34FAF9A6C4B5E36) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)i've done correctly all the steps, i'm on unity 2019.3.0f6. Any idea how to solve this problem?
ziyoshams commentedon Apr 7, 2020
@fabioglimb I have not run the example app from that repo. I just followed the installation steps for my project and it is pretty stable. I have seen that error that you are getting and I think it was related to Unity Versions. I can't confirm the Unity version that I used since I no longer work on that project. Try implementing it to your own project, maybe you won't get that error.
akroshteotia commentedon Aug 21, 2021
If still someone looking for solution i have made a folks to run on Unity 2019 https://github.com/akroshteotia/react-native-unity-view