├── .gitignore ├── LICENSE ├── README.md ├── ScreenShot ├── 1.png ├── 2.png ├── 3.png └── 4.png └── images ├── 0.png ├── 1.png ├── 2.png ├── 3.png ├── 4.png └── 5.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 SimleCp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BBS 2 | 3 | ### Swift编写的iOS端和服务器端, 服务器端基于[Perfect](https://github.com/PerfectlySoft/Perfect)框架 4 | 5 | iOS端地址: [https://github.com/zedxpp/BBS-iOS](https://github.com/zedxpp/BBS-iOS) 6 | 7 | 服务器端地址: [https://github.com/zedxpp/BBS-Server](https://github.com/zedxpp/BBS-Server) 8 | 9 | ![](https://github.com/SimleCp/BBS/blob/master/ScreenShot/1.png) 10 | 11 | ![](https://github.com/SimleCp/BBS/blob/master/ScreenShot/2.png) 12 | 13 | ![](https://github.com/SimleCp/BBS/blob/master/ScreenShot/3.png) 14 | 15 | ![](https://github.com/SimleCp/BBS/blob/master/ScreenShot/4.png) 16 | 17 | 注: 运行`BBS-iOS`, 如果你用的是我的服务器地址, 在帖子详情里面有很大的图片情况下, 加载的时候, 会卡一会, 服务器水管小. 没办法 T-T 18 | 19 | ### 已完成的接口 20 | 21 | - [x] 注册 22 | - [x] 登录 23 | - [x] 所有帖子列表 24 | - [x] 论坛列表 25 | - [x] 帖子详情 26 | - [x] 帖子评论列表 27 | - [x] 评论帖子 28 | - [x] 发布帖子 29 | - [x] 上传图片 30 | - [x] 获取当前用户信息 31 | - [ ] ... 32 | 33 | ## 以下教程编译环境 34 | 35 | #### Apple Swift version 4.0.3 36 | 37 | 查看方式, 打开终端, 输入`swift --version` 38 | 39 | #### mysql Ver 14.14 Distrib 5.7.19(mysql5.6版本也兼容) 40 | 41 | 输入`mysql --version` 42 | 43 | ## 使用方式 44 | 45 | 点个star不迷路 ^-^ 46 | 47 | #### 让iOS端跑起来 48 | 49 | 1. `clone` 和 `pod install`, 项目是基于`cocoapods`的. 50 | 51 | 2. 安装好后直接运行即可. 52 | 53 | 注: 54 | 55 | 如果用这个地址, 需要把`BBS-Server`项目 `clone`到本地, 自己运行起来, 也就是`用你的mac当服务器` 56 | 57 | ``` 58 | let httpAdress = "http://0.0.0.0:8181/" 59 | ``` 60 | 61 | ~~如果用这个地址, 直接运行`BBS-iOS`项目即可~~ `这个云服务器快到期了, 所以尽量结合 BBS-Server 项目查看iOS端的demo` 62 | ``` 63 | let httpAdress = "http://swift520.com:8181/" 64 | ``` 65 | 66 | 配置文件在`BBS-iOS/Tool.swift` 67 | 68 | #### 让服务端跑起来 69 | 70 | 1. `clone`项目, 并且`cd`到项目目录, `swift build`编译项目(如果你的终端没有翻墙, 那么这个过程会很慢) 71 | 2. 编译完成, 会出现`Linking ./.build/x86_64-apple-macosx10.10/debug/BBS-Server`这样的log输出. 直接拷贝`./.build/x86_64-apple-macosx10.10/debug/BBS-Server`, 运行即可. 72 | 73 | 过程如图: 74 | 75 | ![](https://github.com/SimleCp/BBS/blob/master/images/0.png) 76 | 77 | 3. 安装本地MySql, 请看此文章 [点我](http://zedxpp.com/2017/10/07/Swift%20Perfect%20Mac%E6%9C%AC%E5%9C%B0%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/) 78 | 只需要看安装部分即可, 安装完成后, 用命令启动数据库, 终端输出`Starting MySQL . SUCCESS!`, 本地mysql服务启动完成. 79 | 80 | 4. 安装`Navicat Premium`的`Mac App`, 请自行网上搜索安装. 81 | 82 | 5. 用`Navicat Premium`, 新建`mysql`连接, 连接成功后, 打开数据库. 按下面的图, 新建一个`bbs`的数据库, 参数请务必和我图上的一致. 然后运行`bbs.sql`文件. 见下方图片. 83 | 84 | ![](https://github.com/SimleCp/BBS/blob/master/images/1.png) 85 | 86 | ![](https://github.com/SimleCp/BBS/blob/master/images/2.png) 87 | 88 | ![](https://github.com/SimleCp/BBS/blob/master/images/3.png) 89 | 90 | ![](https://github.com/SimleCp/BBS/blob/master/images/4.png) 91 | 92 | ![](https://github.com/SimleCp/BBS/blob/master/images/5.png) 93 | 94 | 6. 导入sql成功后, 在iOS端的`BBS-iOS/Tool.swift`切换为`let httpAdress = "http://0.0.0.0:8181/"`, 并且把`BBS-Server/Sources/BBS-Server/ServerConfiguration.swift`的数据库相关配置设置一下, 在没有更改端口号之类的情况下, 你需要填写你的数据库用户名和密码既可. 95 | 96 | ``` 97 | struct ServerConfiguration { 98 |    let baseURL = "http://localhost/" // 本地地址 99 |    let name = "localhost" 100 |    let mysqlDBName = "bbs" // 数据库名 101 |    let mysqlHost = "127.0.0.1" // 数据库本地地址 102 |    let mysqlPort = 3306 // 默认端口号 103 |    let mysqlPwd = "" // 数据库密码 104 |    let mysqlUser = "" // 数据库用户名 105 |    let httpPort = 8181 // 服务器默认端口号 106 | } 107 | ``` 108 | 109 | 7. 重新运行`BBS-Server`和`BBS-iOS`项目. 现在, 服务器和数据库, 都是用的你mac上的了. 110 | 111 | 112 | ### 这两个小demo, 写了快两个月吧, 有很多细节地方没来得及完善, 同时写两端, 并且在不会用Perfect框架的情况下, 速度很慢了. 113 | 114 | ### 如果你也想在mac或者服务器上部署一个属于自己的app后端, 请看我的Perfect框架使用系列文章, 戳我戳我[http://zedxpp.com](http://zedxpp.com) 115 | 116 | 117 | -------------------------------------------------------------------------------- /ScreenShot/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/ScreenShot/1.png -------------------------------------------------------------------------------- /ScreenShot/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/ScreenShot/2.png -------------------------------------------------------------------------------- /ScreenShot/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/ScreenShot/3.png -------------------------------------------------------------------------------- /ScreenShot/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/ScreenShot/4.png -------------------------------------------------------------------------------- /images/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/images/0.png -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/images/4.png -------------------------------------------------------------------------------- /images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zedxpp/BBS/72725511019c57f7a7de2251894f8f50728c191e/images/5.png --------------------------------------------------------------------------------