diff --git a/.gitignore b/.gitignore index 4e0b092b1..576b1b0e0 100644 --- a/.gitignore +++ b/.gitignore @@ -13,11 +13,12 @@ xcuserdata *.xccheckout *.moved-aside DerivedData -*.hmap *.ipa *.xcuserstate .DS_Store /Example/Pods Podfile.lock +/Example/Gemfile.lock +/Example/bazel-* IDEWorkspaceChecks.plist *.xcworkspace diff --git a/Example/.bazeliskrc b/Example/.bazeliskrc new file mode 100644 index 000000000..b486c8a50 --- /dev/null +++ b/Example/.bazeliskrc @@ -0,0 +1 @@ +USE_BAZEL_VERSION=5.4.1 \ No newline at end of file diff --git a/Example/.bazelrc b/Example/.bazelrc new file mode 100644 index 000000000..958465a7a --- /dev/null +++ b/Example/.bazelrc @@ -0,0 +1,18 @@ +build \ + --spawn_strategy=local \ + --worker_sandboxing=false \ + --features=swift.cacheable_swiftmodules \ + --apple_platform_type=ios \ + --verbose_failures \ + --features=swift.use_global_module_cache \ + --strategy=SwiftCompile=worker \ + --experimental_guard_against_concurrent_changes \ + --features=apple.skip_codesign_simulator_bundles \ + --features=apple.arm64_simulator_use_device_deps \ + --features=swift.index_while_building \ + --features=swift.use_global_index_store \ + --modify_execution_info=^(BitcodeSymbolsCopy|BundleApp|BundleTreeApp|DsymDwarf|DsymLipo|GenerateAppleSymbolsFile|ObjcBinarySymbolStrip|CppLink|ObjcLink|ProcessAndSign|SignBinary|SwiftArchive|SwiftStdlibCopy)$=+no-remote,^(BundleResources|ImportedDynamicFrameworkProcessor)$=+no-remote-exec \ + + +build:Debug \ + --compilation_mode=dbg \ \ No newline at end of file diff --git a/Example/BUILD.bazel b/Example/BUILD.bazel new file mode 100644 index 000000000..68b2bb8db --- /dev/null +++ b/Example/BUILD.bazel @@ -0,0 +1,22 @@ +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") + + +swift_library( + name = "FLEXExampleSources", + srcs = glob(["FLEXample/App/**/*.swift"]) + ["FLEXample/AppDelegate.swift"], + deps = ["//Pods/FLEX"] +) + +ios_application( + name = "FLEXExample", + bundle_id = "com.flipboard.flex.FLEXample", + families = ["iphone"], + infoplists = ["FLEXample/Supporting Files/Info.plist"], + minimum_os_version = "12.0", + visibility = ["//visibility:public"], + deps = [ + "FLEXExampleSources", + ], + +) \ No newline at end of file diff --git a/Example/FLEXample/Supporting Files/Info.plist b/Example/FLEXample/Supporting Files/Info.plist index d299e079e..e21bfc78a 100644 --- a/Example/FLEXample/Supporting Files/Info.plist +++ b/Example/FLEXample/Supporting Files/Info.plist @@ -41,7 +41,7 @@ UISceneConfigurationName Default Configuration UISceneDelegateClassName - $(PRODUCT_MODULE_NAME).SceneDelegate + $(PRODUCT_NAME).SceneDelegate diff --git a/Example/Gemfile b/Example/Gemfile new file mode 100644 index 000000000..e26006167 --- /dev/null +++ b/Example/Gemfile @@ -0,0 +1 @@ +gem 'cocoapods-bazel' diff --git a/Example/Podfile b/Example/Podfile index d2316497a..410fff925 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,6 +1,14 @@ platform :ios, '13.0' +plugin 'cocoapods-bazel', { + rules: { + 'apple_framework' => { load: '@build_bazel_rules_ios//rules:framework.bzl', rule: 'apple_framework' }.freeze, + 'ios_application' => { load: '@build_bazel_rules_ios//rules:app.bzl', rule: 'ios_application' }.freeze, + 'ios_unit_test' => { load: '@build_bazel_rules_ios//rules:test.bzl', rule: 'ios_unit_test' }.freeze + }.freeze, +} + target 'FLEXample' do project 'FLEXample-Cocoapods' - pod 'FLEX', :path => '../' + pod 'FLEX', :git => 'https://github.com/gojekfarm/Flex.git', :branch => 'remove-private-api-usage-and-add-header-maps', :modular_headers => true , :configurations => ['Debug'] end diff --git a/Example/WORKSPACE b/Example/WORKSPACE new file mode 100644 index 000000000..8743b4779 --- /dev/null +++ b/Example/WORKSPACE @@ -0,0 +1,43 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "build_bazel_rules_ios", + remote = "https://github.com/bazel-ios/rules_ios.git", + commit = "3884a206840967cee89c4bf16202bd726c118772", +) + +load( + "@build_bazel_rules_ios//rules:repositories.bzl", + "rules_ios_dependencies" +) + +rules_ios_dependencies() + +load( + "@build_bazel_rules_apple//apple:repositories.bzl", + "apple_rules_dependencies", +) + +apple_rules_dependencies() + +load( + "@build_bazel_rules_swift//swift:repositories.bzl", + "swift_rules_dependencies", +) + +swift_rules_dependencies() + +load( + "@build_bazel_rules_swift//swift:extras.bzl", + "swift_rules_extra_dependencies", +) + +swift_rules_extra_dependencies() + +load( + "@build_bazel_apple_support//lib:repositories.bzl", + "apple_support_dependencies", +) + +apple_support_dependencies() diff --git a/FLEX.podspec b/FLEX.podspec index 6ab34cf2d..e9c962ce3 100644 --- a/FLEX.podspec +++ b/FLEX.podspec @@ -40,6 +40,7 @@ Pod::Spec.new do |spec| spec.xcconfig = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++11', } + spec.preserve_paths = '*.hmap', spec.compiler_flags = "-Wno-unsupported-availability-guard", "-Wno-deprecated-declarations" spec.public_header_files = [ "Classes/*.h", "Classes/Manager/*.h", "Classes/Toolbar/*.h", "Classes/Core/Controllers/*.h", "Classes/Core/Views/*.h", diff --git a/FLEX_private_hmap.hmap b/FLEX_private_hmap.hmap new file mode 100755 index 000000000..a6f55f4b5 Binary files /dev/null and b/FLEX_private_hmap.hmap differ diff --git a/FLEX_public_hmap.hmap b/FLEX_public_hmap.hmap new file mode 100755 index 000000000..ad25b448e Binary files /dev/null and b/FLEX_public_hmap.hmap differ diff --git a/README.md b/README.md index 6cff746f5..903549856 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,15 @@ FLEX (Flipboard Explorer) is a set of in-app debugging and exploration tools for Demo +## How to generate headermaps? +- Headermaps are required to build with Bazel +- To generate a new set of headermaps, cd into Example folder + - Run `pod install` + - Comment out `xcconfig = {"CLANG_CXX_LANGUAGE_STANDARD": "gnu++11"},` this line from Pods/FLEX/BUILD.bazel file + - Run this command `bazel build --config=Debug --ios_multi_cpus=sim_arm64 --xcode_version=14.3.0 --verbose_failures FLEXExample` , right now the build is failing but it generates headermaps. + - Copy these two generated hmap files - `bazel-out/ios-sim_arm64-min9.0-applebin_ios-ios_sim_arm64-dbg-ST-*/bin/Pods/FLEX/FLEX_private_hmap.hmap` and `bazel-out/ios-sim_arm64-min9.0-applebin_ios-ios_sim_arm64-dbg-ST-*/bin/Pods/FLEX/FLEX_public_hmap.hmap` + - Replace the headermap files are root with these copied headermap files. +- Headermap's are binary files, to inspect its content use this tool - https://github.com/milend/hmap ## Give Yourself Debugging Superpowers - Inspect and modify views in the hierarchy. - See the properties and ivars on any object.