emm 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emm/Template/AppDelegate.h +17 -0
- data/lib/emm/Template/AppDelegate.m +45 -0
- data/lib/emm/Template/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- data/lib/emm/Template/Base.lproj/LaunchScreen.storyboard +27 -0
- data/lib/emm/Template/Base.lproj/Main.storyboard +25 -0
- data/lib/emm/Template/Info.plist +47 -0
- data/lib/emm/Template/ViewController.h +15 -0
- data/lib/emm/Template/ViewController.m +27 -0
- data/lib/emm/Template/main.m +16 -0
- data/lib/emm/files.rb +67 -0
- data/lib/emm/pods_build.sh +33 -0
- data/lib/emm/proj.rb +96 -0
- data/lib/emm/version.rb +3 -0
- metadata +14 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15e2a9f67b2b14ffd2e3561cb5c0c77c5cabbf8c
|
4
|
+
data.tar.gz: e46c565222b4f829452c6fb4a4c80ac23ba5b665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5a196cffb3b9810576546e1922f1f2d602f78b8f7940c0136fc7b7a2d4229bca8f17b05e8897202a6e0776b1c0f59cc6b6e3a7d8c2c6a6b08d933e92e4c13b
|
7
|
+
data.tar.gz: 577dc5457a245de0b4bad23e2e92072b1d1e47fc3d6063f7bb39526167536a7f3ee13b9b9d99dffbf3967cd82696270003cc65671a2b2c81e1a184ada9c4cfb4
|
@@ -0,0 +1,17 @@
|
|
1
|
+
//
|
2
|
+
// AppDelegate.h
|
3
|
+
// Test
|
4
|
+
//
|
5
|
+
// Created by Chenly on 16/6/4.
|
6
|
+
// Copyright © 2016年 Little Meaning. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <UIKit/UIKit.h>
|
10
|
+
|
11
|
+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
12
|
+
|
13
|
+
@property (strong, nonatomic) UIWindow *window;
|
14
|
+
|
15
|
+
|
16
|
+
@end
|
17
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
//
|
2
|
+
// AppDelegate.m
|
3
|
+
// Test
|
4
|
+
//
|
5
|
+
// Created by Chenly on 16/6/4.
|
6
|
+
// Copyright © 2016年 Little Meaning. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "AppDelegate.h"
|
10
|
+
|
11
|
+
@interface AppDelegate ()
|
12
|
+
|
13
|
+
@end
|
14
|
+
|
15
|
+
@implementation AppDelegate
|
16
|
+
|
17
|
+
|
18
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
19
|
+
// Override point for customization after application launch.
|
20
|
+
return YES;
|
21
|
+
}
|
22
|
+
|
23
|
+
- (void)applicationWillResignActive:(UIApplication *)application {
|
24
|
+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
25
|
+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
26
|
+
}
|
27
|
+
|
28
|
+
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
29
|
+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
30
|
+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
31
|
+
}
|
32
|
+
|
33
|
+
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
34
|
+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
35
|
+
}
|
36
|
+
|
37
|
+
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
38
|
+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
39
|
+
}
|
40
|
+
|
41
|
+
- (void)applicationWillTerminate:(UIApplication *)application {
|
42
|
+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
43
|
+
}
|
44
|
+
|
45
|
+
@end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
{
|
2
|
+
"images" : [
|
3
|
+
{
|
4
|
+
"idiom" : "iphone",
|
5
|
+
"size" : "29x29",
|
6
|
+
"scale" : "2x"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"idiom" : "iphone",
|
10
|
+
"size" : "29x29",
|
11
|
+
"scale" : "3x"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"idiom" : "iphone",
|
15
|
+
"size" : "40x40",
|
16
|
+
"scale" : "2x"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"idiom" : "iphone",
|
20
|
+
"size" : "40x40",
|
21
|
+
"scale" : "3x"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"idiom" : "iphone",
|
25
|
+
"size" : "60x60",
|
26
|
+
"scale" : "2x"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"idiom" : "iphone",
|
30
|
+
"size" : "60x60",
|
31
|
+
"scale" : "3x"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"idiom" : "ipad",
|
35
|
+
"size" : "29x29",
|
36
|
+
"scale" : "1x"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"idiom" : "ipad",
|
40
|
+
"size" : "29x29",
|
41
|
+
"scale" : "2x"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"idiom" : "ipad",
|
45
|
+
"size" : "40x40",
|
46
|
+
"scale" : "1x"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"idiom" : "ipad",
|
50
|
+
"size" : "40x40",
|
51
|
+
"scale" : "2x"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"idiom" : "ipad",
|
55
|
+
"size" : "76x76",
|
56
|
+
"scale" : "1x"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"idiom" : "ipad",
|
60
|
+
"size" : "76x76",
|
61
|
+
"scale" : "2x"
|
62
|
+
}
|
63
|
+
],
|
64
|
+
"info" : {
|
65
|
+
"version" : 1,
|
66
|
+
"author" : "xcode"
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
3
|
+
<dependencies>
|
4
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
|
5
|
+
</dependencies>
|
6
|
+
<scenes>
|
7
|
+
<!--View Controller-->
|
8
|
+
<scene sceneID="EHf-IW-A2E">
|
9
|
+
<objects>
|
10
|
+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
11
|
+
<layoutGuides>
|
12
|
+
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
|
13
|
+
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
14
|
+
</layoutGuides>
|
15
|
+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
16
|
+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
17
|
+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
18
|
+
<animations/>
|
19
|
+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
20
|
+
</view>
|
21
|
+
</viewController>
|
22
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
23
|
+
</objects>
|
24
|
+
<point key="canvasLocation" x="53" y="375"/>
|
25
|
+
</scene>
|
26
|
+
</scenes>
|
27
|
+
</document>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
3
|
+
<dependencies>
|
4
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
|
5
|
+
</dependencies>
|
6
|
+
<scenes>
|
7
|
+
<!--View Controller-->
|
8
|
+
<scene sceneID="tne-QT-ifu">
|
9
|
+
<objects>
|
10
|
+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
|
11
|
+
<layoutGuides>
|
12
|
+
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
13
|
+
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
14
|
+
</layoutGuides>
|
15
|
+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
16
|
+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
17
|
+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
18
|
+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
19
|
+
</view>
|
20
|
+
</viewController>
|
21
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
22
|
+
</objects>
|
23
|
+
</scene>
|
24
|
+
</scenes>
|
25
|
+
</document>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>en</string>
|
7
|
+
<key>CFBundleExecutable</key>
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
9
|
+
<key>CFBundleIdentifier</key>
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
12
|
+
<string>6.0</string>
|
13
|
+
<key>CFBundleName</key>
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
15
|
+
<key>CFBundlePackageType</key>
|
16
|
+
<string>APPL</string>
|
17
|
+
<key>CFBundleShortVersionString</key>
|
18
|
+
<string>1.0</string>
|
19
|
+
<key>CFBundleSignature</key>
|
20
|
+
<string>????</string>
|
21
|
+
<key>CFBundleVersion</key>
|
22
|
+
<string>1</string>
|
23
|
+
<key>LSRequiresIPhoneOS</key>
|
24
|
+
<true/>
|
25
|
+
<key>UILaunchStoryboardName</key>
|
26
|
+
<string>LaunchScreen</string>
|
27
|
+
<key>UIMainStoryboardFile</key>
|
28
|
+
<string>Main</string>
|
29
|
+
<key>UIRequiredDeviceCapabilities</key>
|
30
|
+
<array>
|
31
|
+
<string>armv7</string>
|
32
|
+
</array>
|
33
|
+
<key>UISupportedInterfaceOrientations</key>
|
34
|
+
<array>
|
35
|
+
<string>UIInterfaceOrientationPortrait</string>
|
36
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
37
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
38
|
+
</array>
|
39
|
+
<key>UISupportedInterfaceOrientations~ipad</key>
|
40
|
+
<array>
|
41
|
+
<string>UIInterfaceOrientationPortrait</string>
|
42
|
+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
43
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
44
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
45
|
+
</array>
|
46
|
+
</dict>
|
47
|
+
</plist>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
//
|
2
|
+
// ViewController.m
|
3
|
+
// Test
|
4
|
+
//
|
5
|
+
// Created by Chenly on 16/6/4.
|
6
|
+
// Copyright © 2016年 Little Meaning. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "ViewController.h"
|
10
|
+
|
11
|
+
@interface ViewController ()
|
12
|
+
|
13
|
+
@end
|
14
|
+
|
15
|
+
@implementation ViewController
|
16
|
+
|
17
|
+
- (void)viewDidLoad {
|
18
|
+
[super viewDidLoad];
|
19
|
+
// Do any additional setup after loading the view, typically from a nib.
|
20
|
+
}
|
21
|
+
|
22
|
+
- (void)didReceiveMemoryWarning {
|
23
|
+
[super didReceiveMemoryWarning];
|
24
|
+
// Dispose of any resources that can be recreated.
|
25
|
+
}
|
26
|
+
|
27
|
+
@end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//
|
2
|
+
// main.m
|
3
|
+
// Test
|
4
|
+
//
|
5
|
+
// Created by Chenly on 16/6/4.
|
6
|
+
// Copyright © 2016年 Little Meaning. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <UIKit/UIKit.h>
|
10
|
+
#import "AppDelegate.h"
|
11
|
+
|
12
|
+
int main(int argc, char * argv[]) {
|
13
|
+
@autoreleasepool {
|
14
|
+
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
15
|
+
}
|
16
|
+
}
|
data/lib/emm/files.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module EMMFiles
|
5
|
+
|
6
|
+
def self.create_podfile(configs, output_dir, proj_name)
|
7
|
+
# create_podfile : 通过 json 配置文件,创建一个 podfile
|
8
|
+
# configs : 项目配置
|
9
|
+
# output_dir : Podfile 文件导出目录
|
10
|
+
podfile = File.new(output_dir + "/Podfile", "w+")
|
11
|
+
podfile.syswrite("source 'https://github.com/CocoaPods/Specs.git'\n")
|
12
|
+
podfile.syswrite("source '" + configs["private_repo"] + "'\n")
|
13
|
+
podfile.syswrite("platform :ios, ‘" + configs["deployment_target"] + "’\n")
|
14
|
+
podfile.syswrite("target '" + proj_name + "' do\n")
|
15
|
+
for pod in configs["pods"]
|
16
|
+
podfile.syswrite(pod + "\n")
|
17
|
+
end
|
18
|
+
podfile.syswrite("end")
|
19
|
+
podfile.close
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.copy_xcconfig(source_path, export_path)
|
23
|
+
# 从 pod 的 xcconfig 中提取出所需内容,生成项目所需的 xcconfig
|
24
|
+
# sourcePath : Cocoapods 生成的 xcconfig 文件
|
25
|
+
# outputPath : 导出的 xcconfig 文件
|
26
|
+
output_file = File.new(export_path, "w+")
|
27
|
+
IO.foreach(source_path) do |line|
|
28
|
+
if line.start_with?("OTHER_LDFLAGS")
|
29
|
+
output_file.syswrite(line)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
output_file.syswrite("HEADER_SEARCH_PATHS = $(inherited) ${SRCROOT}/EMM_Pods/Headers/**\n")
|
33
|
+
output_file.syswrite("LIBRARY_SEARCH_PATHS = $(inherited) ${SRCROOT}/EMM_Pods/Libraries")
|
34
|
+
output_file.close
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.copy_resources(pods_dir, pods_proj_name, export_dir)
|
38
|
+
# 从 pod 的 XXX_Proj-resources.sh 脚本文件中提取出资源文件的路径,并将资源文件拷贝到导出目录下
|
39
|
+
# source_path: Pods 文件夹路径
|
40
|
+
# export_dir: 资源文件导出目录
|
41
|
+
start_string = 'if [[ "$CONFIGURATION" == "Release" ]]; then'
|
42
|
+
end_string = 'fi'
|
43
|
+
writing = false
|
44
|
+
# 读取 Cocoapods 提供的 copy resources 的脚本文件
|
45
|
+
IO.foreach(pods_dir + "/Target Support Files/Pods-" + pods_proj_name + "/Pods-" + pods_proj_name + "-resources.sh") do |line|
|
46
|
+
if line.start_with?(start_string)
|
47
|
+
writing = true
|
48
|
+
next
|
49
|
+
end
|
50
|
+
if writing
|
51
|
+
if line.start_with?(end_string)
|
52
|
+
break
|
53
|
+
end
|
54
|
+
line = line.match("\".+\"")[0]
|
55
|
+
line = line.gsub("\"", "")
|
56
|
+
src = pods_dir + "/" + line
|
57
|
+
dst = export_dir + "/" + line
|
58
|
+
FileUtils.mkdir_p(File.dirname(dst))
|
59
|
+
if File.directory?(src)
|
60
|
+
FileUtils.cp_r(src, File.dirname(dst))
|
61
|
+
else
|
62
|
+
FileUtils.cp(src, dst)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# 使用 cocoapods 拉取源码,编译生成所需的.a、.h 和 资源文件并导出到指定目录
|
2
|
+
# $1 临时项目路径
|
3
|
+
# $2 .a、.h 及 资源文件导出路径
|
4
|
+
temp_proj_path=$1
|
5
|
+
export_path=$2
|
6
|
+
temp_proj_name=${temp_proj_path##*/}
|
7
|
+
|
8
|
+
# cocoapods
|
9
|
+
cd ${temp_proj_path}
|
10
|
+
pod update --no-repo-update
|
11
|
+
|
12
|
+
# 编译生成模拟器和真机的 .a 文件(Release)
|
13
|
+
cd Pods
|
14
|
+
xcodebuild -project "Pods.xcodeproj" -alltargets -sdk iphoneos -configuration Release TARGET_BUILD_DIR="../Products/iPhoneOS" ONLY_ACTIVE_ARCH=NO
|
15
|
+
xcodebuild -project "Pods.xcodeproj" -alltargets -sdk iphonesimulator -configuration Release TARGET_BUILD_DIR="../Products/iPhoneSimulator" -arch x86_64
|
16
|
+
|
17
|
+
# 使用 lipo 指令合并模拟器和真机的 .a
|
18
|
+
lib_files=`find ../Products/iPhoneOS -type f -name "*.a" | grep -v ../Products/iPhoneOS/libPods-${podsProject}`
|
19
|
+
for file in ${lib_files}
|
20
|
+
do
|
21
|
+
lib_name=${file##*/}
|
22
|
+
lipo= lipo -create ../Products/iPhoneOS/${lib_name} ../Products/iPhoneSimulator/${lib_name} -output ../Products/${lib_name}
|
23
|
+
done
|
24
|
+
|
25
|
+
# 合成 .a 后删除无用的目录,避免影响之后的拷贝
|
26
|
+
rm -rf ../Products/iPhoneOS
|
27
|
+
rm -rf ../Products/iPhoneSimulator
|
28
|
+
cd ../Products
|
29
|
+
|
30
|
+
# 从 Pods 目录中拷贝出 .a
|
31
|
+
find . -type f -name "*.a" | grep -v ./libPods-${temp_proj_name} | cpio -pdm ${export_path}/Libraries
|
32
|
+
# 从 Pods 目录中拷贝出 Header
|
33
|
+
cp -r ../Pods/Headers/Public ${export_path}/Headers
|
data/lib/emm/proj.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require "xcodeproj"
|
2
|
+
require "find"
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module EMMProj
|
6
|
+
|
7
|
+
def self.traverse(dirname, basename, super_group)
|
8
|
+
filepath = dirname + "/" + basename
|
9
|
+
refpath = "./" + @emm_pods_name + filepath[@libs_dir.length, filepath.length - @libs_dir.length]
|
10
|
+
|
11
|
+
if File.directory?(filepath)
|
12
|
+
group = super_group.new_group(basename)
|
13
|
+
Dir.foreach(filepath) do |filename|
|
14
|
+
if filename != "." and filename != ".." and filename != ".DS_Store"
|
15
|
+
traverse(filepath, filename, group)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
ref = super_group.new_reference(refpath)
|
20
|
+
extname = File.extname(basename)
|
21
|
+
if !([".xcconfig", ".a", ".h"].include?(extname))
|
22
|
+
# 除去 [".a", ".xcconfig", ".h"] 文件外,都当做资源文件添加到 target 中
|
23
|
+
@target.add_resources([ref])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.create_temp_proj(proj_name, output_dir)
|
29
|
+
# create_temp_proj : 创建一个临时项目
|
30
|
+
# proj_name : 项目名称
|
31
|
+
# output_dir : 项目导出目录
|
32
|
+
proj_path = output_dir + "/" + proj_name + ".xcodeproj"
|
33
|
+
Xcodeproj::Project.new(proj_path).save
|
34
|
+
project = Xcodeproj::Project.open(proj_path)
|
35
|
+
target = project.new_target(:application, proj_name, :ios)
|
36
|
+
project.save
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.create_proj(proj_name, output_dir, emm_pods_name, configs)
|
40
|
+
# create_temp_proj : 创建一个正式项目
|
41
|
+
# proj_name : 项目名称
|
42
|
+
# output_dir : 项目导出目录
|
43
|
+
# emm_pods_name : EMM_Pods 文件夹的名称
|
44
|
+
# configs : 项目配置
|
45
|
+
proj_path = output_dir + "/" + proj_name + "/" + proj_name + ".xcodeproj"
|
46
|
+
# 创建工程文件,并保存
|
47
|
+
Xcodeproj::Project.new(proj_path).save
|
48
|
+
# 打开创建的文件
|
49
|
+
project = Xcodeproj::Project.open(proj_path)
|
50
|
+
# 创建@target,主要的参数 type: application :dynamic_library framework :static_library
|
51
|
+
# name:@target名称
|
52
|
+
# platform:平台 :ios或者:osx
|
53
|
+
@target = project.new_target(:application, proj_name, :ios)
|
54
|
+
|
55
|
+
# 创建一个分组,名称为proj_name,对应的路径为./proj_name
|
56
|
+
group = project.new_group(proj_name)
|
57
|
+
# 给分组添加文件引用
|
58
|
+
group.new_reference("./" + proj_name + "/AppDelegate.h")
|
59
|
+
@target.add_file_references(
|
60
|
+
[group.new_reference("./" + proj_name + "/AppDelegate.m")]
|
61
|
+
);
|
62
|
+
group.new_reference("./" + proj_name + "/ViewController.h")
|
63
|
+
@target.add_file_references(
|
64
|
+
[group.new_reference("./" + proj_name + "/ViewController.m")]
|
65
|
+
);
|
66
|
+
|
67
|
+
# 在分组下创建一个名字为Supporting Files的子分组,并给该子分组添加main和info.plist文件引用
|
68
|
+
supportGroup = group.new_group("Supporting Files")
|
69
|
+
supportGroup.new_reference("./" + proj_name + "/Info.plist")
|
70
|
+
@target.add_file_references(
|
71
|
+
[supportGroup.new_reference("./" + proj_name + "/main.m")]
|
72
|
+
);
|
73
|
+
@target.add_resources(
|
74
|
+
[supportGroup.new_reference("./" + proj_name + "/Base.lproj/LaunchScreen.storyboard"),
|
75
|
+
supportGroup.new_reference("./" + proj_name + "/Base.lproj/Main.storyboard"),
|
76
|
+
supportGroup.new_reference("./" + proj_name + "/Assets.xcassets")]
|
77
|
+
);
|
78
|
+
|
79
|
+
# 添加@target配置信息
|
80
|
+
@target.build_configuration_list.set_setting("INFOPLIST_FILE", "$(SRCROOT)/" + proj_name + "/Info.plist")
|
81
|
+
@target.build_configuration_list.set_setting("PRODUCT_BUNDLE_IDENTIFIER", configs["bundle_identifier"])
|
82
|
+
@target.build_configuration_list.set_setting("IPHONEOS_DEPLOYMENT_TARGET", configs["deployment_target"])
|
83
|
+
|
84
|
+
# 添加 EMM_Pods 文件夹到项目中
|
85
|
+
@libs_dir = output_dir + "/" + proj_name + "/" + emm_pods_name
|
86
|
+
@emm_pods_name = emm_pods_name
|
87
|
+
|
88
|
+
traverse(File.dirname(@libs_dir), File.basename(@libs_dir), project.main_group)
|
89
|
+
|
90
|
+
@target.build_configuration_list["Debug"].base_configuration_reference = project.reference_for_path(@libs_dir + "/EMM_Debug.xcconfig")
|
91
|
+
@target.build_configuration_list["Release"].base_configuration_reference = project.reference_for_path(@libs_dir + "/EMM_Release.xcconfig")
|
92
|
+
|
93
|
+
# 保存
|
94
|
+
project.save
|
95
|
+
end
|
96
|
+
end
|
data/lib/emm/version.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenqmg
|
@@ -36,6 +36,19 @@ files:
|
|
36
36
|
- README.md
|
37
37
|
- bin/emm
|
38
38
|
- lib/emm.rb
|
39
|
+
- lib/emm/Template/AppDelegate.h
|
40
|
+
- lib/emm/Template/AppDelegate.m
|
41
|
+
- lib/emm/Template/Assets.xcassets/AppIcon.appiconset/Contents.json
|
42
|
+
- lib/emm/Template/Base.lproj/LaunchScreen.storyboard
|
43
|
+
- lib/emm/Template/Base.lproj/Main.storyboard
|
44
|
+
- lib/emm/Template/Info.plist
|
45
|
+
- lib/emm/Template/ViewController.h
|
46
|
+
- lib/emm/Template/ViewController.m
|
47
|
+
- lib/emm/Template/main.m
|
48
|
+
- lib/emm/files.rb
|
49
|
+
- lib/emm/pods_build.sh
|
50
|
+
- lib/emm/proj.rb
|
51
|
+
- lib/emm/version.rb
|
39
52
|
homepage: http://rubygems.org/gems/emm
|
40
53
|
licenses:
|
41
54
|
- MIT
|