"Using multiple target to build a large number of similar apps", Tang Qiao Great God Theory verification (with project code address)

Source: Internet
Author: User

Inadvertently see the clever God article, feel very excited, this article just solves the company's current project pain point.

Read the following key paragraph, not very clear, so I did the experiment to share to the people.

"Each of our course's resource files have the same file name, such as the home page background is called Homebackgroundbg.png, because each course background is different, so we in the project, each curriculum target, through the modification Copy Bundle Resources , So that they are configured with different (but identically named) Homebackgroundbg.png. The benefit is that, at the logic level of the code, we don't have to deal with the differences in resource files between courses at all. The variance of the resource file is ensured by the configuration file. ”

My Project code address: Https://github.com/Dast1990/MultiTargetTest

Command-line Download method: Git clone [email protected]:D Ast1990/multitargettest.git

Clone target method and related knowledge see "http://www.jianshu.com/p/83b6e781eb51"

Note: The different target can only refer to the file under the corresponding directory, if the build phases more references, select the point-number to delete the extra reference, otherwise the compilation will not pass.

Select Multitargettest scheme and run, Output 1, display the corresponding picture in directory 1;

Select Multitargettianjin scheme and run, Output 2, display the corresponding picture in Directory 2;

As a result, it also validates the paragraph in the ingenious God article.

The project uses xcode8.2.1,swift3.0, the main code is as follows:

  viewcontroller.swift//  multitargettest////  Created by Ma on 2017/3/8.//  Copyright 2017 Huatu. All rights Reserved.//import Uikitclass Viewcontroller:uiviewcontroller {  override func Viewdidload () {    Super.viewdidload ()        print (CONST.LNUM1)        View.addsubview (GIMGV)    gimgv.center = View.center    Gimgv.bounds = Cgrect.init (x:0, y:0, width:100, height:100)      }   private lazy var Gimgv:uiimageview = {    Let LIMGV = Uiimageview ()        limgv.image = Uiimage.init (named: "Clannad")    return LIMGV  } ()}

Directory 1 under:

  const.swift//  multitargettest////  Created by Ma on 2017/3/8.//  Copyright 2017 Huatu. All rights Reserved.//import Uikitclass Const:nsobject {static Let Lnum1:int = 1}

Directory 2 under:

  const.swift//  multitargettest////  Created by Ma on 2017/3/8.//  Copyright 2017 Huatu. All rights Reserved.//import Uikitclass Const:nsobject {static Let Lnum1:int = 2}

"Using multiple target to build a large number of similar apps", Tang Qiao Great God Theory verification (with project code address)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.