4

I recently downloaded a resume template file for Pages, which has a some "shapes" in it and I'd like to add my own icons as shapes (for Github, StackExchange, etc), which I haven't come across any docs about.

I tried importing an .eps file, but it just comes in as an image. Pages doesn't import .svgs.

Looked in

/Applications/Pages.app/Contents/Resources

And found

-rw-r--r--@ 1 root  wheel   4.9M Mar 17  2022 shape_library.json

Which is full of vector paths:

    "178": {
      "id": 178,
      "shapePath": "M 478.593750 125.187500 C 416.293752 125.187500 399.593709 186.399994 399.593750 210.500000 C 399.593750 248.899999 422.693705 268.293742 435.593750 290.593750 C 437.793750 294.293750 434.706266 298.906298 430.406250 298.406250 C 350.606252 289.506250 305.412435 324.687501 274.312500 325.187500 C 256.412500 325.487500 227.393692 277.506254 204.093750 296.906250 C 187.893751 310.306250 184.693736 486.906254 314.593750 486.906250 C 444.393748 486.906250 485.500020 486.906250 485.500000 486.906250 C 485.500000 486.906250 595.406250 483.906311 595.406250 391.406250 C 595.406250 298.906250 539.406250 300.987528 539.406250 271.687500 C 539.406250 242.387499 591.606242 244.693736 595.406250 236.593750 C 599.606250 227.693750 582.312510 222.006271 582.312500 219.406250 C 582.312500 216.806250 600.106201 201.087508 595.406250 193.687500 C 590.906250 186.687500 582.187459 201.999990 556.187500 195.000000 C 553.487500 194.300000 551.512606 192.200014 550.812500 189.500000 C 545.912500 170.199999 536.193629 125.187523 478.593750 125.187500 Z M 478.593750 125.187500",
      "localizationKey": "Rubber Duck_178",
      "categories": {
        "37": {
          "position": 56
        }
      }
    },

But this is obviously not meant to be edited.

Pages doesn't have a directory in /Library/Application\ Support/ or ~/Library/Application\ Support/.

What am I missing?

UPDATE

Based on answer from @grg, I found my way into the db that stores the user-defined shapes and am hoping to make some updates there.

  1. Get into the db

sqlite3 ~/"Library/Containers/com.apple.iWork.Pages/Data/Library/Application Support/com.apple.iWork.CloudKitStorage/com.apple.iWork.TSKCloudKitPrivateZone.db"

  1. Look around
sqlite> pragma table_info(TSDUserDefinedShapeLibraryShape);
0|identifier|TEXT|0||1
1|cloudKitMetadata|TEXT|0||0
2|needs_first_fetch|INTEGER|0|0|0
3|TSDUserDefinedShapeLibraryBezierPathStringKey|TEXT|0||0
4|TSDUserDefinedShapeLibraryName
sqlite> select identifier, TSDUserDefinedShapeLibraryNameKey   from TSDUserDefinedShapeLibraryShape;
E52A91BC-3774-45AE-B7A8-456EA04E4C0B|Envelope
E19F63AC-23B4-4495-B401-A83544A7AF37|Globe
7C133FEE-8C55-45B5-BB6A-D7A264898555|Location
9B7722F5-8029-4454-A8CA-AE6202BB5CA6|triangle
  1. Make a modification
update TSDUserDefinedShapeLibraryShape set TSDUserDefinedShapeLibraryNameKey = "not a circle" where TSDUserDefinedShapeLibraryNameKey  = 'triangle';
  1. Confirm updated
sqlite> select identifier, TSDUserDefinedShapeLibraryNameKey   from TSDUserDefinedShapeLibraryShape;
9B7722F5-8029-4454-A8CA-AE6202BB5CA6|not a circle
  1. Quit and Restart Pages - updated name not there.

However if I update the name within pages, the new name shows up right away:

9B7722F5-8029-4454-A8CA-AE6202BB5CA6|treehouse

So it seems that Pages is writing to the db in realtime, but not reading from it. Perhaps it's the cloudkitMetadata that needs to change. Perhaps I just shouldn't be trying to use the application in this way.

