Skip to content

Instantly share code, notes, and snippets.

@quocnb
Last active April 2, 2018 08:04
Show Gist options
  • Save quocnb/6d28a6cf7117efd37ffa5cd2b8683d1a to your computer and use it in GitHub Desktop.
Save quocnb/6d28a6cf7117efd37ffa5cd2b8683d1a to your computer and use it in GitHub Desktop.

Code quality control

Swiftlint is best choice

Bug control

Install Crashlytics

Upload dsym file (using fastlane for auto do it)

Auto build

Fastlane is best choice.

Fastlane file example

default_platform(:ios)

platform :ios do
    desc "Build app and upload to Deploygate (ad-hoc version)"
    lane :todeploygate do
        increment_build_number
        ver_no = get_version_number
        build_no = get_build_number
        build_app(
            export_method: "ad-hoc",
        )
        deploygate(
            api_token: ENV["DEPLOYGATE_API_KEY"],
            user: ENV["DEPLOYGATE_GROUP_NAME"],
            message: "Version #{ver_no} Build #{build_no}",
        )
        upload_symbols_to_crashlytics(dsym_path: "./ClothesMaker.app.dSYM.zip")
        chatwork(
            message: "App successfully push to deploygate. Version #{ver_no} Build #{build_no}",
            roomid: ENV["CHATWORK_ROOM_ID"],
            success: true,
            api_token: ENV["CHATWORK_API_KEY"]
        )
    end
end

with .ENV file example

DEPLOYGATE_API_KEY = "deploygate_api"
DEPLOYGATE_GROUP_NAME = "deploygate_group"
CHATWORK_API_KEY = "chatwork_api"
CHATWORK_ROOM_ID = chatwork_room_id

Create XCConfigure for multi-state support

https://hackernoon.com/a-cleaner-way-to-organize-your-ios-debug-development-and-release-distributions-6b5eb6a48356

TLDR;

1. Create .xcconfig file.

File > New File > iOS > Configuration Setting File. Named it ""

2. Add configuration

Project (click to Project icon in Project Navigator) > Info > Configurations > Change Base on Configuration File to your created .xcconfig file name

3. Reconfigure Cocoapods (if you don't using cocoapod, ignore this step)

Delete .xcworkspace file, the Podfile.lock, and the Pods/ directory. Do not delete the Podfile. Re Terminal pod install (besure you are in the workspace's directory) You will get the warning like this

CocoaPods did not set the base configuration of your project because your project already has a custom config set. 
In order for CocoaPods integration to work at all, please either set the base configurations of the target `FavoriteCharacter` to `Pods/Target Support Files/Pods-FavoriteCharacter/Pods-FavoriteCharacter.development.xcconfig` or 
include the `Pods/Target Support Files/Pods-FavoriteCharacter/Pods-FavoriteCharacter.development.xcconfig` in your build configuration (`FavoriteCharacter/Configure/Development.xcconfig`).

Copy the Pods/Target Support Files/Pods-FavoriteCharacter/Pods-FavoriteCharacter.development.xcconfig open your .xcconfig file, put

#include Pods/Target Support Files/Pods-FavoriteCharacter/Pods-FavoriteCharacter.development.xcconfig

4. Edit scheme

Edit Build Configuration in <Scheme_Name> > Edit Scheme > Info > Build Configuration

5. Using configure file for custom keys, settings ...

Declair the key in .xcconfig file like this

API_KEY = <your key>
API_URL = <your url>

Go to Info.plist file, add line

Api_key = ${API_KEY}

Using in code

Bundle.main.infoDictionary?["Api_key"] as? String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment