Skip to content

Commit fdff9df

Browse files
author
Eric Wu
committed
修改获取idfv策略
1 parent cefddf8 commit fdff9df

18 files changed

+70
-537
lines changed

CRBoostSwift/Classes/CRMacros.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,18 @@ public let CRAppBuild = Bundle.main.infoDictionary![kCFBundleVersionKey as Strin
141141
public let CRAppVersionShort = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
142142
public let CRAppName = Bundle.main.infoDictionary!["CFBundleDisplayName"] as! String
143143

144-
public let CRIdfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
144+
public let CRIdfa: String = {
145+
var idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
146+
if #available(iOS 10.0, *) { // ios10更新之后一旦开启了 设置->隐私->广告->限制广告跟踪之后 获取到的idfa将会是一串00000
147+
if !ASIdentifierManager.shared().isAdvertisingTrackingEnabled {
148+
if let idfv = CRIdfv {
149+
idfa = idfv // idfv 是一定可以获取到的
150+
}
151+
}
152+
}
153+
return idfa
154+
}()
155+
145156
public let CRIdfv = UIDevice.current.identifierForVendor?.uuidString
146157

147158
// MARK: - App Default
@@ -262,7 +273,7 @@ public func CRRGBA(r: Float, g: Float, b: Float, a: Float = 1) -> UIColor {
262273
// rgbValue is a Hex vaule without prefix 0x
263274
@discardableResult
264275
public func CRRGBA_X(rgb: Int, a: Float = 1) -> UIColor {
265-
return CRRGBA(r: Float((rgb & 0xFF0000) >> 16), g: Float((rgb & 0xFF00) >> 8), b: (Float(rgb & 0xFF)), a: a)
276+
return CRRGBA(r: Float((rgb & 0xFF0000) >> 16), g: Float((rgb & 0xFF00) >> 8), b: Float(rgb & 0xFF), a: a)
266277
}
267278

268279
// MARK: - execution time

Example/CRBoostSwift.xcodeproj/project.pbxproj

Lines changed: 8 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,14 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
0E749F50988608F6B9D9580B /* Pods_CRBoostSwift_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 845504E04A40AE9EC51A8750 /* Pods_CRBoostSwift_Tests.framework */; };
1110
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
1211
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
1312
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
1413
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1514
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
16-
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
1715
70CDB0C39135DC1761B4FC6A /* Pods_CRBoostSwift_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F0C9210E93EC68FED7F76CDA /* Pods_CRBoostSwift_Example.framework */; };
1816
/* End PBXBuildFile section */
1917

20-
/* Begin PBXContainerItemProxy section */
21-
607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = {
22-
isa = PBXContainerItemProxy;
23-
containerPortal = 607FACC81AFB9204008FA782 /* Project object */;
24-
proxyType = 1;
25-
remoteGlobalIDString = 607FACCF1AFB9204008FA782;
26-
remoteInfo = CRBoostSwift;
27-
};
28-
/* End PBXContainerItemProxy section */
29-
3018
/* Begin PBXFileReference section */
3119
4A26062FAA527DCFA4963110 /* Pods-CRBoostSwift_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CRBoostSwift_Example.debug.xcconfig"; path = "Target Support Files/Pods-CRBoostSwift_Example/Pods-CRBoostSwift_Example.debug.xcconfig"; sourceTree = "<group>"; };
3220
607FACD01AFB9204008FA782 /* CRBoostSwift_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CRBoostSwift_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -36,9 +24,6 @@
3624
607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
3725
607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
3826
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
39-
607FACE51AFB9204008FA782 /* CRBoostSwift_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CRBoostSwift_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
40-
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
41-
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
4227
77CA9DBAEBD7A96AB0512FDA /* Pods-CRBoostSwift_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CRBoostSwift_Tests.release.xcconfig"; path = "Target Support Files/Pods-CRBoostSwift_Tests/Pods-CRBoostSwift_Tests.release.xcconfig"; sourceTree = "<group>"; };
4328
845504E04A40AE9EC51A8750 /* Pods_CRBoostSwift_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CRBoostSwift_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4429
93E89C38EEAB243ED7193F44 /* Pods-CRBoostSwift_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CRBoostSwift_Tests.debug.xcconfig"; path = "Target Support Files/Pods-CRBoostSwift_Tests/Pods-CRBoostSwift_Tests.debug.xcconfig"; sourceTree = "<group>"; };
@@ -57,14 +42,6 @@
5742
);
5843
runOnlyForDeploymentPostprocessing = 0;
5944
};
60-
607FACE21AFB9204008FA782 /* Frameworks */ = {
61-
isa = PBXFrameworksBuildPhase;
62-
buildActionMask = 2147483647;
63-
files = (
64-
0E749F50988608F6B9D9580B /* Pods_CRBoostSwift_Tests.framework in Frameworks */,
65-
);
66-
runOnlyForDeploymentPostprocessing = 0;
67-
};
6845
/* End PBXFrameworksBuildPhase section */
6946

