Yes, but electronic devices can't digitally contain physical substances that might be subject to customs laws. It's not comparable. It's probably still today reasonable to search ships in the harbor and passengers for physical substances (like banned animals or fruits/vegetables), but it's not obvious to me how searching electronic devices achieves any reasonable objective related to customs law.
[1] https://en.wikipedia.org/wiki/Four_Horsemen_of_the_Infocalyp...
Child porn is prohibited to be imported in any form, including digital. Customs isn’t about just physical objects.
The rights granted under the constitution were provided explicitly under the knowing assumption that they could be used to conceal actual crimes or criminal intent. That's the point of them needing protection from the authorities. The mere possibility of committing a crime isn't enough grounds to invade a person's privacy to that degree. You need actual reason to suspect it in an individual case to go that far.
In the old days, it was routine for customs officers to search ships coming in to harbor, including the effects of their passengers, to enforce importation laws. If customs couldn't do this, then importation laws would have no teeth, which is clearly not the intention of the constitution, which gives Congress the explicit power to enact and enforce them.
CBP argues that their smartphone and laptop searches were just an extension of that old custom, the court disagreed, ruling that a smartphone or laptop is fundamentally different from a ship's log or traveler's trunk, such that a higher expectation of privacy exists.