Skip to content

Commit 7bd5c11

Browse files
committed
Merge branch 'develop'
2 parents 83b6f59 + e6821af commit 7bd5c11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+12972
-1976
lines changed

.travis.sh

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
#! /usr/bin/env sh
1+
#! /bin/zsh
22

3-
set -eo pipefail
4-
# set -euxo pipefail
3+
set -euo pipefail
54

6-
echo $TRAVIS_COMMIT_MESSAGE
7-
echo "RFCI_TASK = $RFCI_TASK"
8-
readonly RFWorkspace="RFAPI.xcworkspace"
9-
readonly RFSTAGE="$1"
10-
echo "RFSTAGE = $RFSTAGE"
5+
logInfo () {
6+
echo "\033[32m$1\033[0m" >&2
7+
}
8+
9+
logWarning () {
10+
echo "\033[33m$1\033[0m" >&2
11+
}
12+
13+
logError () {
14+
echo "\033[31m$1\033[0m" >&2
15+
}
16+
17+
# Make sure all parameters are set correctly.
18+
logInfo "RFCI_PRODUCT_NAME = $RFCI_PRODUCT_NAME"
19+
20+
readonly RFCI_TASK="${RFCI_TASK:? is not set.}"
21+
logInfo "RFCI_TASK = $RFCI_TASK"
22+
23+
readonly RFCI_STAGE="${1:?STAGE is not set.}"
24+
logInfo "RFCI_STAGE = $RFCI_STAGE"
25+
26+
readonly RFWorkspace=${RFWorkspace:="$RFCI_PRODUCT_NAME.xcworkspace"}
27+
logInfo "RFWorkspace = $RFWorkspace"
28+
29+
TRAVIS_COMMIT_MESSAGE=${TRAVIS_COMMIT_MESSAGE:="$(logWarning 'TRAVIS_COMMIT_MESSAGE is not set, leave it blank.')"}
30+
TRAVIS_BRANCH=${TRAVIS_BRANCH:="$(logWarning 'TRAVIS_BRANCH is not set, leave it blank.')"}
31+
32+
echo ""
1133

1234
# Run test
1335
# $1 scheme
@@ -23,32 +45,60 @@ XC_TestMac() {
2345

2446
# Run watchOS test
2547
XC_TestWatch() {
26-
xcodebuild build -workspace "$RFWorkspace" -scheme Target-watchOS ONLY_ACTIVE_ARCH=NO | xcpretty
48+
xcodebuild build -workspace "$RFWorkspace" -scheme "Target-watchOS" ONLY_ACTIVE_ARCH=NO | xcpretty
49+
}
50+
51+
# Run tests on iOS Simulator.
52+
# The destinations are the first and last available destination that are automatically detected.
53+
# $1 scheme
54+
XC_TestAutoIOS() {
55+
logInfo "Detecting destinations..."
56+
destList=$(xcodebuild -showdestinations -workspace "$RFWorkspace" -scheme "$1" | grep "iOS Simulator")
57+
destCount=$(echo "$destList" | wc -l)
58+
destFirst=$(echo "$destList" | head -1)
59+
destLast=$(echo "$destList" | tail -2 | head -1)
60+
destFirstID=$(echo "$destFirst" | awk 'match($0,/id\:[0-9A-F-]+/){ print substr($0,RSTART+3,RLENGTH-3) }')
61+
destLastID=$(echo "$destLast" | awk 'match($0,/id\:[0-9A-F-]+/){ print substr($0,RSTART+3,RLENGTH-3) }')
62+
63+
logWarning "Test on simulator (id: $destFirstID)."
64+
XC_Test "$1" "platform=iOS Simulator,id=$destFirstID"
65+
66+
logWarning "Test on simulator (id: $destLastID)."
67+
XC_Test "$1" "platform=iOS Simulator,id=$destLastID"
68+
}
69+
70+
STAGE_SETUP() {
71+
gem install cocoapods --no-document
2772
}
2873

2974
STAGE_MAIN() {
3075
if [ "$RFCI_TASK" = "POD_LINT" ]; then
3176
if [[ "$TRAVIS_COMMIT_MESSAGE" = *"[skip lint]"* ]]; then
32-
echo "Skip pod lint"
77+
logWarning "Skip pod lint"
3378
else
34-
echo "TRAVIS_BRANCH = $TRAVIS_BRANCH"
35-
gem install cocoapods --no-rdoc --no-ri --no-document --quiet
36-
# Always allow warnings as third-party dependencies generate unavoidable warnings.
37-
pod lib lint --allow-warnings
79+
if [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+ ]]; then
80+
logWarning "Release the podspec."
81+
pod trunk push "$RFCI_PRODUCT_NAME.podspec"
82+
elif [ "$TRAVIS_BRANCH" = "master" ]; then
83+
logInfo "Lint the podspec."
84+
pod lib lint --fail-fast
85+
else
86+
logInfo "Lint the podspec."
87+
pod lib lint --fail-fast --allow-warnings
88+
fi
3889
fi
3990

40-
elif [ "$RFCI_TASK" = "Xcode9" ]; then
91+
elif [ "$RFCI_TASK" = "Xcode10" ]; then
4192
pod install
4293
XC_TestMac
43-
XC_Test "Example-iOS" "platform=iOS Simulator,name=iPhone 6,OS=11.2"
44-
# XC_Test "Example-iOS" "platform=iOS Simulator,name=X1,OS=11.3"
94+
XC_TestAutoIOS "Test-iOS"
4595
else
46-
echo "Unexpected CI task: $RFCI_TASK"
96+
logError "Unexpected CI task: $RFCI_TASK"
4797
fi
4898
}
4999