7047
/* Begin PBXGroup section */
@@ -82,7 +59,6 @@
8259
children = (
8360
607FACF51AFB993E008FA782 /* Podspec Metadata */,
8461
607FACD21AFB9204008FA782 /* Example for CRBoostSwift */,
85-
607FACE81AFB9204008FA782 /* Tests */,
8662
607FACD11AFB9204008FA782 /* Products */,
8763
DF00D893D81A8619959AD3FD /* Pods */,
8864
18A6A22E4E7B151A388BFA58 /* Frameworks */,
@@ -93,7 +69,6 @@
9369
isa = PBXGroup;
9470
children = (
9571
607FACD01AFB9204008FA782 /* CRBoostSwift_Example.app */,
96-
607FACE51AFB9204008FA782 /* CRBoostSwift_Tests.xctest */,
9772
);
9873
name = Products;
9974
sourceTree = "<group>";
@@ -120,23 +95,6 @@
12095
name = "Supporting Files";
12196
sourceTree = "<group>";
12297
};
123-
607FACE81AFB9204008FA782 /* Tests */ = {
124-
isa = PBXGroup;
125-
children = (
126-
607FACEB1AFB9204008FA782 /* Tests.swift */,
127-
607FACE91AFB9204008FA782 /* Supporting Files */,
128-
);
129-
path = Tests;
130-
sourceTree = "<group>";
131-
};
132-
607FACE91AFB9204008FA782 /* Supporting Files */ = {
133-
isa = PBXGroup;
134-
children = (
135-
607FACEA1AFB9204008FA782 /* Info.plist */,
136-
);
137-
name = "Supporting Files";
138-
sourceTree = "<group>";
139-
};
14098
607FACF51AFB993E008FA782 /* Podspec Metadata */ = {
14199
isa = PBXGroup;
142100
children = (
@@ -179,25 +137,6 @@
179137
productReference = 607FACD01AFB9204008FA782 /* CRBoostSwift_Example.app */;
180138
productType = "com.apple.product-type.application";
181139
};
182-
607FACE41AFB9204008FA782 /* CRBoostSwift_Tests */ = {
183-
isa = PBXNativeTarget;
184-
buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "CRBoostSwift_Tests" */;
185-
buildPhases = (
186-
1A5F16C8890E824464FF11F9 /* [CP] Check Pods Manifest.lock */,
187-
607FACE11AFB9204008FA782 /* Sources */,
188-
607FACE21AFB9204008FA782 /* Frameworks */,
189-
607FACE31AFB9204008FA782 /* Resources */,
190-
);
191-
buildRules = (
192-
);
193-
dependencies = (
194-
607FACE71AFB9204008FA782 /* PBXTargetDependency */,
195-
);
196-
name = CRBoostSwift_Tests;
197-
productName = Tests;
198-
productReference = 607FACE51AFB9204008FA782 /* CRBoostSwift_Tests.xctest */;
199-
productType = "com.apple.product-type.bundle.unit-test";
200-
};
201140
/* End PBXNativeTarget section */
202141

203142
/* Begin PBXProject section */
@@ -210,12 +149,9 @@
210149
TargetAttributes = {
211150
607FACCF1AFB9204008FA782 = {
212151
CreatedOnToolsVersion = 6.3.1;
152+
DevelopmentTeam = H843PBVDG6;
213153
LastSwiftMigration = 0900;
214-
};
215-
607FACE41AFB9204008FA782 = {
216-
CreatedOnToolsVersion = 6.3.1;
217-
LastSwiftMigration = 1020;
218-
TestTargetID = 607FACCF1AFB9204008FA782;
154+
ProvisioningStyle = Manual;
219155
};
220156
};
221157
};
@@ -233,7 +169,6 @@
233169
projectRoot = "";
234170
targets = (
235171
607FACCF1AFB9204008FA782 /* CRBoostSwift_Example */,
236-
607FACE41AFB9204008FA782 /* CRBoostSwift_Tests */,
237172
);
238173
};
239174
/* End PBXProject section */
@@ -249,38 +184,9 @@
249184
);
250185
runOnlyForDeploymentPostprocessing = 0;
251186
};
252-
607FACE31AFB9204008FA782 /* Resources */ = {
253-
isa = PBXResourcesBuildPhase;
254-
buildActionMask = 2147483647;
255-
files = (
256-
);
257-
runOnlyForDeploymentPostprocessing = 0;
258-
};
259187
/* End PBXResourcesBuildPhase section */
260188

