ymoyao / cocoapods-privacy

a cocoapods plugin to auto manager Xcode PrivacyInfo.xcprivacy file(create && search)
MIT License
188 stars 20 forks source link

cocoapods-privacy

Apple 2024 will review the App's privacy manifests in the spring, and any apps that don't submit a privacy list may be called back. For now, the privacy list is broken down by component, to facilitate the maintenance of component privacy, cocoapods-privacy is developed for management. Click to view details on Apple

Introduction

As name as,cocoapods-privacy is a plugin for privacy manifests, and focus on cocoapods!

Installation

$ gem install cocoapods-privacy

Usage

init

First of all, you must set a json config to cocoapods-privacy, this is a defalut config.json

$ pod privacy config https://raw.githubusercontent.com/ymoyao/cocoapods-privacy/main/resources/config.json

There has 3 keys in defalut config, defalut rule is :To exclude retrieval a component that git source contains certain ‘github.com’ keywords

"source.white.list": [],
"source.black.list": ["github.com"], 
"api.template.url": "https://raw.githubusercontent.com/ymoyao/cocoapods-privacy/main/resources/NSPrivacyAccessedAPITypes.plist"

If your needs are not met, you can custom! For example, there has some components,and it‘s your local config

"source.white.list": ["https://github.com/ReactiveCocoa/ReactiveObjC.git","git.yourserver.com","git.otherserver.com"],
"source.black.list": ["github.com","https://github.com/AFNetworking/AFNetworking.git"], 
"api.template.url": "https://raw.githubusercontent.com/ymoyao/cocoapods-privacy/main/resources/NSPrivacyAccessedAPITypes.plist"
https://github.com/AFNetworking/AFNetworking.git ❌ (it's in 'github.com' black list)
https://github.com/ReactiveCocoa/ReactiveObjC.git ❌ (it's in 'github.com' black list, although also on the white list,but the blacklist priority is high when conflict)
https://git.yourserver.com/xxx/xxxx.git ✅
https://git.yourserver.com/mmm/mmm.git ✅
https://git.otherserver.com/ssss/ssss.git ✅
https://git.yourserver.com/AFNetworking/AFNetworking.git ✅

After custom,you just update config by local like this

$ pod privacy config /yourfilepath/config.json

In a word, if you define both white and black lists ,final search range: white list minus black list, and empty white list means all!

To Component

$ pod privacy spec [podspec_file_path]

This command will auto create privacy file, and search the path of podspec' source_files' define relate to NSPrivacyAccessedAPITypes, finaly, write to PrivacyInfo.xcprivacy file. if your component has much subspec, all subspec that define ‘source_files’ will create PrivacyInfo.xcprivacy, and auto modify .podspec link .xcprivacy to 'resource_bundle' key. For example

Pod::Spec.new do |s|
  s.name             = 'Demo'
  ...
  s.source_files = 'xxxx'
  s.subspec 'idfa' do |sp|
      sp.source_files = 'xxxxx'
  end
  s.subspec 'noidfa' do |sp|
  end
end

To Project

$ pod install --privacy
or
$ pod privacy install
截屏2024-02-02 10 59 59

After command, a PrivacyInfo.xcprivacy will create to you project Resources if empty.

Components that meet all of the following items will be processed.

Notice

The plugin is focus on NSPrivacyAccessedAPITypes and automatically search and create workflow. you should manager NSPrivacyCollectedDataTypes by yourself!

Could you please consider giving our repository a star🌟🌟🌟? It would mean a lot to us and help our project gain more visibility. Thank you!