I have an iOS App target, open to everyone for the public store, all fine. And I have extensions with it in the project.
I duplicated the first App target, added some changes, etc for B2B & MDM usage, but I want to use the same extensions, without having to change their bundle identifiers each time I change the build target, and I don't want to duplicate them just for that, if that is avoidable.
Visual example:
https://i.stack.imgur.com/JuEQa.png
Basically I want to avoid delivering the code of the second target to the users of the first target.
I thought there might be a way to do that with App groups, but I couldn't.
Is there a way to make the extensions work for both App targets?
If it is possible to use scripts in the build phase of the App target, I would be happy if you provide an example of how to manage that, because I am new to that.
Or do I really have to duplicate the extensions and only edit their bundle identifier to point to the other target's identifier?
There are these option available:
1.
You can duplicate the extensions, provide id from your developer portal, or let Xcode add them itself, and change the target identifiers to your new target.
2.
The other way is, to change the extensions bundle ids on build actions of the scheme to your currently required ones. This could look somewhat like this, if you want to use PlistBuddy:
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier fullBundleIdOfExtension" $PROJECT_DIR/Extension\ Directory/Info.plist
fullBundleIdOfExtension is something like com.company.application.extension
This way could cause errors sometimes on the build after a target switch, showing a dialog that the App could not be installed. This requires you to perform a clean build and rebuild.