How do I exclude optional iOS frameworks?
In Swrve iOS SDK version 4.2, we implemented the functionality to exclude certain iOS frameworks that weren’t relevant to your app, such as camera permissions or push notifications, using preprocessor macros that excluded the framework. In version 5.0, we changed the logic so that you needed to add the macros to include the related permissions framework.
With the release of Swrve iOS SDK 6.0, we have removed the permissions code and delegated that responsibility to the app developer. If you want to enable tracking and device permission requests, you must implement the SwrvePermissionsDelegate
delegate and set it in your SwrveConfig
object. For information on how to do this, see the iOS integration guide.
SDK version 6.0+
As of Swrve iOS SDK v6.0, we have removed the optional permissions code (camera, location, contacts, photo library) from the SDK. If you want to handle these permissions in the SDK, you must now implement the SwrvePermissionsDelegate
delegate and set it in your SwrveConfig
object. For more information, see the iOS integration guide.
SDK version 5.0 to 5.3
For Swrve SDKs v5.0 to v5.3, the optional frameworks are excluded by default. We changed the build flags to the following and you must add the Preprocessor Macros to include the associated framework (with the exception of SWRVE_NO_PUSH – see note below):
Preprocessor macros | Framework |
---|---|
SWRVE_ADDRESS_BOOK | AddressBook.framework Contacts.framework |
SWRVE_LOCATION | CoreLocation.framework |
SWRVE_PHOTO_LIBRARY | AssetsLibrary.framework Photos.framework |
SWRVE_PHOTO_CAMERA | N/A – restricts camera access in the AVFoundation.framework |
SDK version 4.2 to 4.11.4
For Swrve SDKs v4.2 to v4.11.4, you must add the following Preprocessor Macros to exclude the associated framework.
Preprocessor Macros | Framework |
---|---|
SWRVE_NO_ADDRESS_BOOK | AddressBook.framework Contacts.framework |
SWRVE_NO_LOCATION | CoreLocation.framework |
SWRVE_NO_PHOTO_LIBRARY | AssetsLibrary.framework Photos.framework |
SWRVE_NO_PHOTO_CAMERA | N/A – restricts camera access in the AVFoundation.framework |
SWRVE_NO_PUSH | UserNotificationsUI.framework UserNotifications.framework Removes push code in the final app. |
Native iOS
SwrvePermissionsDelegate
delegate and set it in your SwrveConfig
object. For information on how to implement theSwrvePermissionsDelegate
, see the iOS integration guide.To exclude the push notification code from your app, add the SWRVE_NO_PUSH preprocessor macro to App Target > Build Settings > Preprocessing > Preprocessor Macros:
Apps integrated with CocoaPods
You must apply theSWRVE_NO_PUSH preprocessor macro to the Pods project that CocoaPods automatically creates. To add these automatically, add the following snippet to your Podfile:
post_install do |installer_representation| installer_representation.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'SWRVE_NO_PUSH’'] end end end
Apps integrated with Carthage
You must apply the SWRVE_NO_PUSH preprocessor macro to the SwrveFrameworks project found in the Carthage/Checkouts/swrve-ios-sdk/SwrveFrameworks folder and then run a Carthage build to update your main project.
Unity iOS
Unity SDK
SDK version 4.2 to 4.11.4
You must apply the preprocessor macros to the Xcode project that Unity automatically creates. To add these automatically, you need to add to the Unity post processor (Assets/Swrve/Editor/SwrveIOSPostProcess.cs) to remove those frameworks.
There are two required steps:
- Comment out the unneeded Frameworks:
// project.AddFrameworkToProject (targetGuid, "AddressBook.framework", false); // project.AddFrameworkToProject (targetGuid, "AssetsLibrary.framework", false); // project.AddFrameworkToProject (targetGuid, "Contacts.framework", true); // project.AddFrameworkToProject (targetGuid, "Photos.framework", true);
- Add the Preprocessor Macros by adding the following lines:
project.SetBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_NO_ADDRESS_BOOK=1"); project.AddBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_NO_LOCATION=1"); project.AddBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_NO_PHOTO_LIBRARY=1"); project.AddBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_NO_PHOTO_CAMERA=1");
SDK version 5.0+
In Swrve SDK v5.0, the above optional frameworks are excluded by default. We have changed the above macros to the following and you now must add the Preprocessor Macros to include the associated framework by modifying a Unity postprocess class that adds those frameworks and build flags:
- Add the required Frameworks:
project.AddFrameworkToProject (targetGuid, "AddressBook.framework", false); project.AddFrameworkToProject (targetGuid, "AssetsLibrary.framework", false); project.AddFrameworkToProject (targetGuid, "Contacts.framework", true); project.AddFrameworkToProject (targetGuid, "Photos.framework", true);
- Add the Preprocessor Macros by adding the following lines:
project.SetBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_ADDRESS_BOOK=1"); project.AddBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_LOCATION=1"); project.AddBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_PHOTO_LIBRARY=1"); project.AddBuildProperty (targetGuid, "GCC_PREPROCESSOR_DEFINITIONS", "SWRVE_PHOTO_CAMERA=1");