iOS+uni模块化

官方集成文档:https://nativesupport.dcloud.net.cn/UniMPDocs/UseSdk/ios.html
注:unimp子工程化。结合下面步骤集成

1、工程化unimp
2、podfile中依赖子工程:pod 'UniMp', :path => '../unimp/'
3、unimp工程单独维护:如果uni模块需要添加新的xxx.a或xxx.framework库。单独在unimp.podspec中依赖。添加完后(unimp工程有任何变动),在主工程pod install

1)spec.frameworks = '',spec.libraries = ''
这个为原生能力需要的framework框架和链接库,根据模块原生能力需要,集成对应的框架。一般是根据官方文档对应的模块能力需要依赖的.a,.framework
uni原生插件工程对应sdk配置:
https://nativesupport.dcloud.net.cn/AppDocs/usemodule/iOSModuleConfig/common.html#
2)spec.vendored_libraries = ''
这个同上面,可以直接放到unimp工程的libs文件夹下,然后主工程内pod install即可自动依赖到工程内

4、对接uni调试
1)uni端输出wgt包,放到unimp工程 UniMp/Apps目录下,同名称的wgt包直接替换。到主工程pod install
2)卸载app,重新跑

5、tips

Q:wgt启动失败
A:https://nativesupport.dcloud.net.cn/UniMPDocs/FAQ/ios.html#q-wgt资源释放失败

附上unimp.podspec

#
#  Be sure to run `pod spec lint UniMp.podspec' to ensure this is a
#  valid spec and to remove all comments including this before submitting the spec.
#
#  To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
#  To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |spec|

  # ―――  Spec Metadata  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  These will help people to find your library, and whilst it
  #  can feel like a chore to fill in it's definitely to your advantage. The
  #  summary should be tweet-length, and the description more in depth.
  #

  spec.name         = "UniMp"
  spec.version      = "1.0.0"
  spec.summary      = "A short description of UniMp."

  # This description is used to generate tags and improve search results.
  #   * Think: What does it do? Why did you write it? What is the focus?
  #   * Try to keep it short, snappy and to the point.
  #   * Write the description between the DESC delimiters below.
  #   * Finally, don't worry about the indent, CocoaPods strips it!
  spec.description  = <<-DESC
                    UNIMP工程基础库
                   DESC

  spec.homepage     = "http://www.xxx.cn"
  # spec.screenshots  = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"


  # ―――  Spec License  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Licensing your code is important. See https://choosealicense.com for more info.
  #  CocoaPods will detect a license file if there is a named LICENSE*
  #  Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
  #

  # spec.license      = "MIT (example)"
  spec.license      = { :type => "MIT", :file => "FILE_LICENSE" }


  # ――― Author Metadata  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Specify the authors of the library, with email addresses. Email addresses
  #  of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
  #  accepts just a name if you'd rather not provide an email address.
  #
  #  Specify a social_media_url where others can refer to, for example a twitter
  #  profile URL.
  #

  spec.author             = { "赵xs" => "xxxx@qq.com" }

  # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  If this Pod runs only on iOS or OS X, then specify the platform and
  #  the deployment target. You can optionally include the target after the platform.
  #

  # spec.platform     = :ios
  spec.platform     = :ios, "9.0"

  #  When using multiple platforms
  # spec.ios.deployment_target = "5.0"
  # spec.osx.deployment_target = "10.7"
  # spec.watchos.deployment_target = "2.0"
  # spec.tvos.deployment_target = "9.0"


  # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Specify the location from where the source should be retrieved.
  #  Supports git, hg, bzr, svn and HTTP.
  #

  spec.source       = { :git => "https://gitlab.xxx.cn/~/UniMp.git", :tag => "#{spec.version}" }


  # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  CocoaPods is smart about how it includes source code. For source files
  #  giving a folder will include any swift, h, m, mm, c & cpp files.
  #  For header files it will include any header in the folder.
  #  Not including the public_header_files will make all headers public.
  #

spec.source_files  = 'src/Apps/*', 'src/Core/**/*.{h,m,mm}', 'src/Core/Libs/storage.framework/Modules/*', 'src/Extension/**/*.{h,m,mm}', 'src/Util/**/*.{h,m,mm}'

  #spec.exclude_files = "Classes/Exclude"
  spec.prefix_header_contents = '#import <Availability.h>

# ――― 你工程的xxx-prefix.pch文件里导入的头文件 ―――――――――――――――――――――――――――――――――――――――――――――――――――― #

#ifdef __OBJC__

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>

