dagronf / QRCode

A quick and beautiful macOS/iOS/tvOS/watchOS QR Code generator/detector library for SwiftUI, Swift and Objective-C.
MIT License
407 stars 56 forks source link

Integrate this library to be used by watchOS with a React Native iOS Project #49

Closed joaonew closed 1 week ago

joaonew commented 3 weeks ago

Hello there,

I was able to implement this library in the native side with Swift and installing the package dependencies through Xcode, but when I try to run my iOS app (built with React Native), it does not recognize this library, which I believe I have to add to my Podfile to work.

By reading the issues here, I was able to get to this:

_target 'watchos Watch App' do platform :watchos, '7.0' pod 'DSFQRCode' end

Which allow me to successfully run pod install in my iOS project, but when I try to run my iOS app (in order to run the watchOS app where this library is been used), I get this error:

image

Any ideas on why Im getting this?

dagronf commented 3 weeks ago

Hi @joaonew ,

It looks like you're linking the QRCode library multiple times against your app (the 4268 duplicate symbols).

I'm guessing that you've added QRCode via Cocoapods (ie. "pod 'DSF_QRCode'") in your comment. The second via Xcode dependencies ("installing the package dependencies through Xcode"). You should only use a single method for integrating QRCode into your app.

If you're already using Cocoapods to get React Native, then I'd suggest using Cocoapods only for installing QRCode.

Hope this helps.

dagronf commented 3 weeks ago

I just threw together a very simple watchos app using cocoapods. It's using SwiftUI, but the same concept applies to React Native. Might give you some more insight into your own app.

The big note here is that QRCode is included via Cocoapods only. No Xcode package dependencies.

qr49-cocoapods-watchos.zip

joaonew commented 3 weeks ago

Thank you. I've decided to delete and redo all the configuration for watchOS to try to get it to work, I will give a close look in the project you shared, appreciated.

joaonew commented 3 weeks ago

I just threw together a very simple watchos app using cocoapods. It's using SwiftUI, but the same concept applies to React Native. Might give you some more insight into your own app.

The big note here is that QRCode is included via Cocoapods only. No Xcode package dependencies.

qr49-cocoapods-watchos.zip

How did add this cocoapods to your project? Can you break it down for me since adding it only to Podfile did not work for me.

dagronf commented 3 weeks ago

Just adding the podfile isn't sufficient, you'll need to also run pod install from within your project directory (in the terminal app). Have a look at the 'Get Started' section in the cocoapods documentation.

Are you planning to use Cocoapods for all your other dependencies, like React Native etc?

joaonew commented 3 weeks ago

I did ran pod install after adding the pod 'DSF_QRCode' in my Podfile, I was wondering if you ran any other commands like yarn add ... because I noticed in your Podfile you had the pod 'DSF_QRCode' under your main app target as well.

I strip all the new communication code from my iOS app (to talk to the watch) but this QRCode lib apparently doesn't let me run my iOS app in Xcode anymore.

For now I can only run pod install without errors if I run USE_FRAMEWORKS=static bundle exec pod install, and even tho pod install is successful, when I run my iOS app in Xcode (already with the watchOS linked to it), I get:

image

Any sugestions?

dagronf commented 3 weeks ago

The Sandbox error is related to an Xcode setting -- you need to set ENABLE_USER_SCRIPT_SANDBOXING to 'No'

This is a common issue with Cocoapods and Xcode versions > 12.

If you look at the project that I attached you'll see it's set to NO on the project targets too. I didn't have to do anything else here (ie. no yarn).

Note that I commented the line use_frameworks! in my podfile, although uncommenting this line still produces a build that runs fine

Screenshot 2024-08-20 at 3 28 52 PM Screenshot 2024-08-20 at 3 38 51 PM
dagronf commented 3 weeks ago

Note that the attached demo app does NOT use React Native AT ALL. I've never used React Native myself so I have no understanding about the requirements of including a platform-specific component into a Reach Native app.

joaonew commented 3 weeks ago

Thank you, that fixed the sandbox error.

Looks like they are never finished tho lol

image

Note that the attached demo app does NOT use React Native AT ALL. I've never used React Native myself so I have no understanding about the requirements of including a platform-specific component into a Reach Native app.

No worries, you helped a lot with your support!