buck
buck copied to clipboard
Apple bundle for framework fails to import
Cheers,
I'm trying to use the examples i've found online to generate an ObjC framework which i can later include in an ObjC project and i keep getting this error: fatal error: 'ObjcFramework/SampleObjcClass.h' file not found #import <ObjcFramework/SampleObjcClass.h>
where ObjcFramework is the framework i'm generating with a BUCK file and SampleObjcClass is one of the exported headers
this is the buck file for the main app:
apple_resource(
name = 'BuckSampleAppResources',
files = glob(['*.png','*.storyboard']),
dirs = [],
)
apple_bundle(
name = 'BuckSample',
binary = ':BuckSampleBinary',
extension = 'app',
info_plist = 'Info.plist',
deps = [':BuckSampleAppResources'],
)
apple_binary(
name = 'BuckSampleBinary',
preprocessor_flags = ['-fobjc-arc'],
headers = glob([
'*.h',
]),
srcs = glob([
'*.m',
]),
deps = ['//ios/BuckSample/ObjcFramework:ObjcFramework'],
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
)
and this one's for the framework:
apple_library(
name = 'ObjcDynamicLibrary',
srcs = glob(['ObjcFramework/*.m']),
preprocessor_flags = ['-fobjc-arc'],
exported_headers = ['ObjcFramework/SampleObjcClass.h'],
visibility = ['PUBLIC'],
info_plist = 'ObjcFramework/Info.plist',
#preferred_linkage = 'shared',
header_path_prefix = 'ObjcFramework',
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
)
apple_bundle(
name = 'ObjcFramework',
binary = ':ObjcDynamicLibrary#shared',
extension = 'framework',
info_plist = 'ObjcFramework/Info.plist',
visibility = ['PUBLIC'],
)
To be noted that if i don't wrap the library in a bundle and just leave it to buck to compile it as a static library, it works. however, i need to able to generate a framework for future use Also, here's a repo for the whole example project if anyone wants to take a look over it: https://github.com/timofticiuc/BuckSample
cc @nguyentruongtho
Framework doesn't work currently, because exported headers from apple_library
are not propagated up to the bundle. The support for framework started at https://github.com/facebook/buck/pull/1032, and we are currently not actively working on it. Instead, we find another way without frameworks by supporting clang modules https://github.com/facebook/buck/pull/983.
We are discussing about continue our effort on supporting framework after module support, we also heard that Facebook is working on it @Coneko? Maybe we should have a meeting around this thing to make sure we are not duplicating our work.
Thanks dude, thought i was losing my mind. So as i see it, it's either let them link as static libraries or wait for #983 to be merged
Yes, I'm breaking up https://github.com/facebook/buck/pull/983 into smaller PRs, the first one is recently merged https://github.com/facebook/buck/issues/1238, and working on following up PRs.
Please read up about modules http://clang.llvm.org/docs/Modules.html, it is a similar concept to framework, and if it fits your case, you should wait for that PR to be merged.
Is it now possible to generate a .framework
that can be exported to Xcode app ?
We try to do it like:
load("//Config:buck_rule_macros.bzl", "apple_lib", "apple_pod_lib")
load("//Config:configs.bzl", "info_plist_substitutions")
apple_pod_lib(
name = "Shared",
srcs = glob([
"**/*.swift",
]),
supported_platforms_regex = '^(iphoneos|iphonesimulator).*',
exported_headers = glob([
"**/*.h",
]),
swift_version = "4.2",
deps = [
"//Frameworks:PromiseKit",
"//Frameworks:RealmSwift",
"//Frameworks:AdyenCSE",
"//Frameworks:BlurKit",
"//Frameworks:Differ",
"//Frameworks:Lottie",
"//Frameworks:nanopb",
"//Frameworks:netfox",
"//Frameworks:Nuke",
"//Frameworks:Protobuf",
"//Frameworks:Realm",
"//Frameworks:Starscream",
"//Frameworks:SwiftyBeaver",
"//Frameworks:Swinject",
"//Frameworks:ZXingObjC",
"//LegacyDependencies/AdidasUINew:AdidasUINew",
"//LegacyDependencies/TrackingCore:TrackingCore",
"//LegacyDependencies/AdidasUI:adidasUI",
"//LegacyDependencies/PhoneNumberKit:PhoneNumberKit",
"//LegacyDependencies/StoreFinder:StoreFinder",
"//LegacyDependencies/ConfirmedCore:ConfirmedCore",
"//LegacyDependencies/CustomerChatCore:CustomerChatCore",
"//LegacyDependencies/CustomerChatUI:CustomerChatUI",
":SharedAssets"
],
link_style = 'shared',
header_path_prefix = 'ObjcFramework',
)
apple_resource(
name = "SharedResources",
visibility = ["PUBLIC"],
files = glob([
"**/*.xib",
"**/*.storyboard",
]),
)
apple_asset_catalog(
name = "SharedAssets",
visibility = ["PUBLIC"],
dirs = glob(["**/*.xcassets"]),
)
apple_bundle(
name = "SharedBundle",
visibility = [
"PUBLIC",
],
extension = "framework",
binary = ":Shared#static",
product_name = "Shared",
info_plist = "Info.plist",
deps = [
":SharedResources",
],
info_plist_substitutions = info_plist_substitutions("Shared"),
)
the frameworks gets build, but I can't be imported from Xcode code
Is this issue still happening? I'm able to generate a framework (#dwarf-and-dsym,no-include-frameworks
) but I'm having issues with headers not being included.
I'm guessing the issue remains?
I'm trying to generate fat frameworks
to import on Xcode