iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
banxi1988
V2EX  ›  iDev

Xcode Swift 项目 多 Target 共享代码经验

  •  
  •   banxi1988 ·
    banxi1988 · Apr 24, 2015 · 4423 views
    This topic created in 4076 days ago, the information mentioned may be changed or developed.
    1. 如果跟 IB 无关的代码,直接通过控制 Target Member来实现即可
    细微的代码差别通过,预编译来处理

    2. 涉及到 IB 相关的,因为 Controller的属性中有Custom Class 属性
    及 Custom Module 属性:
    如下:
    ```
    <tableViewController storyboardIdentifier="alertTimePicker" title="提醒时间" id="8Ci-b5-XGV" customClass="NotificationTimeViewController" customModule="demo_shared" sceneMemberID="viewController">
    ```
    大部分情况下是正常,但是如果 你遇到类似如下问题:
    > Unknown class _TtC13demo_shared30NotificationTimeViewController in Interface Builder file.

    就有问题了.
    我的一个解决办法是,将多个Target都设置成同名的module name,这样无论是在哪一个Target 下编译都不会有问题

    关于第二点,
    大部分情况正常是因为正常的时候: ViewController的配置还有另外一个属性: customModuleProvider
    ```
    <viewController storyboardIdentifier="singleWeekTable" title="单周" useStoryboardIdentifierAsRestorationIdentifier="YES" id="kZ3-Y1-WuQ" customClass="WeekTableViewController" customModule="demo_shared" customModuleProvider="target" sceneMemberID="viewController">
    ```

    customModuleProvider是什么时候没有的?
    我的情况是,是, 是 (其实具体原因我也想不起来了), 好像是从一个Storyboard将 VC移动到另一个Storyboard中.

    上面折腾这么一些,还有一个原因就是, Swift不支持Static Library
    其实弄Static Library还更麻烦.

    PS: 除了将多个Target 设置成同样的Product Module Name,
    还可以将出问题的VC中的Custom Module删除, 这个时候,customModuleProvider = "target"
    这个属性就会回来了..



    有了 Target member和 预编译 Xcode Swift 项目 多Target 共享主要代码还是相当简单的.
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   777 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 19:32 · PVG 03:32 · LAX 12:32 · JFK 15:32
    ♥ Do have faith in what you're doing.