Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
BB9z committed Feb 14, 2020
2 parents 83b6f59 + e6821af commit 7bd5c11
Show file tree
Hide file tree
Showing 69 changed files with 12,972 additions and 1,976 deletions.
90 changes: 70 additions & 20 deletions .travis.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
#! /usr/bin/env sh
#! /bin/zsh

set -eo pipefail
# set -euxo pipefail
set -euo pipefail

echo $TRAVIS_COMMIT_MESSAGE
echo "RFCI_TASK = $RFCI_TASK"
readonly RFWorkspace="RFAPI.xcworkspace"
readonly RFSTAGE="$1"
echo "RFSTAGE = $RFSTAGE"
logInfo () {
echo "\033[32m$1\033[0m" >&2
}

logWarning () {
echo "\033[33m$1\033[0m" >&2
}

logError () {
echo "\033[31m$1\033[0m" >&2
}

# Make sure all parameters are set correctly.
logInfo "RFCI_PRODUCT_NAME = $RFCI_PRODUCT_NAME"

readonly RFCI_TASK="${RFCI_TASK:? is not set.}"
logInfo "RFCI_TASK = $RFCI_TASK"

readonly RFCI_STAGE="${1:?STAGE is not set.}"
logInfo "RFCI_STAGE = $RFCI_STAGE"

readonly RFWorkspace=${RFWorkspace:="$RFCI_PRODUCT_NAME.xcworkspace"}
logInfo "RFWorkspace = $RFWorkspace"

TRAVIS_COMMIT_MESSAGE=${TRAVIS_COMMIT_MESSAGE:="$(logWarning 'TRAVIS_COMMIT_MESSAGE is not set, leave it blank.')"}
TRAVIS_BRANCH=${TRAVIS_BRANCH:="$(logWarning 'TRAVIS_BRANCH is not set, leave it blank.')"}

echo ""

# Run test
# $1 scheme
Expand All @@ -23,32 +45,60 @@ XC_TestMac() {

# Run watchOS test
XC_TestWatch() {
xcodebuild build -workspace "$RFWorkspace" -scheme Target-watchOS ONLY_ACTIVE_ARCH=NO | xcpretty
xcodebuild build -workspace "$RFWorkspace" -scheme "Target-watchOS" ONLY_ACTIVE_ARCH=NO | xcpretty
}

# Run tests on iOS Simulator.
# The destinations are the first and last available destination that are automatically detected.
# $1 scheme
XC_TestAutoIOS() {
logInfo "Detecting destinations..."
destList=$(xcodebuild -showdestinations -workspace "$RFWorkspace" -scheme "$1" | grep "iOS Simulator")
destCount=$(echo "$destList" | wc -l)
destFirst=$(echo "$destList" | head -1)
destLast=$(echo "$destList" | tail -2 | head -1)
destFirstID=$(echo "$destFirst" | awk 'match($0,/id\:[0-9A-F-]+/){ print substr($0,RSTART+3,RLENGTH-3) }')
destLastID=$(echo "$destLast" | awk 'match($0,/id\:[0-9A-F-]+/){ print substr($0,RSTART+3,RLENGTH-3) }')

logWarning "Test on simulator (id: $destFirstID)."
XC_Test "$1" "platform=iOS Simulator,id=$destFirstID"

logWarning "Test on simulator (id: $destLastID)."
XC_Test "$1" "platform=iOS Simulator,id=$destLastID"
}

STAGE_SETUP() {
gem install cocoapods --no-document
}

STAGE_MAIN() {
if [ "$RFCI_TASK" = "POD_LINT" ]; then
if [[ "$TRAVIS_COMMIT_MESSAGE" = *"[skip lint]"* ]]; then
echo "Skip pod lint"
logWarning "Skip pod lint"
else
echo "TRAVIS_BRANCH = $TRAVIS_BRANCH"
gem install cocoapods --no-rdoc --no-ri --no-document --quiet
# Always allow warnings as third-party dependencies generate unavoidable warnings.
pod lib lint --allow-warnings
if [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+ ]]; then
logWarning "Release the podspec."
pod trunk push "$RFCI_PRODUCT_NAME.podspec"
elif [ "$TRAVIS_BRANCH" = "master" ]; then
logInfo "Lint the podspec."
pod lib lint --fail-fast
else
logInfo "Lint the podspec."
pod lib lint --fail-fast --allow-warnings
fi
fi

elif [ "$RFCI_TASK" = "Xcode9" ]; then
elif [ "$RFCI_TASK" = "Xcode10" ]; then
pod install
XC_TestMac
XC_Test "Example-iOS" "platform=iOS Simulator,name=iPhone 6,OS=11.2"
# XC_Test "Example-iOS" "platform=iOS Simulator,name=X1,OS=11.3"
XC_TestAutoIOS "Test-iOS"
else
echo "Unexpected CI task: $RFCI_TASK"
logError "Unexpected CI task: $RFCI_TASK"
fi
}

