Add third party ios framework

451 views
Skip to first unread message

Mirko Flores V.

unread,
May 14, 2024, 7:54:36 PM5/14/24
to Chromi...@chromium.org
Hi all,
How can I add framework
that depends on another framework in a framework that is composed of objective-c files and swift files
Using the following configuration after successfully generating the framework

swift_source_set("facebook_aem_kit_swift") {

#  bridge_header = "//ios/third_party/facebook_core_basics/src/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics/facebook_basics_bridge_swift.h"

  sources = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/**/*.swift' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

    "src/FBAEMKit/FBAEMKit/DependentAsType.swift",

    "src/FBAEMKit/FBAEMKit/SKAdNetworkReporting.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserMultiEntryRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleFactory.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleOperator.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleProviding.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserSingleEntryRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMConfiguration.swift",

    "src/FBAEMKit/FBAEMKit/_AEMEvent.swift",

    "src/FBAEMKit/FBAEMKit/_AEMInvocation.swift",

    "src/FBAEMKit/FBAEMKit/_AEMNetworker.swift",

    "src/FBAEMKit/FBAEMKit/_AEMRequestBody.swift",

    "src/FBAEMKit/FBAEMKit/_AEMRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMSettings.swift",

    "src/FBAEMKit/FBAEMKit/_AEMUtility.swift",

  ]

  deps = [

    "//ios/third_party/facebook_core_basics:facebook_core_basics+bundle",

    "//ios/third_party/facebook_core_basics:facebook_core_basics+link",

  ]

  frameworks = [

    "Foundation.framework",

    "CoreFoundation.framework",

    "UIKit.framework",

    "WebKit.framework",

    "FBSDKCoreKit_Basics.framework",

  ]

}


The FBSDKCoreKit_Basics module is not found when compiling the swiftmodule

Sylvain Defresne

unread,
May 14, 2024, 9:36:13 PM5/14/24
to alone.d...@gmail.com, Chromi...@chromium.org
You can use framework_dirs to add directories to the list of paths used by the compiler to search for frameworks.

So something like this:

swift_source_set("facebook_aem_kit_swift") {
  ...
  framework_dirs = [ "//ios/third_party/facebook_core_basics/..." ]
}

where you would substitute the correct path.

Note that you probably need to add a bundle_data(...) target to also ensure the framework is copied into the application bundle (otherwise you'll get an error at runtime saying that the framework is not found).
-- Sylvain

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAGgxU3sV88o4EJRi1FSKi9YimMbkg7%2B0mot-FYdco3eJh-H-qA%40mail.gmail.com.

Sylvain Defresne

unread,
May 15, 2024, 11:52:37 AM5/15/24
to Mirko Flores V., Chromi...@chromium.org
The Chromium template are probably not ready to build third-party swift code. They make assumption that may not hold true for the third-party code.
-- Sylvain

On Wed, May 15, 2024 at 11:05 AM Mirko Flores V. <alone.d...@gmail.com> wrote:
Thanks for the tip! 

Adding the following bundle_data: 

fbcore_basis =  "//ios/third_party/facebook_core_basics"

bundle_data("FBSDKCoreKit_Basics") {

  sources = [

    "$fbcore_basis/src",

    "$fbcore_basis/Info.plist",

  # List all the other files, if the framework contains directories, you'll

  # needs to use multiple bundle_data targets, one per sub-directory.

  ]

  outputs = [ "{{bundle_resources_dir}}/Frameworks/FBSDKCoreKit_Basics.framework/{{source_file_part}}" ]

}
in BUILD.gn on facebook_core_basics framework
and adding to BUILD.gn for facebook_aem_kit framework


import("//build/config/ios/ios_sdk.gni")

import("//build/config/ios/rules.gni")

import("//build/config/locales.gni")

import("//build/config/ios/swift_source_set.gni")


# The three variables _fbcore_public_headers, _fbcore_include_dirs and _fbcore_sources 

# are there to allow script to automatically keep the build rules up-to-date

# when rolling material_components_ios. They should not be removed.


swift_source_set("facebook_aem_kit_swift") {

#  bridge_header = "src/FBAEMKit/FBAEMKit/aemkit_bridge_swift.h"

  sources = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/**/*.swift' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

    "src/FBAEMKit/FBAEMKit/DependentAsType.swift",

    "src/FBAEMKit/FBAEMKit/SKAdNetworkReporting.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserMultiEntryRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleFactory.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleOperator.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleProviding.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserSingleEntryRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMConfiguration.swift",

    "src/FBAEMKit/FBAEMKit/_AEMEvent.swift",

    "src/FBAEMKit/FBAEMKit/_AEMInvocation.swift",

    "src/FBAEMKit/FBAEMKit/_AEMNetworker.swift",

    "src/FBAEMKit/FBAEMKit/_AEMRequestBody.swift",

    "src/FBAEMKit/FBAEMKit/_AEMRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMSettings.swift",

    "src/FBAEMKit/FBAEMKit/_AEMUtility.swift",

  ]

  deps = [

    "//ios/third_party/facebook_core_basics:facebook_core_basics+bundle",

    "//ios/third_party/facebook_core_basics:facebook_core_basics+link",

#    "//ios/third_party/facebook_core_basics:facebook_core_basics_swift",

#    "//ios/third_party/facebook_core_basics:FBSDKCoreKit_Basics",

  ]

  frameworks = [

    "Foundation.framework",

    "CoreFoundation.framework",

    "UIKit.framework",

    "WebKit.framework",

    "FBSDKCoreKit_Basics.framework",

  ]

  framework_dirs = [

    "//ios/third_party/facebook_core_basics/src/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics",

  ]

}


