vonovak / react-native-simple-toast

Cross-platform Toast experience for React Native
MIT License
287 stars 31 forks source link

PrivacyInfo.xcprivacy is created at the root of the project causing conflicts #79

Open Muha-coinmotion opened 5 months ago

Muha-coinmotion commented 5 months ago

Describe the bug I have added PrivacyInfo.xcprivacy to our project target and added the file to the Copy Bundle Resources Phase in the Build Phase; after that, I can not build the app or create the Archive. I am getting the following error. I'm unsure, but your PrivacyInfo file should be in a bundle.

Changed the inclusion of PrivacyInfo.xcprivacy to resource_bundles for cocoapod to avoid resource name collision when the user uses cocoapod as static library.

error: Multiple commands produce 'Developer/Xcode/DerivedData/MyPorject/Build/Products/Release-iphonesimulator/myproject.app/PrivacyInfo.xcprivacy'
    note: Target 'myproject' (project 'project') has copy command from '/myproject/ios/PrivacyInfo.xcprivacy' to 'Developer/Xcode/DerivedData/MyProject/Build/Products/Release-iphonesimulator/myproject.app/PrivacyInfo.xcprivacy'
    note: That command depends on command in Target 'myproject' (project 'myproject'): script phase “[CP] Copy Pods Resources”

Project Root Level PrivacyInfo.xcprivacy contents

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>NSPrivacyAccessedAPITypes</key>
  <array>
    <dict>
      <key>NSPrivacyAccessedAPIType</key>
      <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
      <key>NSPrivacyAccessedAPITypeReasons</key>
      <array>
        <string>C617.1</string>
        <string>3B52.1</string>
      </array>
    </dict>
    <dict>
      <key>NSPrivacyAccessedAPIType</key>
      <string>NSPrivacyAccessedAPICategoryDiskSpace</string>
      <key>NSPrivacyAccessedAPITypeReasons</key>
      <array>
        <string>E174.1</string>
        <string>7D9E.1</string>
      </array>
    </dict>
    <dict>
      <key>NSPrivacyAccessedAPIType</key>
      <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
      <key>NSPrivacyAccessedAPITypeReasons</key>
      <array>
        <string>CA92.1</string>
      </array>
    </dict>
    <dict>
      <key>NSPrivacyAccessedAPIType</key>
      <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
      <key>NSPrivacyAccessedAPITypeReasons</key>
      <array>
        <string>35F9.1</string>
      </array>
    </dict>
  </array>
</dict>
</plist>

To Reproduce Steps to reproduce the behavior:

  1. Create PrivacyInfo.xcprivacy file in the project
  2. Build the app
  3. see error

Expected behavior We should be able to add PrivacyInfo.xcprivacy file in the project and it should be at the root of the project.

GoldenSoju commented 5 months ago

Having the same problem. This issue (as mentioned in other libraries) usually leads to this solution: https://github.com/getsentry/sentry-cocoa/pull/3651/files

(I am not an pods expert though.)

Muha-coinmotion commented 5 months ago

Having the same problem. This issue (as mentioned in other libraries) usually leads to this solution: https://github.com/getsentry/sentry-cocoa/pull/3651/files

(I am not an pods expert though.)

Please let me know if you find any solution.

React-native-simple-toast has Toast Dependency, and there the PrivacyInfo should be in resource_bundles

GoldenSoju commented 5 months ago

At the moment, Toast doesn't have a PR to fix this (https://github.com/scalessec/Toast/blob/master/Toast.podspec) Toast-Swift has an open PR that implements the fix (https://github.com/scalessec/Toast-Swift/pull/215/files)

So either way, we would need to wait for the fix in the pod dependency so that react-native-toast can use an updated and fixed version.

Muha-coinmotion commented 5 months ago

At the moment, Toast doesn't have a PR to fix this (https://github.com/scalessec/Toast/blob/master/Toast.podspec). Toast-Swift has an open PR that implements the fix (https://github.com/scalessec/Toast-Swift/pull/215/files)

So either way, we would need to wait for the fix in the pod dependency so that react-native-toast can use an updated and fixed version.

I suggest merging PrivacyInfo files at the pod installation phase. What do you think? After merging, the PrivacyInfo file will be at the project's root, and we can add all the required API reasons that Apple is asking for.

Possible Temporary solution.


 project_root_directory = Pod::Config.instance.installation_root

  post_install do |installer|
      react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
      )
  # Define the path to your project's PrivacyInfo file
  project_privacy_file = File.join(project_root_directory, 'PrivacyInfo.xcprivacy')
  # Define the path to the Toast PrivacyInfo file
  toast_privacy_file = File.join(project_root_directory, '/Pods/Toast/Toast/PrivacyInfo.xcprivacy')
  # Replace the contents of the Toast PrivacyInfo file with the contents of your project's PrivacyInfo file
  FileUtils.cp(project_privacy_file, toast_privacy_file)
  end 
dioi2000 commented 5 months ago

@Muha-coinmotion Thank you for the code

here is some tip

replace project_root_directory with dir (ios/) /Pods/Toast/Toast/PrivacyInfo.xcprivacy -> /Pods/Toast/Toast/Resources/PrivacyInfo.xcprivacy'

#if file on ios/PrivacyInfo.xcprivacy
project_privacy_file = File.join(__dir__, 'PrivacyInfo.xcprivacy')
# Define the path to the Toast PrivacyInfo file
toast_privacy_file = File.join(__dir__, '/Pods/Toast/Toast/Resources/PrivacyInfo.xcprivacy')
prathameshmm02 commented 5 months ago

This fixed the issue for me:

cd ios && pod update Toast
DeVoresyah commented 3 months ago

This fixed the issue for me:

cd ios && pod update Toast

this is works for me, but idk how to solve on expo