viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

v2.13.0 + RN0.57.7 not working when not using !use_frameworks #542

Closed skizzo closed 5 years ago

skizzo commented 5 years ago

Hi,

first and foremost, thanks for this amazing library! I really want to integrate it into my existing RN project, but I just can't make it work without using use_frameworks! in my Podfile. Using it is not an option, it would break many of my other dependencies in the project.

I am aware that there are similar issues (Cannot upgrade to v2.3.0 because of use-frameworks!, Issues building for iOS and use_frameworks) but most of them are almost a year old and none of the suggested solutions there could fix my problem.

The error

No matter what I do, I always end up getting this error when running the debug version on the iOS simulator, on app launch, showing up in the XCode console:

dyld: Library not loaded: @rpath/AWSCore.framework/AWSCore Referenced from: /Users/steff/Library/Developer/CoreSimulator/Devices/A71C73DE-6CAC-4FDD-A80D-29FA591D731B/data/Containers/Bundle/Application/19BB82C8-75FC-4B19-B124-EAFEB55FAEBC/iazzu.app/Frameworks/ViroKit.framework/ViroKit Reason: image not found

Steps to reproduce

Your docs page Integrating w/o use_frameworks! (Cocoapods) suggests that starting with version 2.8.0, users are not forced to use use_frameworks! any more ("Starting with ViroReact 2.8.0 we have started including our static library (without the need for relying on use_frameworks! in the ViroReact package that you get from npm itself."). As great as this sounds in theory, it doesn't work and leads to the error mentioned above.

What I do to install react-viro, step by step:

  1. Add "react-viro", "2.13.0" to my package.json
  2. run npm install
  3. Add pod 'ViroReact', :path => '../node_modules/react-viro/ios/'and pod 'ViroKit', :path => '../node_modules/react-viro/ios/dist/ViroRenderer/' to my Podfile, along with this little post install script to prevent the error with vlog_is_on.oo. <-- See the comment below, this was the mistake
  4. run pod install in the iOS directory
  5. Open XCode workspace
  6. Set Enable Bitcode to No in project settings
  7. Build app in debug mode on iOS simulator
  8. --> Error mentioned above

What I tried to fix the error

Disclaimer: I have no idea what I'm doing, just trying everything here.

  1. Added libViroReact.a (node_modules/react-viro/ios/dist/static_lib/libViroReact.a) to the Link Binary with Libraries section in my target. Same error.

  2. Added ViroKit.framework (node_modules/react-viro/ios/dist/ViroRenderer/ViroKit.framework) to the Link Binary with Libraries section in my target. Same error.

  3. Followed the instructions here and added the AWS iOS SDK to my project using Carthage, and effectively added AWSCore.framework and AWSDynamoDB.framework to my project. Same error.

Environment

Podfile

So here's the content of my Podfile, just in case:

platform :ios, '9.3'

target 'iazzu' do
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  project 'iazzu.xcodeproj'

  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  pod 'OpenCV', '3.2'

  pod 'Firebase', '4.11.0'
  pod 'Firebase/Core', '4.11.0'
  pod 'Firebase/Messaging', '4.11.0'
  pod 'Firebase/Database', '4.11.0'
  pod 'Firebase/Crash', '4.11.0'
  pod 'Firebase/Auth', '4.11.0'
  pod 'Firebase/Storage', '4.11.0'
  pod 'FirebaseInstanceID'

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'ART',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]
  pod 'yoga', :path => "../node_modules/react-native/ReactCommon/yoga"

  pod 'react-native-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'react-native-google-maps', path: rn_maps_path
  pod 'ViroReact', :path => '../node_modules/react-viro/ios/'
  pod 'ViroKit', :path => '../node_modules/react-viro/ios/dist/ViroRenderer/'

end

# Otherwise there is an error while archiving https://stackoverflow.com/a/46678210/2455710
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
  # See https://github.com/facebook/react-native/issues/18022#issuecomment-372760977
  system(". ./pod_post_install.sh")
end

Thanks for pointing me into the right direction folks.

skizzo commented 5 years ago

Okay, seems like I didn't properly set this up initially.

It turns out that I put the wrong path to ViroKit into my Podfile, since I don't use use_frameworks!, I should have just followed the instructions on the Integrating w/o use_frameworks! (Cocoapods) docs page and actually put

pod 'ViroKit_static_lib', :path => '../node_modules/react-viro/ios/dist/ViroRenderer/static_lib'

there (instead of pod 'ViroKit', :path => '../node_modules/react-viro/ios/dist/ViroRenderer/', which only works when using use_frameworks!). Duh. Closing this myself, thank you very much.