Skip to content

Commit 5976dc4

Browse files
authored
Merge pull request #23 from leavez/no_source
fix #20 correctly
2 parents 50e3a5b + aecf130 commit 5976dc4

File tree

6 files changed

+151
-19
lines changed

6 files changed

+151
-19
lines changed

lib/cocoapods-binary/Integration.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ def remove_target_files_if_needed
154154
prebuilt_specs.each do |spec|
155155
# `spec` may be a subspec, so we use the root's name
156156
root_name = spec.root.name
157+
158+
target = name_to_target_hash[root_name]
159+
next if Prebuild::Passer.target_names_to_skip_integration_framework.include? target.pod_name
157160

158161
# use the prebuilt framework
159-
target = name_to_target_hash[root_name]
160162
original_vendored_frameworks = spec.attributes_hash["vendored_frameworks"] || []
161163
if original_vendored_frameworks.kind_of?(String)
162164
original_vendored_frameworks = [original_vendored_frameworks]

lib/cocoapods-binary/Prebuild.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ def prebuild_frameworks!
143143
object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s)
144144
object
145145
end
146-
Prebuild::Passer.resources_to_copy_for_static_framework ||= {}
147146
Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
148147
end
149148
end
@@ -153,14 +152,24 @@ def prebuild_frameworks!
153152
# copy vendored libraries and frameworks
154153
targets.each do |target|
155154
root_path = self.sandbox.pod_dir(target.name)
155+
target_folder = sandbox.framework_folder_path_for_pod_name(target.name)
156+
157+
# If target shouldn't build, we copy all the original files
158+
# This is for target with only .a and .h files
159+
if not target.should_build?
160+
Prebuild::Passer.target_names_to_skip_integration_framework << target.pod_name
161+
FileUtils.cp_r(root_path, target_folder, :remove_destination => true)
162+
next
163+
end
164+
156165
target.spec_consumers.each do |consumer|
157166
file_accessor = Sandbox::FileAccessor.new(root_path, consumer)
158167
lib_paths = file_accessor.vendored_frameworks || []
159168
lib_paths += file_accessor.vendored_libraries
160169
# @TODO dSYM files
161170
lib_paths.each do |lib_path|
162171
relative = lib_path.relative_path_from(root_path)
163-
destination = sandbox.framework_folder_path_for_pod_name(target.name) + relative
172+
destination = target_folder + relative
164173
destination.dirname.mkpath unless destination.dirname.exist?
165174
FileUtils.cp_r(lib_path, destination, :remove_destination => true)
166175
end

lib/cocoapods-binary/helper/passer.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ class ResourcePath
2626
#
2727
# @return [Hash<String, [Passer::ResourcePath]>]
2828
class_attr_accessor :resources_to_copy_for_static_framework
29+
self.resources_to_copy_for_static_framework = {}
30+
31+
# Some pod won't be build in prebuild stage even if it have `binary=>true`.
32+
# The targets of this pods have `oshould_build? == true`.
33+
# We should skip integration (patch spec) for this pods
34+
#
35+
# @return [Array<String>]
36+
class_attr_accessor :target_names_to_skip_integration_framework
37+
self.target_names_to_skip_integration_framework = []
38+
2939
end
3040
end
3141
end

test/Binary.xcodeproj/project.pbxproj

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,29 @@
77
objects = {
88

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

1416
/* Begin PBXFileReference section */
17+
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>"; };
18+
3E1E217F20A0B66900EFA102 /* import.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = import.swift; sourceTree = "<group>"; };
1519
3E83E322207BC00E0057855A /* Binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Binary.app; sourceTree = BUILT_PRODUCTS_DIR; };
1620
3E83E325207BC00E0057855A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1721
3E83E327207BC00E0057855A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
1822
3E83E331207BC0120057855A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
23+
5687B1A81F152DBEF5CD4432 /* Pods_Binary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Binary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
24+
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>"; };
1925
/* End PBXFileReference section */
2026

2127
/* Begin PBXFrameworksBuildPhase section */
2228
3E83E31F207BC00E0057855A /* Frameworks */ = {
2329
isa = PBXFrameworksBuildPhase;
2430
buildActionMask = 2147483647;
2531
files = (
32+
AEBC61E3160A9AC38C3A210D /* Pods_Binary.framework in Frameworks */,
2633
);
2734
runOnlyForDeploymentPostprocessing = 0;
2835
};
@@ -34,6 +41,8 @@
3441
children = (
3542
3E83E324207BC00E0057855A /* Binary */,
3643
3E83E323207BC00E0057855A /* Products */,
44+
E8117D681BF19C1B3D847824 /* Pods */,
45+
8E13F0A6AED19C681C2CD7D5 /* Frameworks */,
3746
);
3847
sourceTree = "<group>";
3948
};
@@ -50,21 +59,41 @@
5059
children = (
5160
3E83E325207BC00E0057855A /* AppDelegate.swift */,
5261
3E83E327207BC00E0057855A /* ViewController.swift */,
62+
3E1E217F20A0B66900EFA102 /* import.swift */,
5363
3E83E331207BC0120057855A /* Info.plist */,
5464
);
5565
path = Binary;
5666
sourceTree = "<group>";
5767
};
68+
8E13F0A6AED19C681C2CD7D5 /* Frameworks */ = {
69+
isa = PBXGroup;
70+
children = (
71+
5687B1A81F152DBEF5CD4432 /* Pods_Binary.framework */,
72+
);
73+
name = Frameworks;
74+
sourceTree = "<group>";
75+
};
76+
E8117D681BF19C1B3D847824 /* Pods */ = {
77+
isa = PBXGroup;
78+
children = (
79+
1856F5E2BE44EDB1E470521A /* Pods-Binary.debug.xcconfig */,
80+
7EB848DBE64BD495BCC04ECC /* Pods-Binary.release.xcconfig */,
81+
);
82+
name = Pods;
83+
sourceTree = "<group>";
84+
};
5885
/* End PBXGroup section */
5986

6087
/* Begin PBXNativeTarget section */
6188
3E83E321207BC00E0057855A /* Binary */ = {
6289
isa = PBXNativeTarget;
6390
buildConfigurationList = 3E83E334207BC0120057855A /* Build configuration list for PBXNativeTarget "Binary" */;
6491
buildPhases = (
92+
3E002C27AE1ACBCE5F745FA7 /* [CP] Check Pods Manifest.lock */,
6593
3E83E31E207BC00E0057855A /* Sources */,
6694
3E83E31F207BC00E0057855A /* Frameworks */,
6795
3E83E320207BC00E0057855A /* Resources */,
96+
9937F6A880D56826534273F0 /* [CP] Embed Pods Frameworks */,
6897
);
6998
buildRules = (
7099
);
@@ -118,12 +147,54 @@
118147
};
119148
/* End PBXResourcesBuildPhase section */
120149

150+
/* Begin PBXShellScriptBuildPhase section */
151+
3E002C27AE1ACBCE5F745FA7 /* [CP] Check Pods Manifest.lock */ = {
152+
isa = PBXShellScriptBuildPhase;
153+
buildActionMask = 2147483647;
154+
files = (
155+
);
156+
inputPaths = (
157+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
158+
"${PODS_ROOT}/Manifest.lock",
159+
);
160+
name = "[CP] Check Pods Manifest.lock";
161+
outputPaths = (
162+
"$(DERIVED_FILE_DIR)/Pods-Binary-checkManifestLockResult.txt",
163+
);
164+
runOnlyForDeploymentPostprocessing = 0;
165+
shellPath = /bin/sh;
166+
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";
167+
showEnvVarsInLog = 0;
168+
};
169+
9937F6A880D56826534273F0 /* [CP] Embed Pods Frameworks */ = {
170+
isa = PBXShellScriptBuildPhase;
171+
buildActionMask = 2147483647;
172+
files = (
173+
);
174+
inputPaths = (
175+
"${SRCROOT}/Pods/Target Support Files/Pods-Binary/Pods-Binary-frameworks.sh",
176+
"${PODS_ROOT}/AFNetworking/AFNetworking.framework",
177+
"${PODS_ROOT}/Literal/Literal.framework",
178+
);
179+
name = "[CP] Embed Pods Frameworks";
180+
outputPaths = (
181+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
182+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Literal.framework",
183+
);
184+
runOnlyForDeploymentPostprocessing = 0;
185+
shellPath = /bin/sh;
186+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Binary/Pods-Binary-frameworks.sh\"\n";
187+
showEnvVarsInLog = 0;
188+
};
189+
/* End PBXShellScriptBuildPhase section */
190+
121191
/* Begin PBXSourcesBuildPhase section */
122192
3E83E31E207BC00E0057855A /* Sources */ = {
123193
isa = PBXSourcesBuildPhase;
124194
buildActionMask = 2147483647;
125195
files = (
126196
3E83E328207BC00E0057855A /* ViewController.swift in Sources */,
197+
3E1E218020A0B66900EFA102 /* import.swift in Sources */,
127198
3E83E326207BC00E0057855A /* AppDelegate.swift in Sources */,
128199
);
129200
runOnlyForDeploymentPostprocessing = 0;
@@ -247,13 +318,11 @@
247318
};
248319
3E83E335207BC0120057855A /* Debug */ = {
249320
isa = XCBuildConfiguration;
321+
baseConfigurationReference = 1856F5E2BE44EDB1E470521A /* Pods-Binary.debug.xcconfig */;
250322
buildSettings = {
251323
CODE_SIGN_STYLE = Automatic;
252324
INFOPLIST_FILE = Binary/Info.plist;
253-
LD_RUNPATH_SEARCH_PATHS = (
254-
"$(inherited)",
255-
"@executable_path/Frameworks",
256-
);
325+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
257326
PRODUCT_BUNDLE_IDENTIFIER = me.leavez.Binary;
258327
PRODUCT_NAME = "$(TARGET_NAME)";
259328
SWIFT_VERSION = 4.0;
@@ -263,13 +332,11 @@
263332
};
264333
3E83E336207BC0120057855A /* Release */ = {
265334
isa = XCBuildConfiguration;
335+
baseConfigurationReference = 7EB848DBE64BD495BCC04ECC /* Pods-Binary.release.xcconfig */;
266336
buildSettings = {
267337
CODE_SIGN_STYLE = Automatic;
268338
INFOPLIST_FILE = Binary/Info.plist;
269-
LD_RUNPATH_SEARCH_PATHS = (
270-
"$(inherited)",
271-
"@executable_path/Frameworks",
272-
);
339+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
273340
PRODUCT_BUNDLE_IDENTIFIER = me.leavez.Binary;
274341
PRODUCT_NAME = "$(TARGET_NAME)";
275342
SWIFT_VERSION = 4.0;

test/Binary/import.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
import Literal
3+
import AFNetworking
4+
import Instabug

test/change_podfile.py

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,64 +16,104 @@ def save_to_podfile(text):
1616
path = os.path.dirname(os.path.abspath(__file__))
1717
path += "/Podfile"
1818
file = open(path, "w+")
19-
file.write(text)
19+
file.write(text[0])
20+
file.close()
21+
22+
path = os.path.dirname(os.path.abspath(__file__))
23+
path += "/Binary/import.swift"
24+
file = open(path, "w+")
25+
file.write(text[1])
2026
file.close()
2127

2228

29+
2330
def initial():
24-
return wrapper(
31+
return (wrapper(
2532
"""
2633
pod "Masonry"
34+
"""),
35+
"""
36+
import Masonry
2737
""")
2838

2939
def addSwiftPod():
30-
return wrapper(
40+
return (wrapper(
3141
"""
3242
pod "Masonry", :binary => true
3343
pod "Literal", :binary => true
44+
"""),
45+
"""
46+
import Masonry
47+
import Literal
3448
""")
3549

3650
def addDifferentNamePod():
37-
return wrapper(
51+
return (wrapper(
3852
"""
3953
enable_bitcode_for_prebuilt_frameworks!
4054
4155
pod "Masonry", :binary => true
4256
pod "Literal", :binary => true
4357
pod "lottie-ios", :binary => true
58+
"""),
59+
"""
60+
import Masonry
61+
import Literal
62+
import Lottie
4463
""")
4564

65+
4666
def addSubPod():
47-
return wrapper(
67+
return (wrapper(
4868
"""
4969
pod "Masonry", :binary => true
5070
pod "Literal", :binary => true
5171
pod "lottie-ios", :binary => true
5272
pod "AFNetworking/Reachability", :binary => true
73+
""") ,
74+
"""
75+
import Masonry
76+
import Literal
77+
import Lottie
78+
import AFNetworking
5379
""")
5480

5581
def addVendoredLibPod():
56-
return wrapper(
82+
return (wrapper(
5783
"""
5884
pod "Literal", :binary => true
5985
pod "AFNetworking/Reachability", :binary => true
6086
pod "Instabug", :binary => true
87+
pod "GrowingIO", :binary => true
88+
""") ,
89+
"""
90+
import Literal
91+
import AFNetworking
92+
import Instabug
6193
""")
6294

6395
def deleteAPod():
64-
return wrapper(
96+
return (wrapper(
6597
"""
6698
pod "Literal", :binary => true
6799
pod "AFNetworking/Reachability", :binary => true
100+
""") ,
101+
"""
102+
import Literal
103+
import AFNetworking
68104
""")
69105

70106
def universalFlag():
71-
return wrapper(
107+
return (wrapper(
72108
"""
73109
all_binary!
74110
75111
pod "Literal"
76112
pod "AFNetworking/Reachability"
113+
""") ,
114+
"""
115+
import Literal
116+
import AFNetworking
77117
""")
78118

79119

0 commit comments

Comments
 (0)