With the new build system on Xcode 10, I'm running into an issue. In our project we have our main app, a Today View Extension, and a Notification Service Extension.
We previously set our Product Module Name to the same value in all targets. We also use NSKeyedArchiver / NSKeyedUnarchiver to cache Swift objects that can be accessed by all targets using app groups. Since the Product Module Name was the same in all targets, NSKeyedUnarchiver worked since all Swift classes were prefixed with the same module.
However, on the new build system I receive an error when the Product Module Name is the same for embedded targets. I get the following:
:-1: duplicate output file '/[Product_Module_Name].swiftmodule/x86_64.swiftdoc' on task: Ditto [Product_Module_Name].swiftmodule/x86_64.swiftdoc [Product Module Name].swiftdoc (in target 'Notification Service Extension')
:-1: duplicate output file '[Product Module Name].swiftmodule/x86_64.swiftmodule' on task: Ditto [Product Mdoule Name].swiftmodule/x86_64.swiftmodule [Product Module Name].build/Dev Debug Production-iphonesimulator/Notification Service Extension.build/Objects-normal/x86_64/[Product Module Name].swiftmodule (in target 'Notification Service Extension')
I am able to build by setting a distinct Product Module Name for each target, but that breaks using NSKeyedUnarchiver across app groups. I get the following crash:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class ([Product Module Name].SharedEventHistoryItem) for key (NS.object.0); the class may be defined in source code or a library that is not linked'