{"id":28458784,"url":"https://github.com/openmined/swiftdp","last_synced_at":"2025-07-02T09:31:12.705Z","repository":{"id":103100184,"uuid":"252196177","full_name":"OpenMined/SwiftDP","owner":"OpenMined","description":"Swift wrapper for Google's Differential Privacy Project","archived":false,"fork":false,"pushed_at":"2020-05-08T07:50:46.000Z","size":103,"stargazers_count":11,"open_issues_count":3,"forks_count":4,"subscribers_count":6,"default_branch":"dev","last_synced_at":"2025-06-07T00:40:36.384Z","etag":null,"topics":["differential-privacy","swift"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenMined.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"openmined","open_collective":"openmined"}},"created_at":"2020-04-01T14:19:39.000Z","updated_at":"2022-11-12T15:22:12.000Z","dependencies_parsed_at":"2023-07-22T13:31:19.198Z","dependency_job_id":null,"html_url":"https://github.com/OpenMined/SwiftDP","commit_stats":{"total_commits":33,"total_committers":3,"mean_commits":11.0,"dds":0.4545454545454546,"last_synced_commit":"6d20cb4ce85fadc2d3515fde54110c8b92b702e6"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/OpenMined/SwiftDP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2FSwiftDP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2FSwiftDP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2FSwiftDP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2FSwiftDP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenMined","download_url":"https://codeload.github.com/OpenMined/SwiftDP/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2FSwiftDP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263111351,"owners_count":23415433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["differential-privacy","swift"],"created_at":"2025-06-07T00:39:47.410Z","updated_at":"2025-07-02T09:31:12.686Z","avatar_url":"https://github.com/OpenMined.png","language":"Objective-C++","funding_links":["https://github.com/sponsors/openmined","https://opencollective.com/openmined"],"categories":[],"sub_categories":[],"readme":"![Tests](https://github.com/OpenMined/SwiftDP/workflows/CI/badge.svg)\n[![Chat on Slack](https://img.shields.io/badge/chat-on%20slack-7A5979.svg)](https://openmined.slack.com/messages/lib_swift_dp)\n\n# SwiftDP\n\nSwift wrapper for Google's Differential Privacy Project via an Objective-C++ bridge.\n\n## TODO\n\n- [x] Bazel Build\n- [x] C++ -\u003e Objective-C -\u003e Swift\n- [x] Xcodegen Project\n- [x] clang-format\n- [x] fastlane\n- [x] Carrot Hello World\n- [x] GitHub CI Unit Tests\n- [x] OCDP Objective-C Wrapper Framework\n- [ ] SwiftDP Wrapper Framework\n- [ ] Cocopods Support\n- [ ] Carthage Support\n- [ ] SwiftPM Support\n- [ ] Native iOS Example\n- [ ] React Native Example\n- [ ] Flutter Example\n\n## Prerequisites\n\n- Xcode\n- Brew\n\n```\n$ /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\n```\n\n- Bazel\n\n```\n$ brew tap bazelbuild/tap\n$ brew install bazelbuild/tap/bazel\n```\n\n- XcodeGen\n\n```\n$ brew install xcodegen\n```\n\n- clang-format\n\n```\n$ brew install clang-format\n```\n\n# Setup\n\nThere is a start script which will fetch the bazel dependencies build the framework and\ncreate an xcode project for use in development.\n\n```\n$ ./start.sh\n```\n\n# Packaging Overview\n\n## Build Framework\n\n```\n$ ./build_framework.sh\n```\n\n## Xcode Development\n\nAll development can be done inside of xcode. We have the Objective-C source code linked a dummy framework to allow for \"Jump to Definition\" as well as the google absl and dp libraries linked but with no target membership to make it easy to navigate the source.\n\n## Build Example App\n\n```\n$ cd xcode\n$ xcodegen generate\n```\n\nOpen SwiftDP-App.xcodeproj and add your Team Signing Identity and hit run.\n\n## Useful Commands\n\n### Bazel Clean\n\n```\n$ bazel clean --expunge\n```\n\n### Inspect iOS Library Files\n\nShow which architectures are available:\n\n```\n$ lipo -info ./bazel-bin/src/SwiftDP_archive-root/SwiftDP.framework/SwiftDP\n```\n\n```\n$ otool -hv -arch all $FILENAME\n```\n\n```\n$ nm $FILENAME\n```\n\n# Namespaces\n\n## Objective-C\n\nWe are using the namespace OCDP in the Objective-C code.\n\n## Swift\n\nWe plan to use NS_SWIFT_UNAVAILABLE and NS_SWIFT_NAME to selectively expose and rename the Objective-C API to Swift.\n\n# How to Objective-C++\n\n## Utility Library\n\nWe have a utility library of functions which help converting from C++ to Objective-C and back as needed.\n\nThe file is called DPUtil.mm and has no header, which allows it to freely mix C++ and Objective-C into the *franken*code that is Objective-C++.\n\nTo make the file available for import its listed in the Bazel BUILD objc_library hdrs.\n\n## Initializers\n\nMark types with nonnull if you want to return an Implicitly Unwrapped Optional (IOU) in Swift.\n\n```\n- (nonnull instancetype) initWithEpsilon: (double) epsilon; // return ! IUO\n```\n\nTo mark as optional use nullable:\n\n```\n- (nullable instancetype) initWithEpsilon: (double) epsilon; // return ? Optional\n```\n\nHide unused init / new:\n\n```\n- (instancetype)init NS_UNAVAILABLE; // disable default initializers\n+ (instancetype)new NS_UNAVAILABLE; // disable default new aka [[NSObject alloc] init]\n```\n\n## Toolbox\n\n### C++\n\n- Templates\n- C++ auto in range-based for-loops\n\n### Objective-C\n\n- Categories\n- Objective-C++ .mm files\n- `__kindof`\n- isMemberOfClass\n- isKindOfClass\n- Protocols\n- Light-weight Generics\n- NS_UNAVAILABLE\n\n### Swift\n\n- NS_SWIFT_NAME\n- NS_SWIFT_UNAVAILABLE\n\n## Resources\n\nThese links have really useful patterns and ideas on ways to mix C++ and Objective-C in novel ways.\n\nhttps://philjordan.eu/article/strategies-for-using-c++-in-objective-c-projects  \nhttps://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++  \nhttps://useyourloaf.com/blog/using-nullable-to-annotate-objective-c/\nhttps://useyourloaf.com/blog/using-objective-c-lightweight-generics/\nhttps://developer.apple.com/documentation/swift/objective-c_and_c_code_customization\nhttp://mirror.informatimago.com/next/developer.apple.com/releasenotes/Cocoa/Objective-C++.html\nhttps://gist.github.com/dodikk/4a0f1d98faa7c1336551\nhttps://medium.com/@husain.amri/objective-c-deliver-us-from-swift-3a44d3ac00e7\nhttps://medium.com/@husain.amri/creating-objective-c-classes-at-runtime-1f02b3a3a1db\nhttps://academy.realm.io/posts/altconf-peter-steinberger-objective-c++-what-could-possibly-go-wrong/\nhttps://github.com/EmbeddedSources/JFFLibrary/tree/master/lib/JFFUtils\nhttps://www.netguru.com/codestories/objective-c-generics\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmined%2Fswiftdp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenmined%2Fswiftdp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmined%2Fswiftdp/lists"}