_fbcore_public_headers = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/*.h' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

  "src/FBAEMKit/FBAEMKit/FBAEMAdvertiserRuleMatching.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKit-Prefix-Header.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKit.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKitVersions.h",

  "src/FBAEMKit/FBAEMKit/FBAEMNetworking.h",

  "src/FBAEMKit/FBAEMKit/FBAEMReporter.h",

]


_fbcore_include_dirs = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/*/*.h' -a \! -path '*Test*'|sed -e 's:\(.*\)/[^/]*:  "\1",:'|sort -u

  "src/FBAEMKit/FBAEMKit",

]


_fbcore_sources = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/**/*.[hm]' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

  "src/FBAEMKit/FBAEMKit/FBAEMAdvertiserRuleMatching.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKit-Prefix-Header.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKit.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKitVersions.h",

  "src/FBAEMKit/FBAEMKit/FBAEMNetworking.h",

  "src/FBAEMKit/FBAEMKit/FBAEMReporter.h",

  "src/FBAEMKit/FBAEMKit/FBAEMReporter.m",

]


config("disable_deprecated") {

  cflags = [ "-Wno-deprecated" ]

  cflags += [ "-Wno-deprecated-declarations" ]

}


# TODO(crbug.com/1153275): MDCTabBarViewItemView.h has incomplete nullability

# specification, causing compilation to fail. Disable the warning until this

# is fixed in MDC. Remove this once fixed.

config("disable_nullability_completeness") {

  cflags = [ "-Wno-nullability-completeness" ]

}


# TODO(crbug.com/1339746): MDCNavigationBar.h has conflicting deprecation

# specification, causing compilation to fail. Disable the warning until this

# is fixed in MDC. Remove this once fixed.

config("disable_availability") {

  cflags = [ "-Wno-availability" ]

}


config("disable_iso_c99"){

  cflags = [ "-Wimplicit-function-declaration" ]

}


config("config") {

  visibility = [ ":*" ]

  include_dirs = _fbcore_include_dirs

}


ios_framework_bundle("facebook_aem_kit") {

  sources = _fbcore_sources


  info_plist = "Info.plist"

  output_name = "FBAEMKit"

  public_headers = _fbcore_public_headers


  frameworks = [

    "Foundation.framework",

    "CoreFoundation.framework",

    "UIKit.framework",

    "WebKit.framework",

    "FBSDKCoreKit_Basics.framework",

  ]


  deps = [

    "//ios/third_party/facebook_core_basics",

    ":facebook_aem_kit_swift",

  ]


  configs -= [

    "//build/config/compiler:chromium_code",

    "//build/config/gcc:symbol_visibility_hidden",

  ]

  configs += [

    ":config",

    "//build/config/compiler:no_chromium_code",

    "//build/config/gcc:symbol_visibility_default",

    ":disable_deprecated",

    ":disable_nullability_completeness",

    ":disable_availability",

    ":disable_iso_c99",

  ]

}


I have the next error

/Users/alonedemon/projects/FE/chromiumios/chromium/src/ios/third_party/facebook_aem_kit/src/FBAEMKit/FBAEMKit/aemkit_bridge_swift.h:3:9: error: 'FBSDKCoreKit_Basics/FBSDKCoreKit_Basics.h' file not found

#import <FBSDKCoreKit_Basics/FBSDKCoreKit_Basics.h>

        ^

1 error generated.

commenting bridge_header

../../ios/third_party/facebook_aem_kit/src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleFactory.swift:11:8: error: no such module 'FBSDKCoreKit_Basics'

import FBSDKCoreKit_Basics

       ^

error: fatalError

PD: 
FBSDKCoreKit_Basics work usually in any module on chromium

Mirko Flores V.

unread,
May 15, 2024, 1:05:15 PM5/15/24
to Sylvain Defresne, Chromi...@chromium.org
Thanks for the tip! 