Safety

To backup db before hacking at it:

.sqlite ~/"Library/Containers/com.apple.iWork.Pages/Data/Library/Application Support/com.apple.iWork.CloudKitStorage/com.apple.iWork.TSKCloudKitPrivateZone.db" \
    ".backup 'iword_cloudkit_backup_file.sq3'"

Second Update

Possibly due to having disconnected from the internet, my database changes are now showing up after restarting the Pages application.

I can now successfully run CRUD commands on the db and as they will work if certain specs are met:

  1. location needs to be a UUID of the correct format. Not sure what format that is. This website suggested the app is generating either version 1 or 4. I have tried generating my own and they don't seem to work. I can only INSERT if I use a location previously generated by the app.

  2. Am still unsure if being connected to the internet makes any difference.

  3. The TSDUserDefinedShapeLibraryBezierPathStringKey needs to be a Bezier curve. Not an svg path.

I have tried using a tool to generate a Bezier curve from svg path, but so far not in a way that renders correctly. In testing I copy-pasted paths from the shapy_library.json file referenced above.

1

1 Answer 1

4

Pages does not support importing a shape file.

If you created or customised a closed-path shape, you can save it to the shapes library.

https://support.apple.com/guide/pages-iphone/tancb0d1c0b3/ios

You can draw the shape yourself, then add it to My Shapes with the context menu.

Pages is a sandboxed application like most on macOS, so you won't find anything outside of its container(s) in ~/Library/Containers. My Shapes are stored in
~/Library/Containers/com.apple.iWork.Pages/Data/Library/Application Support/com.apple.iWork.CloudKitStorage/com.apple.iWork.TSKCloudKitPrivateZone.db.

$ sqlite3 ~/"Library/Containers/com.apple.iWork.Pages/Data/Library/Application Support/com.apple.iWork.CloudKitStorage/com.apple.iWork.TSKCloudKitPrivateZone.db" \
    "select TSDUserDefinedShapeLibraryNameKey, TSDUserDefinedShapeLibraryBezierPathStringKey from TSDUserDefinedShapeLibraryShape;"
MyCustomShape|M 153.676079 367.646016 C 122.497427 367.646016 97.121058 402.035008 97.121048 444.405957 C 97.121048 486.776952 122.397495 521.134633 153.676079 521.134679 C 179.758225 521.134679 201.736961 497.157369 208.232483 464.579648 C 208.832069 461.381841 211.748833 459.083402 214.946632 459.083409 L 429.487259 459.083409 C 430.686447 459.083409 431.704483 460.101491 431.704483 461.300641 L 431.704483 483.379277 C 431.704483 484.578450 445.994766 490.874173 447.193893 490.874143 L 454.282791 490.874143 C 455.481979 490.874143 469.772202 484.578488 469.772171 483.379277 L 469.772171 461.300641 C 469.772171 460.101468 470.759018 459.083379 471.958176 459.083409 L 493.037491 459.083409 C 495.835587 459.083409 498.159103 456.791257 498.158981 453.993146 L 498.158981 434.818776 C 497.959122 432.020688 495.648209 429.697289 492.850113 429.697282 L 214.946632 429.697282 C 211.748825 429.697282 208.832039 427.398847 208.232483 424.201043 C 201.736923 391.623349 179.758202 367.646016 153.676079 367.646016 Z M 153.582394 389.349906 C 168.472199 389.349906 180.563934 403.615151 180.563919 421.203095 C 180.563919 428.198308 180.563904 460.676061 180.563919 467.671285 C 180.563919 485.259236 168.472199 499.555669 153.582394 499.555699 C 138.692585 499.555699 126.600851 485.259252 126.600866 467.671285 C 126.600866 460.676068 126.600880 428.198296 126.600866 421.203095 C 126.600866 403.615140 138.692581 389.349912 153.582394 389.349906 Z M 153.582394 389.349906
1
  • Great. Using that db, I can run select * from TSDUserDefinedShapeLibraryShape; to see my shapes. Can I also insert shapes into that db?
    – MikeiLL
    Commented Dec 16, 2022 at 20:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .