Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/cocoapods-binary/Integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ def remove_target_files_if_needed
prebuilt_specs.each do |spec|
# `spec` may be a subspec, so we use the root's name
root_name = spec.root.name

target = name_to_target_hash[root_name]
next if Prebuild::Passer.target_names_to_skip_integration_framework.include? target.pod_name

# use the prebuilt framework
target = name_to_target_hash[root_name]
original_vendored_frameworks = spec.attributes_hash["vendored_frameworks"] || []
if original_vendored_frameworks.kind_of?(String)
original_vendored_frameworks = [original_vendored_frameworks]
Expand Down
13 changes: 11 additions & 2 deletions lib/cocoapods-binary/Prebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def prebuild_frameworks!
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s)
object
end
Prebuild::Passer.resources_to_copy_for_static_framework ||= {}
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
end
end
Expand All @@ -153,14 +152,24 @@ def prebuild_frameworks!
# copy vendored libraries and frameworks
targets.each do |target|
root_path = self.sandbox.pod_dir(target.name)
target_folder = sandbox.framework_folder_path_for_pod_name(target.name)

# If target shouldn't build, we copy all the original files
# This is for target with only .a and .h files
if not target.should_build?
Prebuild::Passer.target_names_to_skip_integration_framework << target.pod_name
FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
next
end

target.spec_consumers.each do |consumer|
file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
lib_paths = file_accessor.vendored_frameworks || []
lib_paths += file_accessor.vendored_libraries
# @TODO dSYM files
lib_paths.each do |lib_path|
relative = lib_path.relative_path_from(root_path)
destination = sandbox.framework_folder_path_for_pod_name(target.name) + relative
destination = target_folder + relative
destination.dirname.mkpath unless destination.dirname.exist?
FileUtils.cp_r(lib_path, destination, :remove_destination => true)
end
Expand Down
10 changes: 10 additions & 0 deletions lib/cocoapods-binary/helper/passer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class ResourcePath
#
# @return [Hash<String, [Passer::ResourcePath]>]
class_attr_accessor :resources_to_copy_for_static_framework
self.resources_to_copy_for_static_framework = {}

# Some pod won't be build in prebuild stage even if it have `binary=>true`.
# The targets of this pods have `oshould_build? == true`.
# We should skip integration (patch spec) for this pods
#
# @return [Array<String>]
class_attr_accessor :target_names_to_skip_integration_framework
self.target_names_to_skip_integration_framework = []

end
end
end
83 changes: 75 additions & 8 deletions test/Binary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
objects = {

/* Begin PBXBuildFile section */
3E1E218020A0B66900EFA102 /* import.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1E217F20A0B66900EFA102 /* import.swift */; };
3E83E326207BC00E0057855A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E83E325207BC00E0057855A /* AppDelegate.swift */; };
3E83E328207BC00E0057855A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E83E327207BC00E0057855A /* ViewController.swift */; };
AEBC61E3160A9AC38C3A210D /* Pods_Binary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5687B1A81F152DBEF5CD4432 /* Pods_Binary.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1856F5E2BE44EDB1E470521A /* Pods-Binary.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Binary.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Binary/Pods-Binary.debug.xcconfig"; sourceTree = "<group>"; };
3E1E217F20A0B66900EFA102 /* import.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = import.swift; sourceTree = "<group>"; };
3E83E322207BC00E0057855A /* Binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Binary.app; sourceTree = BUILT_PRODUCTS_DIR; };
3E83E325207BC00E0057855A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3E83E327207BC00E0057855A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
3E83E331207BC0120057855A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5687B1A81F152DBEF5CD4432 /* Pods_Binary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Binary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7EB848DBE64BD495BCC04ECC /* Pods-Binary.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Binary.release.xcconfig"; path = "Pods/Target Support Files/Pods-Binary/Pods-Binary.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
3E83E31F207BC00E0057855A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AEBC61E3160A9AC38C3A210D /* Pods_Binary.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -34,6 +41,8 @@
children = (
3E83E324207BC00E0057855A /* Binary */,
3E83E323207BC00E0057855A /* Products */,
E8117D681BF19C1B3D847824 /* Pods */,
8E13F0A6AED19C681C2CD7D5 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -50,21 +59,41 @@
children = (
3E83E325207BC00E0057855A /* AppDelegate.swift */,
3E83E327207BC00E0057855A /* ViewController.swift */,
3E1E217F20A0B66900EFA102 /* import.swift */,
3E83E331207BC0120057855A /* Info.plist */,
);
path = Binary;
sourceTree = "<group>";
};
8E13F0A6AED19C681C2CD7D5 /* Frameworks */ = {
isa = PBXGroup;
children = (
5687B1A81F152DBEF5CD4432 /* Pods_Binary.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
E8117D681BF19C1B3D847824 /* Pods */ = {
isa = PBXGroup;
children = (
1856F5E2BE44EDB1E470521A /* Pods-Binary.debug.xcconfig */,
7EB848DBE64BD495BCC04ECC /* Pods-Binary.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
3E83E321207BC00E0057855A /* Binary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 3E83E334207BC0120057855A /* Build configuration list for PBXNativeTarget "Binary" */;
buildPhases = (
3E002C27AE1ACBCE5F745FA7 /* [CP] Check Pods Manifest.lock */,
3E83E31E207BC00E0057855A /* Sources */,
3E83E31F207BC00E0057855A /* Frameworks */,
3E83E320207BC00E0057855A /* Resources */,
9937F6A880D56826534273F0 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -118,12 +147,54 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
3E002C27AE1ACBCE5F745FA7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Binary-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9937F6A880D56826534273F0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Binary/Pods-Binary-frameworks.sh",
"${PODS_ROOT}/AFNetworking/AFNetworking.framework",
"${PODS_ROOT}/Literal/Literal.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Literal.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Binary/Pods-Binary-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
3E83E31E207BC00E0057855A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3E83E328207BC00E0057855A /* ViewController.swift in Sources */,
3E1E218020A0B66900EFA102 /* import.swift in Sources */,
3E83E326207BC00E0057855A /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -247,13 +318,11 @@
};
3E83E335207BC0120057855A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 1856F5E2BE44EDB1E470521A /* Pods-Binary.debug.xcconfig */;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Binary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.leavez.Binary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
Expand All @@ -263,13 +332,11 @@
};
3E83E336207BC0120057855A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7EB848DBE64BD495BCC04ECC /* Pods-Binary.release.xcconfig */;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
INFOPLIST_FILE = Binary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.leavez.Binary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
Expand Down
4 changes: 4 additions & 0 deletions test/Binary/import.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

import Literal
import AFNetworking
import Instabug
56 changes: 48 additions & 8 deletions test/change_podfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,104 @@ def save_to_podfile(text):
path = os.path.dirname(os.path.abspath(__file__))
path += "/Podfile"
file = open(path, "w+")
file.write(text)
file.write(text[0])
file.close()

path = os.path.dirname(os.path.abspath(__file__))
path += "/Binary/import.swift"
file = open(path, "w+")
file.write(text[1])
file.close()



def initial():
return wrapper(
return (wrapper(
"""
pod "Masonry"
"""),
"""
import Masonry
""")

def addSwiftPod():
return wrapper(
return (wrapper(
"""
pod "Masonry", :binary => true
pod "Literal", :binary => true
"""),
"""
import Masonry
import Literal
""")

def addDifferentNamePod():
return wrapper(
return (wrapper(
"""
enable_bitcode_for_prebuilt_frameworks!

pod "Masonry", :binary => true
pod "Literal", :binary => true
pod "lottie-ios", :binary => true
"""),
"""
import Masonry
import Literal
import Lottie
""")


def addSubPod():
return wrapper(
return (wrapper(
"""
pod "Masonry", :binary => true
pod "Literal", :binary => true
pod "lottie-ios", :binary => true
pod "AFNetworking/Reachability", :binary => true
""") ,
"""
import Masonry
import Literal
import Lottie
import AFNetworking
""")

def addVendoredLibPod():
return wrapper(
return (wrapper(
"""
pod "Literal", :binary => true
pod "AFNetworking/Reachability", :binary => true
pod "Instabug", :binary => true
pod "GrowingIO", :binary => true
""") ,
"""
import Literal
import AFNetworking
import Instabug
""")

def deleteAPod():
return wrapper(
return (wrapper(
"""
pod "Literal", :binary => true
pod "AFNetworking/Reachability", :binary => true
""") ,
"""
import Literal
import AFNetworking
""")

def universalFlag():
return wrapper(
return (wrapper(
"""
all_binary!

pod "Literal"
pod "AFNetworking/Reachability"
""") ,
"""
import Literal
import AFNetworking
""")


Expand Down