Skip to content

Extract private API to external repo #2

@markbattistella

Description

@markbattistella

Hey @Aeastr,

Just came across this and nice little package - but noticed your comment on the private API use and how it can affect the usage in real world apps.

Note: trying not to be self-promoting here

I faced the same issue with BezelKit, and what I did was:

  1. Extract the private API into a separate project
  2. Save that data to a JSON log file (https://github.com/markbattistella/BezelKit-Generator/blob/e8607292fb525360d03785d6416346b54ca968da/FetchBezel/FetchBezel/MainApp.swift#L23)
  3. Wrote a NodeJS script (simpler at the time for me) to boot up a simulator, run the project, then conform it to a JSON data file (https://github.com/markbattistella/BezelKit-Generator/blob/e8607292fb525360d03785d6416346b54ca968da/index.js#L2)
  4. At the end of the JS script it does the following to the main repo:

    Once the script completes and updates the bezel.min.json for the actual package, pending and problematic keys are deleted, and the JSON is minified.

  5. Add the new JSON file to your main repo (https://github.com/markbattistella/BezelKit/blob/fc2bdcb9a4a02cfc09b17ce6db028b4b0cdcd75f/Package.swift#L19)
  6. Use it in your package (https://github.com/markbattistella/BezelKit/blob/fc2bdcb9a4a02cfc09b17ce6db028b4b0cdcd75f/Sources/BezelKit/BezelKit.swift#L39)

I know this is a lot of extra overhead to you, but for the user it means these private APIs aren't even a thought in their apps. Everything you provide for them to use is simply an outputted JSON file.

I then have a VM (using VirtualBuddy) to essentially run this every time a new device is released. Currently I manually add the identifier and simulator name to the generator JSON, then it does the rest for me!

If you're interested I can see what parts I can clone into making this work for NotchMyProblem since it is really doing the same thing, and for the user/dev all they really need is to know where the notch is not the calculation within the app 😄

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions