2015-06-07 22:20:23 -07:00
|
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2015-07-20 15:23:17 -07:00
|
|
|
|
"bytes"
|
2015-07-08 09:46:18 -06:00
|
|
|
|
"fmt"
|
2015-07-10 16:47:46 -06:00
|
|
|
|
"go/build"
|
2015-06-07 22:20:23 -07:00
|
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
2015-06-12 11:17:46 -07:00
|
|
|
|
"path"
|
2015-06-07 22:20:23 -07:00
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
2015-07-20 15:23:17 -07:00
|
|
|
|
"text/template"
|
2015-06-07 22:20:23 -07:00
|
|
|
|
)
|
|
|
|
|
|
2015-07-24 16:47:16 -04:00
|
|
|
|
func goIOSBuild(pkg *build.Package) (map[string]bool, error) {
|
2015-07-10 16:47:46 -06:00
|
|
|
|
src := pkg.ImportPath
|
2015-07-08 09:46:18 -06:00
|
|
|
|
if buildO != "" && !strings.HasSuffix(buildO, ".app") {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, fmt.Errorf("-o must have an .app for target=ios")
|
2015-07-08 09:46:18 -06:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 19:52:31 -04:00
|
|
|
|
productName := rfc1034Label(path.Base(pkg.ImportPath))
|
|
|
|
|
if productName == "" {
|
|
|
|
|
productName = "ProductName" // like xcode.
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 15:23:17 -07:00
|
|
|
|
infoplist := new(bytes.Buffer)
|
2015-08-02 19:52:31 -04:00
|
|
|
|
if err := infoplistTmpl.Execute(infoplist, infoplistTmplData{
|
|
|
|
|
// TODO: better bundle id.
|
|
|
|
|
BundleID: "org.golang.todo." + productName,
|
|
|
|
|
Name: strings.Title(path.Base(pkg.ImportPath)),
|
2015-07-20 15:23:17 -07:00
|
|
|
|
}); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-07-20 15:23:17 -07:00
|
|
|
|
}
|
2015-07-25 21:26:28 -04:00
|
|
|
|
|
|
|
|
|
files := []struct {
|
|
|
|
|
name string
|
|
|
|
|
contents []byte
|
|
|
|
|
}{
|
|
|
|
|
{tmpdir + "/main.xcodeproj/project.pbxproj", []byte(projPbxproj)},
|
|
|
|
|
{tmpdir + "/main/Info.plist", infoplist.Bytes()},
|
|
|
|
|
{tmpdir + "/main/Images.xcassets/AppIcon.appiconset/Contents.json", []byte(contentsJSON)},
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-25 21:26:28 -04:00
|
|
|
|
for _, file := range files {
|
|
|
|
|
if err := mkdir(filepath.Dir(file.name)); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-07-19 21:29:35 -04:00
|
|
|
|
}
|
2015-06-07 22:20:23 -07:00
|
|
|
|
if buildX {
|
2015-07-25 21:26:28 -04:00
|
|
|
|
printcmd("echo \"%s\" > %s", file.contents, file.name)
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
if !buildN {
|
2015-07-25 21:26:28 -04:00
|
|
|
|
if err := ioutil.WriteFile(file.name, file.contents, 0644); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 16:47:46 -06:00
|
|
|
|
armPath := filepath.Join(tmpdir, "arm")
|
2015-07-19 11:02:03 -04:00
|
|
|
|
if err := goBuild(src, darwinArmEnv, "-tags=ios", "-o="+armPath); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
nmpkgs, err := extractPkgs(darwinArmNM, armPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 16:47:46 -06:00
|
|
|
|
arm64Path := filepath.Join(tmpdir, "arm64")
|
2015-07-19 11:02:03 -04:00
|
|
|
|
if err := goBuild(src, darwinArm64Env, "-tags=ios", "-o="+arm64Path); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Apple requires builds to target both darwin/arm and darwin/arm64.
|
|
|
|
|
// We are using lipo tool to build multiarchitecture binaries.
|
|
|
|
|
// TODO(jbd): Investigate the new announcements about iO9's fat binary
|
|
|
|
|
// size limitations are breaking this feature.
|
2015-07-19 21:29:35 -04:00
|
|
|
|
cmd := exec.Command(
|
|
|
|
|
"xcrun", "lipo",
|
|
|
|
|
"-create", armPath, arm64Path,
|
|
|
|
|
"-o", filepath.Join(tmpdir, "main/main"),
|
|
|
|
|
)
|
|
|
|
|
if err := runCmd(cmd); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-12 11:17:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-18 13:47:19 -07:00
|
|
|
|
// TODO(jbd): Set the launcher icon.
|
2015-07-10 16:47:46 -06:00
|
|
|
|
if err := iosCopyAssets(pkg, tmpdir); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-18 13:47:19 -07:00
|
|
|
|
}
|
2015-06-12 11:17:46 -07:00
|
|
|
|
|
|
|
|
|
// Build and move the release build to the output directory.
|
2015-07-19 21:29:35 -04:00
|
|
|
|
cmd = exec.Command(
|
2015-07-09 15:38:20 -06:00
|
|
|
|
"xcrun", "xcodebuild",
|
|
|
|
|
"-configuration", "Release",
|
2015-07-10 16:47:46 -06:00
|
|
|
|
"-project", tmpdir+"/main.xcodeproj",
|
2015-07-09 15:38:20 -06:00
|
|
|
|
)
|
2015-07-19 21:29:35 -04:00
|
|
|
|
if err := runCmd(cmd); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-12 11:17:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO(jbd): Fallback to copying if renaming fails.
|
2015-07-08 09:46:18 -06:00
|
|
|
|
if buildO == "" {
|
|
|
|
|
buildO = path.Base(pkg.ImportPath) + ".app"
|
2015-06-12 11:17:46 -07:00
|
|
|
|
}
|
|
|
|
|
if buildX {
|
2015-07-10 16:47:46 -06:00
|
|
|
|
printcmd("mv %s %s", tmpdir+"/build/Release-iphoneos/main.app", buildO)
|
2015-06-12 11:17:46 -07:00
|
|
|
|
}
|
|
|
|
|
if !buildN {
|
2015-06-29 10:17:55 -07:00
|
|
|
|
// if output already exists, remove.
|
2015-07-08 09:46:18 -06:00
|
|
|
|
if err := os.RemoveAll(buildO); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-29 10:17:55 -07:00
|
|
|
|
}
|
2015-07-10 16:47:46 -06:00
|
|
|
|
if err := os.Rename(tmpdir+"/build/Release-iphoneos/main.app", buildO); err != nil {
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nil, err
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-24 16:47:16 -04:00
|
|
|
|
return nmpkgs, nil
|
2015-06-07 22:20:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 16:47:46 -06:00
|
|
|
|
func iosCopyAssets(pkg *build.Package, xcodeProjDir string) error {
|
2015-06-29 10:52:22 -07:00
|
|
|
|
dstAssets := xcodeProjDir + "/main/assets"
|
2015-07-19 21:29:35 -04:00
|
|
|
|
if err := mkdir(dstAssets); err != nil {
|
|
|
|
|
return err
|
2015-06-29 10:52:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srcAssets := filepath.Join(pkg.Dir, "assets")
|
|
|
|
|
fi, err := os.Stat(srcAssets)
|
2015-06-18 13:47:19 -07:00
|
|
|
|
if err != nil {
|
|
|
|
|
if os.IsNotExist(err) {
|
2015-06-29 10:52:22 -07:00
|
|
|
|
// skip walking through the directory to deep copy.
|
|
|
|
|
return nil
|
2015-06-18 13:47:19 -07:00
|
|
|
|
}
|
2015-06-29 10:52:22 -07:00
|
|
|
|
return err
|
2015-06-18 13:47:19 -07:00
|
|
|
|
}
|
2015-06-29 10:52:22 -07:00
|
|
|
|
if !fi.IsDir() {
|
|
|
|
|
// skip walking through to deep copy.
|
2015-06-18 13:47:19 -07:00
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:52:22 -07:00
|
|
|
|
return filepath.Walk(srcAssets, func(path string, info os.FileInfo, err error) error {
|
2015-06-18 13:47:19 -07:00
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if info.IsDir() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2015-06-29 10:52:22 -07:00
|
|
|
|
dst := dstAssets + "/" + path[len(srcAssets)+1:]
|
2015-07-19 21:29:35 -04:00
|
|
|
|
return copyFile(dst, path)
|
2015-06-18 13:47:19 -07:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 15:23:17 -07:00
|
|
|
|
type infoplistTmplData struct {
|
2015-08-02 19:52:31 -04:00
|
|
|
|
BundleID string
|
|
|
|
|
Name string
|
2015-07-20 15:23:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var infoplistTmpl = template.Must(template.New("infoplist").Parse(`<?xml version="1.0" encoding="UTF-8"?>
|
2015-06-07 22:20:23 -07:00
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
|
<plist version="1.0">
|
|
|
|
|
<dict>
|
|
|
|
|
<key>CFBundleDevelopmentRegion</key>
|
|
|
|
|
<string>en</string>
|
|
|
|
|
<key>CFBundleExecutable</key>
|
2015-07-21 14:45:53 -07:00
|
|
|
|
<string>main</string>
|
2015-06-07 22:20:23 -07:00
|
|
|
|
<key>CFBundleIdentifier</key>
|
2015-08-02 19:52:31 -04:00
|
|
|
|
<string>{{.BundleID}}</string>
|
2015-06-07 22:20:23 -07:00
|
|
|
|
<key>CFBundleInfoDictionaryVersion</key>
|
|
|
|
|
<string>6.0</string>
|
|
|
|
|
<key>CFBundleName</key>
|
2015-07-21 14:45:53 -07:00
|
|
|
|
<string>{{.Name}}</string>
|
2015-06-07 22:20:23 -07:00
|
|
|
|
<key>CFBundlePackageType</key>
|
|
|
|
|
<string>APPL</string>
|
|
|
|
|
<key>CFBundleShortVersionString</key>
|
|
|
|
|
<string>1.0</string>
|
|
|
|
|
<key>CFBundleSignature</key>
|
|
|
|
|
<string>????</string>
|
|
|
|
|
<key>CFBundleVersion</key>
|
|
|
|
|
<string>1</string>
|
|
|
|
|
<key>LSRequiresIPhoneOS</key>
|
|
|
|
|
<true/>
|
|
|
|
|
<key>UILaunchStoryboardName</key>
|
|
|
|
|
<string>LaunchScreen</string>
|
|
|
|
|
<key>UIRequiredDeviceCapabilities</key>
|
|
|
|
|
<array>
|
|
|
|
|
<string>armv7</string>
|
|
|
|
|
</array>
|
|
|
|
|
<key>UISupportedInterfaceOrientations</key>
|
|
|
|
|
<array>
|
|
|
|
|
<string>UIInterfaceOrientationPortrait</string>
|
|
|
|
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
|
|
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
|
|
|
</array>
|
|
|
|
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
|
|
|
|
<array>
|
|
|
|
|
<string>UIInterfaceOrientationPortrait</string>
|
|
|
|
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
|
|
|
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
|
|
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
|
|
|
</array>
|
|
|
|
|
</dict>
|
|
|
|
|
</plist>
|
2015-07-20 15:23:17 -07:00
|
|
|
|
`))
|
2015-06-07 22:20:23 -07:00
|
|
|
|
|
|
|
|
|
const projPbxproj = `// !$*UTF8*$!
|
|
|
|
|
{
|
|
|
|
|
archiveVersion = 1;
|
|
|
|
|
classes = {
|
|
|
|
|
};
|
|
|
|
|
objectVersion = 46;
|
|
|
|
|
objects = {
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin PBXBuildFile section */
|
|
|
|
|
254BB84F1B1FD08900C56DE9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 254BB84E1B1FD08900C56DE9 /* Images.xcassets */; };
|
|
|
|
|
254BB8681B1FD16500C56DE9 /* main in Resources */ = {isa = PBXBuildFile; fileRef = 254BB8671B1FD16500C56DE9 /* main */; };
|
2015-06-18 13:47:19 -07:00
|
|
|
|
25FB30331B30FDEE0005924C /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 25FB30321B30FDEE0005924C /* assets */; };
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* End PBXBuildFile section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin PBXFileReference section */
|
|
|
|
|
254BB83E1B1FD08900C56DE9 /* main.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = main.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
|
|
|
254BB8421B1FD08900C56DE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
|
|
|
|
254BB84E1B1FD08900C56DE9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
|
|
|
|
254BB8671B1FD16500C56DE9 /* main */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = main; sourceTree = "<group>"; };
|
2015-06-18 13:47:19 -07:00
|
|
|
|
25FB30321B30FDEE0005924C /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = main/assets; sourceTree = "<group>"; };
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* End PBXFileReference section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin PBXGroup section */
|
|
|
|
|
254BB8351B1FD08900C56DE9 = {
|
|
|
|
|
isa = PBXGroup;
|
|
|
|
|
children = (
|
2015-06-18 13:47:19 -07:00
|
|
|
|
25FB30321B30FDEE0005924C /* assets */,
|
2015-06-07 22:20:23 -07:00
|
|
|
|
254BB8401B1FD08900C56DE9 /* main */,
|
|
|
|
|
254BB83F1B1FD08900C56DE9 /* Products */,
|
|
|
|
|
);
|
|
|
|
|
sourceTree = "<group>";
|
|
|
|
|
usesTabs = 0;
|
|
|
|
|
};
|
|
|
|
|
254BB83F1B1FD08900C56DE9 /* Products */ = {
|
|
|
|
|
isa = PBXGroup;
|
|
|
|
|
children = (
|
|
|
|
|
254BB83E1B1FD08900C56DE9 /* main.app */,
|
|
|
|
|
);
|
|
|
|
|
name = Products;
|
|
|
|
|
sourceTree = "<group>";
|
|
|
|
|
};
|
|
|
|
|
254BB8401B1FD08900C56DE9 /* main */ = {
|
|
|
|
|
isa = PBXGroup;
|
|
|
|
|
children = (
|
|
|
|
|
254BB8671B1FD16500C56DE9 /* main */,
|
|
|
|
|
254BB84E1B1FD08900C56DE9 /* Images.xcassets */,
|
|
|
|
|
254BB8411B1FD08900C56DE9 /* Supporting Files */,
|
|
|
|
|
);
|
|
|
|
|
path = main;
|
|
|
|
|
sourceTree = "<group>";
|
|
|
|
|
};
|
|
|
|
|
254BB8411B1FD08900C56DE9 /* Supporting Files */ = {
|
|
|
|
|
isa = PBXGroup;
|
|
|
|
|
children = (
|
|
|
|
|
254BB8421B1FD08900C56DE9 /* Info.plist */,
|
|
|
|
|
);
|
|
|
|
|
name = "Supporting Files";
|
|
|
|
|
sourceTree = "<group>";
|
|
|
|
|
};
|
|
|
|
|
/* End PBXGroup section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin PBXNativeTarget section */
|
|
|
|
|
254BB83D1B1FD08900C56DE9 /* main */ = {
|
|
|
|
|
isa = PBXNativeTarget;
|
|
|
|
|
buildConfigurationList = 254BB8611B1FD08900C56DE9 /* Build configuration list for PBXNativeTarget "main" */;
|
|
|
|
|
buildPhases = (
|
|
|
|
|
254BB83C1B1FD08900C56DE9 /* Resources */,
|
|
|
|
|
);
|
|
|
|
|
buildRules = (
|
|
|
|
|
);
|
|
|
|
|
dependencies = (
|
|
|
|
|
);
|
|
|
|
|
name = main;
|
|
|
|
|
productName = main;
|
|
|
|
|
productReference = 254BB83E1B1FD08900C56DE9 /* main.app */;
|
|
|
|
|
productType = "com.apple.product-type.application";
|
|
|
|
|
};
|
|
|
|
|
/* End PBXNativeTarget section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin PBXProject section */
|
|
|
|
|
254BB8361B1FD08900C56DE9 /* Project object */ = {
|
|
|
|
|
isa = PBXProject;
|
|
|
|
|
attributes = {
|
|
|
|
|
LastUpgradeCheck = 0630;
|
|
|
|
|
ORGANIZATIONNAME = Developer;
|
|
|
|
|
TargetAttributes = {
|
|
|
|
|
254BB83D1B1FD08900C56DE9 = {
|
|
|
|
|
CreatedOnToolsVersion = 6.3.1;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
buildConfigurationList = 254BB8391B1FD08900C56DE9 /* Build configuration list for PBXProject "main" */;
|
|
|
|
|
compatibilityVersion = "Xcode 3.2";
|
|
|
|
|
developmentRegion = English;
|
|
|
|
|
hasScannedForEncodings = 0;
|
|
|
|
|
knownRegions = (
|
|
|
|
|
en,
|
|
|
|
|
Base,
|
|
|
|
|
);
|
|
|
|
|
mainGroup = 254BB8351B1FD08900C56DE9;
|
|
|
|
|
productRefGroup = 254BB83F1B1FD08900C56DE9 /* Products */;
|
|
|
|
|
projectDirPath = "";
|
|
|
|
|
projectRoot = "";
|
|
|
|
|
targets = (
|
|
|
|
|
254BB83D1B1FD08900C56DE9 /* main */,
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
/* End PBXProject section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin PBXResourcesBuildPhase section */
|
|
|
|
|
254BB83C1B1FD08900C56DE9 /* Resources */ = {
|
|
|
|
|
isa = PBXResourcesBuildPhase;
|
|
|
|
|
buildActionMask = 2147483647;
|
|
|
|
|
files = (
|
2015-06-18 13:47:19 -07:00
|
|
|
|
25FB30331B30FDEE0005924C /* assets in Resources */,
|
2015-06-07 22:20:23 -07:00
|
|
|
|
254BB8681B1FD16500C56DE9 /* main in Resources */,
|
|
|
|
|
254BB84F1B1FD08900C56DE9 /* Images.xcassets in Resources */,
|
|
|
|
|
);
|
|
|
|
|
runOnlyForDeploymentPostprocessing = 0;
|
|
|
|
|
};
|
|
|
|
|
/* End PBXResourcesBuildPhase section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin XCBuildConfiguration section */
|
|
|
|
|
254BB85F1B1FD08900C56DE9 /* Debug */ = {
|
|
|
|
|
isa = XCBuildConfiguration;
|
|
|
|
|
buildSettings = {
|
|
|
|
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
|
|
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
|
|
|
CLANG_CXX_LIBRARY = "libc++";
|
|
|
|
|
CLANG_ENABLE_MODULES = YES;
|
|
|
|
|
CLANG_ENABLE_OBJC_ARC = YES;
|
|
|
|
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
|
|
|
CLANG_WARN_EMPTY_BODY = YES;
|
|
|
|
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_INT_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
|
|
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
|
|
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
|
|
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
|
|
|
|
COPY_PHASE_STRIP = NO;
|
|
|
|
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
|
|
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
|
|
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
|
|
|
GCC_DYNAMIC_NO_PIC = NO;
|
|
|
|
|
GCC_NO_COMMON_BLOCKS = YES;
|
|
|
|
|
GCC_OPTIMIZATION_LEVEL = 0;
|
|
|
|
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
|
|
|
"DEBUG=1",
|
|
|
|
|
"$(inherited)",
|
|
|
|
|
);
|
|
|
|
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
|
|
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
|
|
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
|
|
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
|
|
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
|
|
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
|
|
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
|
|
|
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
|
|
|
|
|
MTL_ENABLE_DEBUG_INFO = YES;
|
|
|
|
|
ONLY_ACTIVE_ARCH = YES;
|
|
|
|
|
SDKROOT = iphoneos;
|
|
|
|
|
TARGETED_DEVICE_FAMILY = "1,2";
|
|
|
|
|
};
|
|
|
|
|
name = Debug;
|
|
|
|
|
};
|
|
|
|
|
254BB8601B1FD08900C56DE9 /* Release */ = {
|
|
|
|
|
isa = XCBuildConfiguration;
|
|
|
|
|
buildSettings = {
|
|
|
|
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
|
|
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
|
|
|
CLANG_CXX_LIBRARY = "libc++";
|
|
|
|
|
CLANG_ENABLE_MODULES = YES;
|
|
|
|
|
CLANG_ENABLE_OBJC_ARC = YES;
|
|
|
|
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
|
|
|
CLANG_WARN_EMPTY_BODY = YES;
|
|
|
|
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_INT_CONVERSION = YES;
|
|
|
|
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
|
|
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
|
|
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
|
|
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
|
|
|
|
COPY_PHASE_STRIP = NO;
|
|
|
|
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
|
|
|
ENABLE_NS_ASSERTIONS = NO;
|
|
|
|
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
|
|
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
|
|
|
GCC_NO_COMMON_BLOCKS = YES;
|
|
|
|
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
|
|
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
|
|
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
|
|
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
|
|
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
|
|
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
|
|
|
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
|
|
|
|
|
MTL_ENABLE_DEBUG_INFO = NO;
|
|
|
|
|
SDKROOT = iphoneos;
|
|
|
|
|
TARGETED_DEVICE_FAMILY = "1,2";
|
|
|
|
|
VALIDATE_PRODUCT = YES;
|
|
|
|
|
};
|
|
|
|
|
name = Release;
|
|
|
|
|
};
|
|
|
|
|
254BB8621B1FD08900C56DE9 /* Debug */ = {
|
|
|
|
|
isa = XCBuildConfiguration;
|
|
|
|
|
buildSettings = {
|
|
|
|
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
|
|
|
|
INFOPLIST_FILE = main/Info.plist;
|
|
|
|
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
|
|
|
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
|
|
|
};
|
|
|
|
|
name = Debug;
|
|
|
|
|
};
|
|
|
|
|
254BB8631B1FD08900C56DE9 /* Release */ = {
|
|
|
|
|
isa = XCBuildConfiguration;
|
|
|
|
|
buildSettings = {
|
|
|
|
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
|
|
|
|
INFOPLIST_FILE = main/Info.plist;
|
|
|
|
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
|
|
|
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
|
|
|
};
|
|
|
|
|
name = Release;
|
|
|
|
|
};
|
|
|
|
|
/* End XCBuildConfiguration section */
|
2015-06-18 13:47:19 -07:00
|
|
|
|
|
2015-06-07 22:20:23 -07:00
|
|
|
|
/* Begin XCConfigurationList section */
|
|
|
|
|
254BB8391B1FD08900C56DE9 /* Build configuration list for PBXProject "main" */ = {
|
|
|
|
|
isa = XCConfigurationList;
|
|
|
|
|
buildConfigurations = (
|
|
|
|
|
254BB85F1B1FD08900C56DE9 /* Debug */,
|
|
|
|
|
254BB8601B1FD08900C56DE9 /* Release */,
|
|
|
|
|
);
|
|
|
|
|
defaultConfigurationIsVisible = 0;
|
|
|
|
|
defaultConfigurationName = Release;
|
|
|
|
|
};
|
|
|
|
|
254BB8611B1FD08900C56DE9 /* Build configuration list for PBXNativeTarget "main" */ = {
|
|
|
|
|
isa = XCConfigurationList;
|
|
|
|
|
buildConfigurations = (
|
|
|
|
|
254BB8621B1FD08900C56DE9 /* Debug */,
|
|
|
|
|
254BB8631B1FD08900C56DE9 /* Release */,
|
|
|
|
|
);
|
|
|
|
|
defaultConfigurationIsVisible = 0;
|
|
|
|
|
defaultConfigurationName = Release;
|
|
|
|
|
};
|
|
|
|
|
/* End XCConfigurationList section */
|
|
|
|
|
};
|
|
|
|
|
rootObject = 254BB8361B1FD08900C56DE9 /* Project object */;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const contentsJSON = `{
|
|
|
|
|
"images" : [
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "iphone",
|
|
|
|
|
"size" : "29x29",
|
|
|
|
|
"scale" : "2x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "iphone",
|
|
|
|
|
"size" : "29x29",
|
|
|
|
|
"scale" : "3x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "iphone",
|
|
|
|
|
"size" : "40x40",
|
|
|
|
|
"scale" : "2x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "iphone",
|
|
|
|
|
"size" : "40x40",
|
|
|
|
|
"scale" : "3x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "iphone",
|
|
|
|
|
"size" : "60x60",
|
|
|
|
|
"scale" : "2x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "iphone",
|
|
|
|
|
"size" : "60x60",
|
|
|
|
|
"scale" : "3x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "ipad",
|
|
|
|
|
"size" : "29x29",
|
|
|
|
|
"scale" : "1x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "ipad",
|
|
|
|
|
"size" : "29x29",
|
|
|
|
|
"scale" : "2x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "ipad",
|
|
|
|
|
"size" : "40x40",
|
|
|
|
|
"scale" : "1x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "ipad",
|
|
|
|
|
"size" : "40x40",
|
|
|
|
|
"scale" : "2x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "ipad",
|
|
|
|
|
"size" : "76x76",
|
|
|
|
|
"scale" : "1x"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"idiom" : "ipad",
|
|
|
|
|
"size" : "76x76",
|
|
|
|
|
"scale" : "2x"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"info" : {
|
|
|
|
|
"version" : 1,
|
|
|
|
|
"author" : "xcode"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
2015-08-02 19:52:31 -04:00
|
|
|
|
|
|
|
|
|
// rfc1034Label sanitizes the name to be usable in a uniform type identifier.
|
|
|
|
|
// The sanitization is similar to xcode's rfc1034identifier macro that
|
|
|
|
|
// replaces illegal characters (not conforming the rfc1034 label rule) with '-'.
|
|
|
|
|
func rfc1034Label(name string) string {
|
|
|
|
|
// * Uniform type identifier:
|
|
|
|
|
//
|
|
|
|
|
// According to
|
|
|
|
|
// https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html
|
|
|
|
|
//
|
|
|
|
|
// A uniform type identifier is a Unicode string that usually contains characters
|
|
|
|
|
// in the ASCII character set. However, only a subset of the ASCII characters are
|
|
|
|
|
// permitted. You may use the Roman alphabet in upper and lower case (A–Z, a–z),
|
|
|
|
|
// the digits 0 through 9, the dot (“.”), and the hyphen (“-”). This restriction
|
|
|
|
|
// is based on DNS name restrictions, set forth in RFC 1035.
|
|
|
|
|
//
|
|
|
|
|
// Uniform type identifiers may also contain any of the Unicode characters greater
|
|
|
|
|
// than U+007F.
|
|
|
|
|
//
|
|
|
|
|
// Note: the actual implementation of xcode does not allow some unicode characters
|
|
|
|
|
// greater than U+007f. In this implementation, we just replace everything non
|
|
|
|
|
// alphanumeric with "-" like the rfc1034identifier macro.
|
|
|
|
|
//
|
|
|
|
|
// * RFC1034 Label
|
|
|
|
|
//
|
|
|
|
|
// <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
|
|
|
|
|
// <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
|
|
|
|
|
// <let-dig-hyp> ::= <let-dig> | "-"
|
|
|
|
|
// <let-dig> ::= <letter> | <digit>
|
|
|
|
|
const surrSelf = 0x10000
|
|
|
|
|
begin := false
|
|
|
|
|
|
|
|
|
|
var res []rune
|
|
|
|
|
for i, r := range name {
|
|
|
|
|
if r == '.' && !begin {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
begin = true
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
|
case 'a' <= r && r <= 'z', 'A' <= r && r <= 'Z':
|
|
|
|
|
res = append(res, r)
|
|
|
|
|
case '0' <= r && r <= '9':
|
|
|
|
|
if i == 0 {
|
|
|
|
|
res = append(res, '-')
|
|
|
|
|
} else {
|
|
|
|
|
res = append(res, r)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
if r < surrSelf {
|
|
|
|
|
res = append(res, '-')
|
|
|
|
|
} else {
|
|
|
|
|
res = append(res, '-', '-')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return string(res)
|
|
|
|
|
}
|