STAGE_SUCCESS() {
if [ "$RFCI_TASK" = "Xcode9" ]; then
if [ "${RFCI_COVERAGE-}" = "1" ]; then
curl -s https://codecov.io/bash | bash -s
fi
}
Expand All @@ -59,4 +109,4 @@ STAGE_FAILURE() {
fi
}

"STAGE_$RFSTAGE"
"STAGE_$RFCI_STAGE"
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ env:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
- LANGUAGE=en_US.UTF-8
- RFCI_PRODUCT_NAME="RFAPI"
- RFWorkspace="RFAPI.xcworkspace"
matrix:
include:
- osx_image: xcode9.3
- osx_image: xcode11.3
env: RFCI_TASK="POD_LINT"
- osx_image: xcode9.3
env: RFCI_TASK="Xcode9"
before_install:
- pod repo update master --silent
script: ./.travis.sh MAIN
after_success: ./.travis.sh SUCCESS
after_failure: ./.travis.sh FAILURE
- osx_image: xcode10
env:
- RFCI_TASK="Xcode10"
- RFCI_COVERAGE=1
before_install: ./.travis.sh SETUP
script: ./.travis.sh MAIN
after_success: ./.travis.sh SUCCESS
after_failure: ./.travis.sh FAILURE
4 changes: 4 additions & 0 deletions Documents/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RFAPI 背后的设计

好的设计应该是不会过时的

48 changes: 48 additions & 0 deletions Documents/migration_guide_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# RFAPI v2 升级指南

> *Because there should be no non-Chinese developers using this library before, this guide is not available in English at this time.*
v1 到 v2 几乎全部重写,内部变化很大,但是实际项目需要调整的地方应该不多。

如果只是用到请求发送、取消这样的基本功能,甚至无需修改。

## 主要类型变化

`RFAPI` 的父类由 `NSOperationQueue` 变为 `NSObject`。如果之前用到了 NSOperationQueue 的方法,只能都移除了。`maxConcurrentOperationCount` 可以改用 NSURLSessionConfiguration 的 `HTTPMaximumConnectionsPerHost` 属性设置。

请求方法返回的请求对象类型从 `AFHTTPRequestOperation` 变为 `RFAPITask`,暴露的属性有减少。

`RFAPIControl` 被移除,取而代之的类是 `RFAPIRequestConext`,必须修改的地方并不多:

* `message` 属性更名为 `activityMessage`
* 移除的属性都没用到,`RFAPIRequestConext` 新增的属性也无需修改;
* 不再支持从字典创建,这个正常用得极少。

缓存管理移除了,但这个系统只在 iOS 7 之前工作,正常的项目应该影响不到。

## Define 和 DefineManager

`RFAPIDefine``responseClass` 类型由 class 改为 string,其他在外部看来没有变化。

`RFAPIDefineManager` 现在直接使用 define 对象,不再使用字典作为存储。`defaultRule` 更名为 `defaultDefine`,修改立即生效,无需再手动调用 `setNeedsUpdateDefaultRule` 方法。之前对 define 字段进行修改的方法被移除,直接对 define 对象进行修改即可。`setDefinesWithRulesInfo:` 现在支持分组。

在 DEBUG 环境(准确的说是 RFDEBUG 为真且 NSAssert 启用)下编译的 RFAPI,在 define 处理时会进行一些额外检查,帮助你正确使用,Release 环境这些检查不会执行。

## 请求创建

v1 请求有两个方法,正常请求和表单上传请求,正常请求有兼容实现,可无需修改(但是推荐改成新的方法)。

表单上传只能用新的请求方法,不再需要 `RFHTTPRequestFormData`,直接设置 request context 的 formData 即可。

## responseProcessingQueue

变为 `processingQueue`,默认的队列由主线程队列变为私有的并行队列。

## Swift

如果之前在 Swift 中子类了 `RFAPI`,可能需要调整方法名,需要重写的方法有了更合适的命名。

## 国际化

// todo
<!-- v1 的很多错误信息是硬编码在代码中的 -->
10 changes: 10 additions & 0 deletions Example/Shared/Example-iOS.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#import "JSONModel.h"