#import <MJExtension.h>
#import "AFNetWorking.h"
#import <MBProgressHUD/MBProgressHUD.h>
#import <MJExtension.h>
#import <SVProgressHUD/SVProgressHUD.h>
#import <IQKeyboardManager/IQKeyboardManager.h>
#import <FMDB/FMDB.h>
#import <MJRefresh/MJRefresh.h>
#import <KVOController/KVOController.h>
#import <MMKV/MMKV.h>
#import <QMUIKit/QMUIKit.h>

#import "UIImageView+WebCache.h"

#import "Color.h"
#import "SCDefine.h"
#import "GlobalConst.h"
#import "UrlConst.h"
#import "GlobalSets.h"
#import "BaseViewController.h"
#import "iToast.h"
#import "NetworkingManager.h"
#import "XXTAESUtil.h"
#import "ColorConst.h"
#import "StringConst.h"
#import "Logger.h"
#import "IconFontStringConst.h"
#import "StringUtil.h"
#import "NSDictionary+SafeAccess.h"
#import "NSString+Find.h"
#import "HostIdUtil.h"
#import "UIUtil.h"
#import "YBTRouter.h"
#import "YBTMethod.h"

#define MY_USEPREFIXMETHOD
#import "MyLayout.h"


#define MAS_SHORTHAND

#define MAS_SHORTHAND_GLOBALS
#import "Masonry.h"

#import "AlivcHeader.h"

#endif

#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"[文件名:%s]\n" "[函数名:%s]\n" "[行号:%d]\n打印内容:" fmt), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...);
#endif'

  # spec.public_header_files = "Classes/**/*.h"


  # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  A list of resources included with the Pod. These are copied into the
  #  target bundle with a build phase script. Anything else will be cleaned.
  #  You can preserve files from being cleaned, please don't preserve
  #  non-essential files like tests, examples and documentation.
  #

  # spec.resource  = "icon.png"
    spec.resources = 'src/**/*.{bundle,storyboard,xib,json,png,jpg,plist,js,wgt,gif}'

  # spec.preserve_paths = "FilesToSave", "MoreFilesToSave"


  # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Link your library with frameworks, or libraries. Libraries do not include
  #  the lib prefix of their name.
  #
  spec.static_framework = true
  # spec.framework  = "SomeFramework"
  # spec.subspec 'BaseFrameworks' do |s|
  #   s.frameworks = 'CoreText', 'JavaScriptCore', 'WebKit', 'CoreTelephony', 'MobileCoreServices',
  #                  'SystemConfiguration', 'MediaPlayer', 'AudioToolbox', 'QuartzCore', 'CFNetwork',
  #                  'Foundation', 'CoreFoundation', 'CoreGraphics', 'UIKit', 'AVFoundation', 'AssetsLibrary',
  #                  'AddressBook', 'CoreLocation', 'UserNotifications'
  # end
  # spec.subspec 'AudioFrameworks' do |s|
  #   s.frameworks = 'AVFoundation'
  # end
  # spec.subspec 'CameraGalleryFrameworks' do |s|
  #   s.frameworks = 'AssetsLibrary', 'Accelerate', 'Photos', 'CoreMedia', 'MetalKit', 'GLKit'
  # end
  # spec.frameworks = spec.subspecs.map { |subspec| subspec.frameworks }.flatten.uniq
  
  spec.frameworks = 'CoreFoundation', 'CFNetwork', 'AudioToolbox', 'SystemConfiguration', 'MobileCoreServices', 'WebKit', 'JavaScriptCore', 'CoreMedia', 'MediaPlayer', 'AVFoundation', 'AVKit', 'GLKit', 'OpenGLES', 'CoreText', 'QuartzCore', 'CoreGraphics', 'QuickLook', 'CoreTelephony', 'AssetsLibrary', 'Photos', 'MetalKit', 'CoreBluetooth'

  spec.vendored_frameworks = "src/**/*.{framework}"
  spec.exclude_files = ["src/Core/Libs/storage.framework/Info.plist", "src/Core/Libs/DCUniRecord.framework/Info.plist", "UniMpInfo.plist"]

  # spec.library   = "iconv"
  spec.libraries = "c++", "iconv"
  spec.vendored_libraries ='src/**/Libs/*.{a}'


  # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  If your library depends on compiler flags you can set them in the xcconfig hash
  #  where they will only apply to your library. If you depend on other Podspecs
  #  you can include multiple dependencies to ensure it works.

  # spec.requires_arc = true

  # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
  # spec.dependency "JSONKit", "~> 1.4"
  spec.dependency "BaseCommons"
  spec.dependency "SSZipArchive"
end

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容