下面将2个常用的节点拿出来讲一下
XCBuildConfiguration
/* Begin XCBuildConfiguration section */
7A73A5D01FFF24A200ED0259 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
7A73A5D31FFF24A200ED0259 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = xxxxx;
FRAMEWORK_SEARCH_PATHS = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
"MAINLAND=1",
);
HEADER_SEARCH_PATHS = "/Users/macmini2/Documents/UEWork/Channel/Common/**";
INFOPLIST_FILE = xxx/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "/Users/macmini2/Documents/UEWork/Channel/Common/**";
PRODUCT_BUNDLE_IDENTIFIER = com.xxxx.xxxx;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
7A73A5D61FFF24A200ED0259 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = xxxxxxx;
INFOPLIST_FILE = xxxx/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xxxx.xxx;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SMTest.app/SMTest";
};
name = Debug;
};
/* End XCBuildConfiguration section */
上面这部分代码就是XCBuildConfiguration的配置内容,找到对应的key就可以设置相应的值,脚本最后需要保存。
PBXProject
/* Begin PBXProject section */
7A73A59E1FFF24A200ED0259 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = UE;
TargetAttributes = {
7A73A5A51FFF24A200ED0259 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
7A73A5BD1FFF24A200ED0259 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
TestTargetID = 7A73A5A51FFF24A200ED0259;
};
7A73A5C81FFF24A200ED0259 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
TestTargetID = 7A73A5A51FFF24A200ED0259;
};
};
};
mainGroup = 7A73A59D1FFF24A200ED0259;
productRefGroup = 7A73A5A71FFF24A200ED0259 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
7A73A5A51FFF24A200ED0259 /* SMTest */,
7A73A5BD1FFF24A200ED0259 /* SMTestTests */,
);
};
/* End PBXProject section */
从当前结构中我们可以看到,这里可以获取target和ProvisioningStyle
通过查看模块中相应的方法我们可以做以下处理
project = XcodeProject.load(projectPath)
pbxprojects = project.objects.get_objects_in_section(u'PBXProject')
def setProject( project,pbxprojects , teamid):
target = project.get_target_by_name(u'Unity-iPhone')
for pbxproject in pbxprojects:
pbxproject.set_provisioning_style(u'Manual',target)
pbxproject.set_developmentTeam_name(teamid,target)
如果模块中缺少函数,可以自行添加进去,这个模块的处理主要是为了在打包的时候选择teamID和xcode自动选择证书和手动配置证书 (Manual , Automatic)
def set_developmentTeam_name(self, developmentTeam, target):
if u'attributes' not in self:
self[u'attributes'] = PBXGenericObject()
if u'TargetAttributes' not in self.attributes:
self.attributes[u'TargetAttributes'] = PBXGenericObject()
if target.get_id() not in self.attributes.TargetAttributes:
self.attributes.TargetAttributes[target.get_id()] = PBXGenericObject()
self.attributes.TargetAttributes[target.get_id()][u'DevelopmentTeam'] = developmentTeam
添加 Files和Farmeworks
一般添加FIles可以先把需要添加的文件copy到工程目录下
project.add_folder(targetDir+"/UnitySDK", excludes=["^.*\.DS_Store$"], recursive=True)
project.add_folder(targetDir+"/SDKs", excludes=["^.*\.DS_Store$"], recursive=True)
#如果需要添加library_search_paths
project.add_library_search_paths("$(SRCROOT)/Libraries")
需要提的是文件夹中的framework等会自动添加识别,但是 .entitlements文件不在识别序列中,需要自己手动添加,需要修改的地方有
添加系统framework和添加file一样
project.add_file("System/Library/Frameworks/AssetsLibrary.framework",tree='SDKROOT',force=False)
project.add_file("usr/lib/libstdc++.tbd",tree='SDKROOT',force=False)
需要将framework该成optional的可使用以下方法:
def setWeak(project,framework):
items = project.objects.get_objects_in_section(u'PBXBuildFile')
for item in items:
setting = item._get_comment()
if setting.encode('utf8').find(framework) != -1:
item.add_attributes(u'Weak')
具体代码可以在这里查看脚本详情
代码可根据自己需要修改
网友评论