50100
STAGE_SUCCESS() {
51-
if [ "$RFCI_TASK" = "Xcode9" ]; then
101+
if [ "${RFCI_COVERAGE-}" = "1" ]; then
52102
curl -s https://codecov.io/bash | bash -s
53103
fi
54104
}
@@ -59,4 +109,4 @@ STAGE_FAILURE() {
59109
fi
60110
}
61111

62-
"STAGE_$RFSTAGE"
112+
"STAGE_$RFCI_STAGE"

.travis.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ env:
66
- LC_CTYPE=en_US.UTF-8
77
- LANG=en_US.UTF-8
88
- LANGUAGE=en_US.UTF-8
9+
- RFCI_PRODUCT_NAME="RFAPI"
10+
- RFWorkspace="RFAPI.xcworkspace"
911
matrix:
1012
include:
11-
- osx_image: xcode9.3
13+
- osx_image: xcode11.3
1214
env: RFCI_TASK="POD_LINT"
13-
- osx_image: xcode9.3
14-
env: RFCI_TASK="Xcode9"
15-
before_install:
16-
- pod repo update master --silent
17-
script: ./.travis.sh MAIN
18-
after_success: ./.travis.sh SUCCESS
19-
after_failure: ./.travis.sh FAILURE
15+
- osx_image: xcode10
16+
env:
17+
- RFCI_TASK="Xcode10"
18+
- RFCI_COVERAGE=1
19+
before_install: ./.travis.sh SETUP
20+
script: ./.travis.sh MAIN
21+
after_success: ./.travis.sh SUCCESS
22+
after_failure: ./.travis.sh FAILURE

Documents/design.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RFAPI 背后的设计
2+
3+
好的设计应该是不会过时的
4+

