diff --git a/BUILD b/BUILD index addf80b..d29a802 100644 --- a/BUILD +++ b/BUILD @@ -25,7 +25,7 @@ macos_command_line_application( name = "bazelpods", minimum_os_version = MACOS_VERSION, deps = [":BazelPodsLib"], - visibility = ["//xcodeproj:__pkg__"] + visibility = ["//visibility:public"] ) swift_library( @@ -56,7 +56,7 @@ macos_command_line_application( name = "Analyzer", minimum_os_version = MACOS_VERSION, deps = [":AnalyzerLib"], - visibility = ["//xcodeproj:__pkg__"] + visibility = ["//visibility:public"] ) swift_library( diff --git a/Sources/BazelPodsCore/Analyzer/Analyzers/SourcesAnalyzer.swift b/Sources/BazelPodsCore/Analyzer/Analyzers/SourcesAnalyzer.swift index c7a85a1..241af7f 100644 --- a/Sources/BazelPodsCore/Analyzer/Analyzers/SourcesAnalyzer.swift +++ b/Sources/BazelPodsCore/Analyzer/Analyzers/SourcesAnalyzer.swift @@ -33,6 +33,7 @@ public struct SourcesAnalyzer { let sourceFiles: GlobNodeV2 let publicHeaders: GlobNodeV2 let privateHeaders: GlobNodeV2 + let nonArcSourceFiles: GlobNodeV2 let sourcesType: SourcesType var linkDynamic: Bool } @@ -119,10 +120,18 @@ public struct SourcesAnalyzer { !spec.staticFramework && sourcesType.oneOf(.swiftOnly, .objcOnly, .mixed) + let requiresArc: Bool + if (spec.requiresArc == .left(false) || spec.requiresArc == .right(["false"])) && subspecs.isEmpty { + requiresArc = false + } else { + requiresArc = true + } + return Result( - sourceFiles: sourceFiles ?? .empty, + sourceFiles: requiresArc ? sourceFiles ?? .empty : .empty, publicHeaders: publicHeaders ?? .empty, privateHeaders: privateHeaders ?? .empty, + nonArcSourceFiles: !requiresArc ? sourceFiles ?? .empty : .empty, sourcesType: sourcesType, linkDynamic: linkDynamic ) diff --git a/Sources/BazelPodsCore/Core/Magmas.swift b/Sources/BazelPodsCore/Core/Magmas.swift index a6706c5..118e31a 100644 --- a/Sources/BazelPodsCore/Core/Magmas.swift +++ b/Sources/BazelPodsCore/Core/Magmas.swift @@ -229,3 +229,5 @@ public indirect enum Either { } } } + +extension Either: Equatable where T: Equatable, U: Equatable { } diff --git a/Sources/BazelPodsCore/Targets/AppleFramework.swift b/Sources/BazelPodsCore/Targets/AppleFramework.swift index 1044985..b111d25 100644 --- a/Sources/BazelPodsCore/Targets/AppleFramework.swift +++ b/Sources/BazelPodsCore/Targets/AppleFramework.swift @@ -142,6 +142,7 @@ struct AppleFramework: BazelTarget { .named(name: "infoplists", value: infoplists.map({ ":" + $0 }).toStarlark()), .named(name: "platforms", value: info.platforms.toStarlark()), .named(name: "srcs", value: sources.sourceFiles.toStarlark()), + .named(name: "non_arc_srcs", value: sources.nonArcSourceFiles.toStarlark()), .named(name: "public_headers", value: sources.publicHeaders.toStarlark()), .named(name: "private_headers", value: sources.privateHeaders.toStarlark()), .named(name: "data", value: packData()), diff --git a/TestTools/Pods.json b/TestTools/Pods.json index 3d6a09c..bff8783 100644 --- a/TestTools/Pods.json +++ b/TestTools/Pods.json @@ -89,6 +89,7 @@ "PhoneNumberKit": "3.6.3", "PromiseKit": "6.18.1", "PromisesObjC": "2.1.1", + "Protobuf": "3.22.0", "PubguardSDK": "", "QMUIKit": "", "QY_NIM_iOS_SDK": "8.4.1", diff --git a/TestTools/Pods_Integration.json b/TestTools/Pods_Integration.json index 485a751..0385f6a 100644 --- a/TestTools/Pods_Integration.json +++ b/TestTools/Pods_Integration.json @@ -29,6 +29,7 @@ "ObjectMapper": "4.2.0", "Onfido": "25.2.0", "PromiseKit": "6.18.1", + "Protobuf": "3.22.0", "R.swift": "6.1.0", "ReSwift": "6.1.0", "ReachabilitySwift": "5.0.0", diff --git a/Tests/Recorded/MMKV/BUILD.bazel b/Tests/Recorded/MMKV/BUILD.bazel index e054db3..5863183 100644 --- a/Tests/Recorded/MMKV/BUILD.bazel +++ b/Tests/Recorded/MMKV/BUILD.bazel @@ -21,7 +21,7 @@ apple_framework( platforms = { "ios": "10.0" }, - srcs = glob( + non_arc_srcs = glob( [ "iOS/MMKV/MMKV/**/*.S", "iOS/MMKV/MMKV/**/*.c", diff --git a/Tests/Recorded/MTAppenderFile/BUILD.bazel b/Tests/Recorded/MTAppenderFile/BUILD.bazel index 3bbfb62..7a9260d 100644 --- a/Tests/Recorded/MTAppenderFile/BUILD.bazel +++ b/Tests/Recorded/MTAppenderFile/BUILD.bazel @@ -21,7 +21,7 @@ apple_framework( platforms = { "ios": "10.0" }, - srcs = glob( + non_arc_srcs = glob( [ "comm/**/*.c", "comm/**/*.cc", diff --git a/Tests/Recorded/Protobuf/BUILD.bazel b/Tests/Recorded/Protobuf/BUILD.bazel new file mode 100644 index 0000000..dbae7a5 --- /dev/null +++ b/Tests/Recorded/Protobuf/BUILD.bazel @@ -0,0 +1,112 @@ +load('@build_bazel_rules_ios//rules:framework.bzl', 'apple_framework') +# Add a config setting release for compilation mode +# Assume that people are using `opt` for release mode +# see the bazel user manual for more information +# https://docs.bazel.build/versions/master/be/general.html#config_setting +config_setting( + name = "release", + values = { + "compilation_mode": "opt" + } +) +apple_framework( + name = "Protobuf", + module_name = "Protobuf", + bundle_id = "org.cocoapods.Protobuf", + link_dynamic = True, + testonly = False, + infoplists = [ + ":Protobuf_InfoPlist" + ], + platforms = { + "ios": "10.0" + }, + non_arc_srcs = glob( + [ + "objectivec/*.h", + "objectivec/*.m", + "objectivec/google/protobuf/Any.pbobjc.h", + "objectivec/google/protobuf/Api.pbobjc.h", + "objectivec/google/protobuf/Duration.pbobjc.h", + "objectivec/google/protobuf/Empty.pbobjc.h", + "objectivec/google/protobuf/FieldMask.pbobjc.h", + "objectivec/google/protobuf/SourceContext.pbobjc.h", + "objectivec/google/protobuf/Struct.pbobjc.h", + "objectivec/google/protobuf/Timestamp.pbobjc.h", + "objectivec/google/protobuf/Type.pbobjc.h", + "objectivec/google/protobuf/Wrappers.pbobjc.h" + ] + ), + objc_defines = [ + "COCOAPODS=1" + ] + select( + { + "//conditions:default": [ + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1" + ], + ":release": [ + "POD_CONFIGURATION_RELEASE=1" + ] + } + ), + swift_defines = [ + "COCOAPODS" + ] + select( + { + "//conditions:default": [ + "DEBUG" + ] + } + ), + xcconfig = { + "GCC_PREPROCESSOR_DEFINITIONS": [ + "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1" + ] + }, + visibility = [ + "//visibility:public" + ] +) +genrule( + name = "Protobuf_InfoPlist", + srcs = [], + outs = [ + "Protobuf_InfoPlist.plist" + ], + cmd = """cat < $@ + + + + + CFBundleIdentifier + org.cocoapods.Protobuf + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Protobuf + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.22.0 + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + iPhoneSimulator + iPhoneOS + + CFBundleVersion + 1 + MinimumOSVersion + 10.0 + UIDeviceFamily + + 1 + 2 + + + + +EOF""" +) \ No newline at end of file diff --git a/Tests/Recorded/Yoga/BUILD.bazel b/Tests/Recorded/Yoga/BUILD.bazel index 1e91176..7f0f462 100644 --- a/Tests/Recorded/Yoga/BUILD.bazel +++ b/Tests/Recorded/Yoga/BUILD.bazel @@ -21,7 +21,7 @@ apple_framework( platforms = { "ios": "10.0" }, - srcs = glob( + non_arc_srcs = glob( [ "yoga/**/*.c", "yoga/**/*.cpp", diff --git a/Tests/Recorded/ZipArchive/BUILD.bazel b/Tests/Recorded/ZipArchive/BUILD.bazel index 4a4a203..d9da833 100644 --- a/Tests/Recorded/ZipArchive/BUILD.bazel +++ b/Tests/Recorded/ZipArchive/BUILD.bazel @@ -21,7 +21,7 @@ apple_framework( platforms = { "ios": "10.0" }, - srcs = glob( + non_arc_srcs = glob( [ "*.h", "*.m", diff --git a/xcodeconfig/xcodeconfig.sh b/xcodeconfig/xcodeconfig.sh index 17fe5fc..bd05366 100644 --- a/xcodeconfig/xcodeconfig.sh +++ b/xcodeconfig/xcodeconfig.sh @@ -8,8 +8,10 @@ XCODE_BUILD_NUMBER=$(echo "$XCODE_VERSION_FULL" | tail -n 1 | awk '{ print $3 }' # If XCODE_VERSION has only 1 dot, append a ".0" if [[ $XCODE_VERSION == *.* && ! $XCODE_VERSION == *.*.* ]]; then XCODE_VERSION_EXTENDED="$XCODE_VERSION.0" + XCODE_ALIASES="['${XCODE_VERSION_EXTENDED}.${XCODE_BUILD_NUMBER}', '${XCODE_VERSION}', '${XCODE_VERSION_EXTENDED}', '${XCODE_BUILD_NUMBER}', '${XCODE_VERSION%%.*}']," else XCODE_VERSION_EXTENDED="$XCODE_VERSION" + XCODE_ALIASES="['${XCODE_VERSION_EXTENDED}.${XCODE_BUILD_NUMBER}', '${XCODE_VERSION}', '${XCODE_BUILD_NUMBER}', '${XCODE_VERSION%%.*}']," fi # Get the SDK versions @@ -22,7 +24,7 @@ WATCHOS_SDK_VERSION=$(xcodebuild -showsdks | grep -Eo 'watchos[0-9.]+' | grep -E echo "xcode_version( name = 'version${XCODE_VERSION//./_}_${XCODE_BUILD_NUMBER//./_}', version = '${XCODE_VERSION_EXTENDED}.${XCODE_BUILD_NUMBER}', - aliases = ['${XCODE_VERSION_EXTENDED}.${XCODE_BUILD_NUMBER}', '${XCODE_VERSION}', '${XCODE_VERSION_EXTENDED}', '${XCODE_BUILD_NUMBER}', '${XCODE_VERSION%%.*}'], + aliases = ${XCODE_ALIASES} default_ios_sdk_version = '$IOS_SDK_VERSION', default_tvos_sdk_version = '$TVOS_SDK_VERSION', default_macos_sdk_version = '$MACOS_SDK_VERSION', diff --git a/xcodeproj/BUILD b/xcodeproj/BUILD index e18cad5..5c2bd3e 100644 --- a/xcodeproj/BUILD +++ b/xcodeproj/BUILD @@ -61,6 +61,38 @@ fi args = ["arm64sim --src $SRCROOT/Tests -f --log-level debug"] ), ), + xcode_schemes.scheme( + name = BAZELPODS + " IntegrationTests", + build_action = xcode_schemes.build_action(targets = ["//:%s" % BAZELPODS]), + launch_action = xcode_schemes.launch_action( + target = "//:%s" % BAZELPODS, + args = ["--src $SRCROOT/IntegrationTests -a --log-level debug --patches bundle_deduplicate arm64_to_sim missing_sdks --diff"] + ), + ), + xcode_schemes.scheme( + name = BAZELPODS + " IntegrationTests Frameworks", + build_action = xcode_schemes.build_action(targets = ["//:%s" % BAZELPODS]), + launch_action = xcode_schemes.launch_action( + target = "//:%s" % BAZELPODS, + args = ["--src $SRCROOT/IntegrationTests -a -f --log-level debug --patches bundle_deduplicate arm64_to_sim missing_sdks --diff"] + ), + ), + xcode_schemes.scheme( + name = BAZELPODS + " arm64sim IntegrationTests", + build_action = xcode_schemes.build_action(targets = ["//:%s" % BAZELPODS]), + launch_action = xcode_schemes.launch_action( + target = "//:%s" % BAZELPODS, + args = ["arm64sim --src $SRCROOT/IntegrationTests --log-level debug"] + ), + ), + xcode_schemes.scheme( + name = BAZELPODS + " arm64sim IntegrationTests Frameworks", + build_action = xcode_schemes.build_action(targets = ["//:%s" % BAZELPODS]), + launch_action = xcode_schemes.launch_action( + target = "//:%s" % BAZELPODS, + args = ["arm64sim --src $SRCROOT/IntegrationTests -f --log-level debug"] + ), + ), ], tags = ["manual"], )