261189
/* Begin PBXShellScriptBuildPhase section */
262-
1A5F16C8890E824464FF11F9 /* [CP] Check Pods Manifest.lock */ = {
263-
isa = PBXShellScriptBuildPhase;
264-
buildActionMask = 2147483647;
265-
files = (
266-
);
267-
inputFileListPaths = (
268-
);
269-
inputPaths = (
270-
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
271-
"${PODS_ROOT}/Manifest.lock",
272-
);
273-
name = "[CP] Check Pods Manifest.lock";
274-
outputFileListPaths = (
275-
);
276-
outputPaths = (
277-
"$(DERIVED_FILE_DIR)/Pods-CRBoostSwift_Tests-checkManifestLockResult.txt",
278-
);
279-
runOnlyForDeploymentPostprocessing = 0;
280-
shellPath = /bin/sh;
281-
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";
282-
showEnvVarsInLog = 0;
283-
};
284190
61EE3E0A066FDAA0A517927A /* [CP] Check Pods Manifest.lock */ = {
285191
isa = PBXShellScriptBuildPhase;
286192
buildActionMask = 2147483647;
@@ -333,24 +239,8 @@
333239
);
334240
runOnlyForDeploymentPostprocessing = 0;
335241
};
336-
607FACE11AFB9204008FA782 /* Sources */ = {
337-
isa = PBXSourcesBuildPhase;
338-
buildActionMask = 2147483647;
339-
files = (
340-
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
341-
);
342-
runOnlyForDeploymentPostprocessing = 0;
343-
};
344242
/* End PBXSourcesBuildPhase section */
345243

346-
/* Begin PBXTargetDependency section */
347-
607FACE71AFB9204008FA782 /* PBXTargetDependency */ = {
348-
isa = PBXTargetDependency;
349-
target = 607FACCF1AFB9204008FA782 /* CRBoostSwift_Example */;
350-
targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */;
351-
};
352-
/* End PBXTargetDependency section */
353-
354244
/* Begin PBXVariantGroup section */
355245
607FACD91AFB9204008FA782 /* Main.storyboard */ = {
356246
isa = PBXVariantGroup;
@@ -475,12 +365,15 @@
475365
baseConfigurationReference = 4A26062FAA527DCFA4963110 /* Pods-CRBoostSwift_Example.debug.xcconfig */;
476366
buildSettings = {
477367
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
368+
CODE_SIGN_STYLE = Manual;
369+
DEVELOPMENT_TEAM = H843PBVDG6;
478370
INFOPLIST_FILE = CRBoostSwift/Info.plist;
479371
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
480372
MODULE_NAME = ExampleApp;
481373
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -D DEBUG";
482374
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
483375
PRODUCT_NAME = "$(TARGET_NAME)";
376+
PROVISIONING_PROFILE_SPECIFIER = "XC Wildcard_Dev(Simai)";
484377
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
485378
SWIFT_VERSION = 5.0;
486379
};
@@ -491,48 +384,19 @@
491384
baseConfigurationReference = DA0A16488ED230CD7307EEB7 /* Pods-CRBoostSwift_Example.release.xcconfig */;
492385
buildSettings = {
493386
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
387+
CODE_SIGN_STYLE = Manual;
388+
DEVELOPMENT_TEAM = "";
494389
INFOPLIST_FILE = CRBoostSwift/Info.plist;
495390
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
496391
MODULE_NAME = ExampleApp;
497392
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
498393
PRODUCT_NAME = "$(TARGET_NAME)";
394+
PROVISIONING_PROFILE_SPECIFIER = "";
499395
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
500396
SWIFT_VERSION = 5.0;
501397
};
502398
name = Release;
503399
};
504-
607FACF31AFB9204008FA782 /* Debug */ = {
505-
isa = XCBuildConfiguration;
506-
baseConfigurationReference = 93E89C38EEAB243ED7193F44 /* Pods-CRBoostSwift_Tests.debug.xcconfig */;
507-
buildSettings = {
508-
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
509-
GCC_PREPROCESSOR_DEFINITIONS = (
510-
"DEBUG=1",
511-
"$(inherited)",
512-
);
513-
INFOPLIST_FILE = Tests/Info.plist;
514-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
515-
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
516-
PRODUCT_NAME = "$(TARGET_NAME)";
517-
SWIFT_VERSION = 5.0;
518-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CRBoostSwift_Example.app/CRBoostSwift_Example";
519-
};
520-
name = Debug;
521-
};
522-
607FACF41AFB9204008FA782 /* Release */ = {
523-
isa = XCBuildConfiguration;
524-
baseConfigurationReference = 77CA9DBAEBD7A96AB0512FDA /* Pods-CRBoostSwift_Tests.release.xcconfig */;
525-
buildSettings = {
526-
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
527-
INFOPLIST_FILE = Tests/Info.plist;
528-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
529-
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
530-
PRODUCT_NAME = "$(TARGET_NAME)";
531-
SWIFT_VERSION = 5.0;
532-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CRBoostSwift_Example.app/CRBoostSwift_Example";
533-
};
534-
name = Release;
535-
};
536400
/* End XCBuildConfiguration section */
537401