@interface RFDTestEntity : JSONModel
@property (assign, nonatomic) int uid;
@property (strong, nonatomic) NSString *name;
@end

@protocol RFDTestEntity <NSObject>
@property int uid;
@property NSString *name;
@end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#import "RFDTestEntity.h"
#import "RFRuntime.h"
#import <RFKit/RFRuntime.h>

@implementation RFDTestEntity

Expand Down
4 changes: 4 additions & 0 deletions Example/Shared/OCBridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import <AFNetworking/AFURLRequestSerialization.h>
#import <AFNetworking/AFURLResponseSerialization.h>
#import <RFAPI/RFAPI.h>
#import <RFAPI/RFAPIDefineConfigFile.h>
#import <RFAPI/RFAPIJSONModelTransformer.h>
#import <RFMessageManager/RFSVProgressMessageManager.h>
3 changes: 2 additions & 1 deletion Example/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}
}
43 changes: 20 additions & 23 deletions Example/iOS-Swift/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<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">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -14,7 +12,7 @@
<objects>
<navigationController id="von-Nu-zIU" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="51V-PD-3Mz">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -23,12 +21,12 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Y9Z-3Q-GfH" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="28" y="483"/>
<point key="canvasLocation" x="31" y="323"/>
</scene>
<!--RFAPI-->
<scene sceneID="FlU-N5-eoc">
<objects>
<viewController automaticallyAdjustsScrollViewInsets="NO" id="G31-9q-QIj" customClass="RFDAPITestViewController" sceneMemberID="viewController">
<viewController automaticallyAdjustsScrollViewInsets="NO" id="G31-9q-QIj" customClass="TestViewController" customModule="Example_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="VYZ-kw-ClE"/>
<viewControllerLayoutGuide type="bottom" id="UvO-60-D33"/>
Expand All @@ -38,14 +36,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="08X-eY-SGq">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3Op-hc-Txc" userLabel="Content">
<rect key="frame" x="0.0" y="0.0" width="505" height="603"/>
<rect key="frame" x="0.0" y="0.0" width="505" height="623"/>
<subviews>
<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">
<rect key="frame" x="0.0" y="0.0" width="180" height="603"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<rect key="frame" x="0.0" y="0.0" width="180" height="623"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="width" constant="180" id="qGh-0a-lfY"/>
</constraints>
Expand All @@ -54,14 +52,13 @@
<rect key="frame" x="0.0" y="28" width="180" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Rge-bu-ejB" id="EDm-3n-Hd0">
<rect key="frame" x="0.0" y="0.0" width="180" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="180" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="XT4-OY-1f4">
<rect key="frame" x="15" y="0.0" width="150" height="43.5"/>
<rect key="frame" x="15" y="0.0" width="150" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand All @@ -74,16 +71,16 @@
</connections>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FPp-Vf-YK5" userLabel="Response Area">
<rect key="frame" x="180" y="0.0" width="325" height="603"/>
<rect key="frame" x="180" y="0.0" width="325" height="623"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="Resopnse" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="VNd-yL-ZI4">
<rect key="frame" x="8" y="8" width="309" height="587"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<rect key="frame" x="8" y="8" width="309" height="607"/>
<color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="VNd-yL-ZI4" secondAttribute="bottom" constant="8" id="EyY-o4-eJE"/>
<constraint firstAttribute="trailing" secondItem="VNd-yL-ZI4" secondAttribute="trailing" constant="8" id="Z1J-PO-HiV"/>
Expand Down Expand Up @@ -114,7 +111,7 @@
</constraints>
</scrollView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="08X-eY-SGq" secondAttribute="trailing" id="1DX-DW-DC4"/>
<constraint firstItem="UvO-60-D33" firstAttribute="top" secondItem="08X-eY-SGq" secondAttribute="bottom" id="7mg-Ra-oLU"/>
Expand All @@ -125,13 +122,13 @@
<navigationItem key="navigationItem" title="RFAPI" id="J6L-JP-3hQ"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections>
<outlet property="operationList" destination="ZZS-tP-r8T" id="UHs-cU-c7Z"/>
<outlet property="responseTextView" destination="VNd-yL-ZI4" id="0oI-32-HSU"/>
<outlet property="operationList" destination="ZZS-tP-r8T" id="kEa-sL-LLx"/>
<outlet property="responseTextView" destination="VNd-yL-ZI4" id="eJD-XO-TP8"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4uS-AR-AqJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="546" y="483"/>
<point key="canvasLocation" x="844" y="322"/>
</scene>
</scenes>
</document>
Loading

0 comments on commit 7bd5c11

Please sign in to comment.