Documents/migration_guide_v2.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# RFAPI v2 升级指南
2+
3+
> *Because there should be no non-Chinese developers using this library before, this guide is not available in English at this time.*
4+
5+
v1 到 v2 几乎全部重写,内部变化很大,但是实际项目需要调整的地方应该不多。
6+
7+
如果只是用到请求发送、取消这样的基本功能,甚至无需修改。
8+
9+
## 主要类型变化
10+
11+
`RFAPI` 的父类由 `NSOperationQueue` 变为 `NSObject`。如果之前用到了 NSOperationQueue 的方法,只能都移除了。`maxConcurrentOperationCount` 可以改用 NSURLSessionConfiguration 的 `HTTPMaximumConnectionsPerHost` 属性设置。
12+
13+
请求方法返回的请求对象类型从 `AFHTTPRequestOperation` 变为 `RFAPITask`,暴露的属性有减少。
14+
15+
`RFAPIControl` 被移除,取而代之的类是 `RFAPIRequestConext`,必须修改的地方并不多:
16+
17+
* `message` 属性更名为 `activityMessage`
18+
* 移除的属性都没用到,`RFAPIRequestConext` 新增的属性也无需修改;
19+
* 不再支持从字典创建,这个正常用得极少。
20+
21+
缓存管理移除了,但这个系统只在 iOS 7 之前工作,正常的项目应该影响不到。
22+
23+
## Define 和 DefineManager
24+
25+
`RFAPIDefine``responseClass` 类型由 class 改为 string,其他在外部看来没有变化。
26+
27+
`RFAPIDefineManager` 现在直接使用 define 对象,不再使用字典作为存储。`defaultRule` 更名为 `defaultDefine`,修改立即生效,无需再手动调用 `setNeedsUpdateDefaultRule` 方法。之前对 define 字段进行修改的方法被移除,直接对 define 对象进行修改即可。`setDefinesWithRulesInfo:` 现在支持分组。
28+
29+
在 DEBUG 环境(准确的说是 RFDEBUG 为真且 NSAssert 启用)下编译的 RFAPI,在 define 处理时会进行一些额外检查,帮助你正确使用,Release 环境这些检查不会执行。
30+
31+
## 请求创建
32+
33+
v1 请求有两个方法,正常请求和表单上传请求,正常请求有兼容实现,可无需修改(但是推荐改成新的方法)。
34+
35+
表单上传只能用新的请求方法,不再需要 `RFHTTPRequestFormData`,直接设置 request context 的 formData 即可。
36+
37+
## responseProcessingQueue
38+
39+
变为 `processingQueue`,默认的队列由主线程队列变为私有的并行队列。
40+
41+
## Swift
42+
43+
如果之前在 Swift 中子类了 `RFAPI`,可能需要调整方法名,需要重写的方法有了更合适的命名。
44+
45+
## 国际化
46+
47+
// todo
48+
<!-- v1 的很多错误信息是硬编码在代码中的 -->
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.network.client</key>
8+
<true/>
9+
</dict>
10+
</plist>
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
#import "JSONModel.h"
1010

1111
@interface RFDTestEntity : JSONModel
12-
@property (assign, nonatomic) int uid;
13-
@property (strong, nonatomic) NSString *name;
14-
@end
15-
16-
@protocol RFDTestEntity <NSObject>
12+
@property int uid;
13+
@property NSString *name;
1714
@end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#import "RFDTestEntity.h"
3-
#import "RFRuntime.h"
3+
#import <RFKit/RFRuntime.h>
44

55
@implementation RFDTestEntity
66

Example/Shared/OCBridging-Header.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
// Use this file to import your target's public headers that you would like to expose to Swift.
33
//
44

5+
#import <AFNetworking/AFURLRequestSerialization.h>
6+
#import <AFNetworking/AFURLResponseSerialization.h>
57
#import <RFAPI/RFAPI.h>
8+
#import <RFAPI/RFAPIDefineConfigFile.h>
9+
#import <RFAPI/RFAPIJSONModelTransformer.h>
610
#import <RFMessageManager/RFSVProgressMessageManager.h>

Example/iOS-Swift/AppDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import UIKit
1010
@UIApplicationMain
1111
class AppDelegate: UIResponder, UIApplicationDelegate {
1212
var window: UIWindow?
13-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
13+
14+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
1415
return true
1516
}
1617
}