538402
/* Begin XCConfigurationList section */
@@ -554,15 +418,6 @@
554418
defaultConfigurationIsVisible = 0;
555419
defaultConfigurationName = Release;
556420
};
557-
607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "CRBoostSwift_Tests" */ = {
558-
isa = XCConfigurationList;
559-
buildConfigurations = (
560-
607FACF31AFB9204008FA782 /* Debug */,
561-
607FACF41AFB9204008FA782 /* Release */,
562-
);
563-
defaultConfigurationIsVisible = 0;
564-
defaultConfigurationName = Release;
565-
};
566421
/* End XCConfigurationList section */
567422
};
568423
rootObject = 607FACC81AFB9204008FA782 /* Project object */;

Example/CRBoostSwift/ViewController.swift

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,19 @@ import CRBoostSwift
1212
import UIKit
1313

1414
class ViewController: UIViewController {
15+
let btnAdd = UIButton(type: .contactAdd)
1516
override func viewDidLoad() {
1617
super.viewDidLoad()
17-
// Do any additional setup after loading the view, typically from a nib.
18-
}
19-
20-
override func didReceiveMemoryWarning() {
21-
super.didReceiveMemoryWarning()
22-
// Dispose of any resources that can be recreated.
18+
view.addSubview(btnAdd)
2319
}
2420

2521
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
26-
CRPresentAlert(title: nil, msg: "安全验证", config: { alert in
27-
alert.addTextField { textField in
28-
textField.keyboardType = .asciiCapable
29-
textField.isSecureTextEntry = true
30-
textField.placeholder = "请输入登陆密码"
31-
}
32-
}, handler: { _ in
22+
let rect = CGRect(x: 25, y: 20, width: 100, height: 100)
23+
print("midX\(rect.midX),midY:\(rect.midY)")
24+
print(CRFrameCenter(rect: rect))
25+
btnAdd.centerX = view.centerX
26+
btnAdd.centerY = view.centerY
27+
print(CRIdfa)
3328

34-
}, canel: "取消", action: "确定")
3529
}
3630
}

Example/Podfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,4 @@ target 'CRBoostSwift_Example' do
66
# pod 'DoraemonKit', '~> 1.2.0', :subspecs => ['Core'], :configurations => ['Debug']
77
# pod 'SwiftLint'
88

9-
target 'CRBoostSwift_Tests' do
10-
inherit! :search_paths
11-
12-
13-
end
149
end

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ EXTERNAL SOURCES:
1111
SPEC CHECKSUMS:
1212
CRBoostSwift: fb794a4d62feacaf2ac26b0ab8860ed99b8ce9cb
1313

14-
PODFILE CHECKSUM: eadb9a58472b15ca5989ddcad9495b6c8fc94333
14+
PODFILE CHECKSUM: 31f8a7f6cd6c64a007709b2d505a8413d2c5448c
1515

16-
COCOAPODS: 1.7.4
16+
COCOAPODS: 1.7.5

Example/Pods/Manifest.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)