Adding the following bundle_data: 

fbcore_basis =  "//ios/third_party/facebook_core_basics"

bundle_data("FBSDKCoreKit_Basics") {

  sources = [

    "$fbcore_basis/src",

    "$fbcore_basis/Info.plist",

  # List all the other files, if the framework contains directories, you'll

  # needs to use multiple bundle_data targets, one per sub-directory.

  ]

  outputs = [ "{{bundle_resources_dir}}/Frameworks/FBSDKCoreKit_Basics.framework/{{source_file_part}}" ]

}
in BUILD.gn on facebook_core_basics framework
and adding to BUILD.gn for facebook_aem_kit framework


import("//build/config/ios/ios_sdk.gni")

import("//build/config/ios/rules.gni")

import("//build/config/locales.gni")

import("//build/config/ios/swift_source_set.gni")


# The three variables _fbcore_public_headers, _fbcore_include_dirs and _fbcore_sources 

# are there to allow script to automatically keep the build rules up-to-date

# when rolling material_components_ios. They should not be removed.


swift_source_set("facebook_aem_kit_swift") {

#  bridge_header = "src/FBAEMKit/FBAEMKit/aemkit_bridge_swift.h"

  sources = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/**/*.swift' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

    "src/FBAEMKit/FBAEMKit/DependentAsType.swift",

    "src/FBAEMKit/FBAEMKit/SKAdNetworkReporting.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserMultiEntryRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleFactory.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleOperator.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserRuleProviding.swift",

    "src/FBAEMKit/FBAEMKit/_AEMAdvertiserSingleEntryRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMConfiguration.swift",

    "src/FBAEMKit/FBAEMKit/_AEMEvent.swift",

    "src/FBAEMKit/FBAEMKit/_AEMInvocation.swift",

    "src/FBAEMKit/FBAEMKit/_AEMNetworker.swift",

    "src/FBAEMKit/FBAEMKit/_AEMRequestBody.swift",

    "src/FBAEMKit/FBAEMKit/_AEMRule.swift",

    "src/FBAEMKit/FBAEMKit/_AEMSettings.swift",

    "src/FBAEMKit/FBAEMKit/_AEMUtility.swift",

  ]

  deps = [

    "//ios/third_party/facebook_core_basics:facebook_core_basics+bundle",

    "//ios/third_party/facebook_core_basics:facebook_core_basics+link",

#    "//ios/third_party/facebook_core_basics:facebook_core_basics_swift",

#    "//ios/third_party/facebook_core_basics:FBSDKCoreKit_Basics",

  ]

  frameworks = [

    "Foundation.framework",

    "CoreFoundation.framework",

    "UIKit.framework",

    "WebKit.framework",

    "FBSDKCoreKit_Basics.framework",

  ]

  framework_dirs = [

    "//ios/third_party/facebook_core_basics/src/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics",

  ]

}


_fbcore_public_headers = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/*.h' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

  "src/FBAEMKit/FBAEMKit/FBAEMAdvertiserRuleMatching.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKit-Prefix-Header.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKit.h",

  "src/FBAEMKit/FBAEMKit/FBAEMKitVersions.h",

  "src/FBAEMKit/FBAEMKit/FBAEMNetworking.h",

  "src/FBAEMKit/FBAEMKit/FBAEMReporter.h",

]


_fbcore_include_dirs = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/*/*.h' -a \! -path '*Test*'|sed -e 's:\(.*\)/[^/]*:  "\1",:'|sort -u

  "src/FBAEMKit/FBAEMKit",

]


_fbcore_sources = [

  # List generated by the following commands:

  # $ cd src/ios/third_party/facebook_aem_kit

  # $ find src -path 'src/FBAEMKit/**/*.[hm]' -a \! -path '*Test*'|sed -e 's:\(.*\):  "\1",:'|sort -u

  frameworks = [

    "Foundation.framework",

    "CoreFoundation.framework",

    "UIKit.framework",

    "WebKit.framework",

    "FBSDKCoreKit_Basics.framework",

  ]


Mirko Flores V.

unread,
May 16, 2024, 6:42:01 PM5/16/24
to Sylvain Defresne, Chromi...@chromium.org
Thanks for the tip! 

hi

Do you know if a compiled framework can be directly imported? It didn't work for me doing the build with chromium. For frameworks that depend on another framework programmed in objective-c, it works if the framework inserts it.

magesh s

unread,
Jan 31, 2025, 3:37:13 PMJan 31
to Chromium-dev, Mirko Flores V., Chromi...@chromium.org, Sylvain Defresne
Hi,

Is it working now? Is the Chromium template ready to build third-party Swift code into an Objective-C framework?
Reply all
Reply to author
Forward
0 new messages