Example/iOS-Swift/Main.storyboard

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="von-Nu-zIU">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="von-Nu-zIU">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<scenes>
@@ -14,7 +12,7 @@
1412
<objects>
1513
<navigationController id="von-Nu-zIU" sceneMemberID="viewController">
1614
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="51V-PD-3Mz">
17-
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
15+
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
1816
<autoresizingMask key="autoresizingMask"/>
1917
</navigationBar>
2018
<connections>
@@ -23,12 +21,12 @@
2321
</navigationController>
2422
<placeholder placeholderIdentifier="IBFirstResponder" id="Y9Z-3Q-GfH" userLabel="First Responder" sceneMemberID="firstResponder"/>
2523
</objects>
26-
<point key="canvasLocation" x="28" y="483"/>
24+
<point key="canvasLocation" x="31" y="323"/>
2725
</scene>
2826
<!--RFAPI-->
2927
<scene sceneID="FlU-N5-eoc">
3028
<objects>
31-
<viewController automaticallyAdjustsScrollViewInsets="NO" id="G31-9q-QIj" customClass="RFDAPITestViewController" sceneMemberID="viewController">
29+
<viewController automaticallyAdjustsScrollViewInsets="NO" id="G31-9q-QIj" customClass="TestViewController" customModule="Example_iOS" customModuleProvider="target" sceneMemberID="viewController">
3230
<layoutGuides>
3331
<viewControllerLayoutGuide type="top" id="VYZ-kw-ClE"/>
3432
<viewControllerLayoutGuide type="bottom" id="UvO-60-D33"/>
@@ -38,14 +36,14 @@
3836
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3937
<subviews>
4038
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="08X-eY-SGq">
41-
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
39+
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
4240
<subviews>
4341
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3Op-hc-Txc" userLabel="Content">
44-
<rect key="frame" x="0.0" y="0.0" width="505" height="603"/>
42+
<rect key="frame" x="0.0" y="0.0" width="505" height="623"/>
4543
<subviews>
4644
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ZZS-tP-r8T">
47-
<rect key="frame" x="0.0" y="0.0" width="180" height="603"/>
48-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
45+
<rect key="frame" x="0.0" y="0.0" width="180" height="623"/>
46+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
4947
<constraints>
5048
<constraint firstAttribute="width" constant="180" id="qGh-0a-lfY"/>
5149
</constraints>
@@ -54,14 +52,13 @@
5452
<rect key="frame" x="0.0" y="28" width="180" height="44"/>
5553
<autoresizingMask key="autoresizingMask"/>
5654
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Rge-bu-ejB" id="EDm-3n-Hd0">
57-
<rect key="frame" x="0.0" y="0.0" width="180" height="43.5"/>
55+
<rect key="frame" x="0.0" y="0.0" width="180" height="44"/>
5856
<autoresizingMask key="autoresizingMask"/>
5957
<subviews>
6058
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="XT4-OY-1f4">
61-
<rect key="frame" x="15" y="0.0" width="150" height="43.5"/>
59+
<rect key="frame" x="15" y="0.0" width="150" height="44"/>
6260
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
6361
<fontDescription key="fontDescription" type="system" pointSize="16"/>
64-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6562
<nil key="highlightedColor"/>
6663
</label>
6764
</subviews>
@@ -74,16 +71,16 @@
7471
</connections>
7572
</tableView>
7673
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FPp-Vf-YK5" userLabel="Response Area">
77-
<rect key="frame" x="180" y="0.0" width="325" height="603"/>
74+
<rect key="frame" x="180" y="0.0" width="325" height="623"/>
7875
<subviews>
7976
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="Resopnse" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="VNd-yL-ZI4">
80-
<rect key="frame" x="8" y="8" width="309" height="587"/>
81-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
77+
<rect key="frame" x="8" y="8" width="309" height="607"/>
78+
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
8279
<fontDescription key="fontDescription" type="system" pointSize="14"/>
8380
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
8481
</textView>
8582
</subviews>
86-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
83+
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
8784
<constraints>
8885
<constraint firstAttribute="bottom" secondItem="VNd-yL-ZI4" secondAttribute="bottom" constant="8" id="EyY-o4-eJE"/>
8986
<constraint firstAttribute="trailing" secondItem="VNd-yL-ZI4" secondAttribute="trailing" constant="8" id="Z1J-PO-HiV"/>
@@ -114,7 +111,7 @@
114111
</constraints>
115112
</scrollView>
116113
</subviews>
117-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
114+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
118115
<constraints>
119116
<constraint firstAttribute="trailing" secondItem="08X-eY-SGq" secondAttribute="trailing" id="1DX-DW-DC4"/>
120117
<constraint firstItem="UvO-60-D33" firstAttribute="top" secondItem="08X-eY-SGq" secondAttribute="bottom" id="7mg-Ra-oLU"/>
@@ -125,13 +122,13 @@
125122
<navigationItem key="navigationItem" title="RFAPI" id="J6L-JP-3hQ"/>
126123
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
127124
<connections>
128-
<outlet property="operationList" destination="ZZS-tP-r8T" id="UHs-cU-c7Z"/>
129-
<outlet property="responseTextView" destination="VNd-yL-ZI4" id="0oI-32-HSU"/>
125+
<outlet property="operationList" destination="ZZS-tP-r8T" id="kEa-sL-LLx"/>
126+
<outlet property="responseTextView" destination="VNd-yL-ZI4" id="eJD-XO-TP8"/>
130127
</connections>
131128
</viewController>
132129
<placeholder placeholderIdentifier="IBFirstResponder" id="4uS-AR-AqJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
133130
</objects>
134-
<point key="canvasLocation" x="546" y="483"/>
131+
<point key="canvasLocation" x="844" y="322"/>
135132
</scene>
136133
</scenes>
137134
</document>

0 commit comments

Comments
 (0)