XcodeGen - how to configure Notification Service Extention target?

226 views Asked by At

Perhaps someone has already solved this problem. Tell me if you know. How can I add a Notification Service Extention target using XcdoeGen? I just don't see this type of target in XcodeGen. Perhaps it is not supported at all. Perhaps there are some workarounds, please help if someone has already done this using XcodeGen.

1

There are 1 answers

0
KimNguyen On

The target type is app-extension and this is how it looks in my project.yml file

NotificationService:
    platform: iOS
    type: app-extension
    sources:
      - NotificationService
    dependencies:
       - package: my_package_dependency1
       - package: my_package_dependency2
    settings:
      base:
        ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: ${inherited}
        PRODUCT_NAME: NotificationService
        PRODUCT_MODULE_NAME: NotificationService
        DEVELOPMENT_TEAM: YOU_TEAM
        CODE_SIGN_STYLE: Manual
        TARGETED_DEVICE_FAMILY: "1,2"
      configs:
        Debug:
          PRODUCT_BUNDLE_IDENTIFIER: 'com.myAppBundleID.debug.NotificationService'
        Beta:
          PRODUCT_BUNDLE_IDENTIFIER: 'com.myAppBundleID.beta.NotificationService'
        Release:
          PRODUCT_BUNDLE_IDENTIFIER: 'com.myAppBundleID.NotificationService'
    configFiles:
      Debug: debugNotification.xcconfig
      Beta: betaNotification.xcconfig
      Release: releaseNotification.xcconfig
    info:
      path: NotificationService/NotificationInfo.plist
      properties:
        NSExtension:
          NSExtensionPointIdentifier: 'com.apple.usernotifications.service'
          NSExtensionPrincipalClass: '$(PRODUCT_MODULE_NAME).NotificationService'
        CFBundleName: NotificationService
        CFBundleDisplayName: your_bundle_display_name
        CFBundleShortVersionString: 1.0.0
        CFBundlePackageType: $(PRODUCT_BUNDLE_PACKAGE_TYPE)
Then, in the dependencies of the main target, add:

dependencies:
       - package: my_package_dependeny
       - target: NotificationService
         embed: true

Also, create a simple Scheme for it if you want to debug:

schemes:
  NotificationService:
    build:
      targets:
        NotificationService: all
        [MainTargetName]: all
      parallelizeBuild: true
      buildImplicitDependencies: true
    run:
      config: Debug
    test:
      config: Debug
    profile:
      config: Release
    analyze:
      config: Debug
    archive:
      config: Release

Hope it helps!