iOS builds have been broken due to missing main executable. Xcode doesn't complain and buildling the target .app bundle even if a referenced objects doesn't exist. Fixing .app builds and adding a unit test. Change-Id: Ie9aec6c8c982a96c10bf07344e44bd501fcabd19 Reviewed-on: https://go-review.googlesource.com/12492 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
422 lines
14 KiB
Go
422 lines
14 KiB
Go
// 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 (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"text/template"
|
|
)
|
|
|
|
func TestIOSBuild(t *testing.T) {
|
|
buf := new(bytes.Buffer)
|
|
defer func() {
|
|
xout = os.Stderr
|
|
buildN = false
|
|
buildX = false
|
|
}()
|
|
xout = buf
|
|
buildN = true
|
|
buildX = true
|
|
buildO = "basic.app"
|
|
buildTarget = "ios"
|
|
gopath = filepath.SplitList(os.Getenv("GOPATH"))[0]
|
|
cmdBuild.flag.Parse([]string{"golang.org/x/mobile/example/basic"})
|
|
err := runBuild(cmdBuild)
|
|
if err != nil {
|
|
t.Log(buf.String())
|
|
t.Fatal(err)
|
|
}
|
|
|
|
diff, err := diffOutput(buf.String(), iosBuildTmpl)
|
|
if err != nil {
|
|
t.Fatalf("computing diff failed: %v", err)
|
|
}
|
|
if diff != "" {
|
|
t.Errorf("unexpected output:\n%s", diff)
|
|
}
|
|
}
|
|
|
|
var iosBuildTmpl = template.Must(template.New("output").Parse(`GOMOBILE={{.GOPATH}}/pkg/gomobile
|
|
WORK=$WORK
|
|
mkdir -p $WORK/main.xcodeproj
|
|
echo "// !$*UTF8*$!
|
|
{
|
|
archiveVersion = 1;
|
|
classes = {
|
|
};
|
|
objectVersion = 46;
|
|
objects = {
|
|
|
|
/* Begin PBXBuildFile section */
|
|
254BB84F1B1FD08900C56DE9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 254BB84E1B1FD08900C56DE9 /* Images.xcassets */; };
|
|
254BB8681B1FD16500C56DE9 /* main in Resources */ = {isa = PBXBuildFile; fileRef = 254BB8671B1FD16500C56DE9 /* main */; };
|
|
25FB30331B30FDEE0005924C /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 25FB30321B30FDEE0005924C /* assets */; };
|
|
/* End PBXBuildFile section */
|
|
|
|
/* 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>"; };
|
|
25FB30321B30FDEE0005924C /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = main/assets; sourceTree = "<group>"; };
|
|
/* End PBXFileReference section */
|
|
|
|
/* Begin PBXGroup section */
|
|
254BB8351B1FD08900C56DE9 = {
|
|
isa = PBXGroup;
|
|
children = (
|
|
25FB30321B30FDEE0005924C /* assets */,
|
|
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 */
|
|
|
|
/* 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 */
|
|
|
|
/* 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 */
|
|
|
|
/* Begin PBXResourcesBuildPhase section */
|
|
254BB83C1B1FD08900C56DE9 /* Resources */ = {
|
|
isa = PBXResourcesBuildPhase;
|
|
buildActionMask = 2147483647;
|
|
files = (
|
|
25FB30331B30FDEE0005924C /* assets in Resources */,
|
|
254BB8681B1FD16500C56DE9 /* main in Resources */,
|
|
254BB84F1B1FD08900C56DE9 /* Images.xcassets in Resources */,
|
|
);
|
|
runOnlyForDeploymentPostprocessing = 0;
|
|
};
|
|
/* End PBXResourcesBuildPhase section */
|
|
|
|
/* 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 */
|
|
|
|
/* 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 */;
|
|
}
|
|
" > $WORK/main.xcodeproj/project.pbxproj
|
|
mkdir -p $WORK/main
|
|
echo "<?xml version="1.0" encoding="UTF-8"?>
|
|
<!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>
|
|
<string>main</string>
|
|
<key>CFBundleIdentifier</key>
|
|
<string>org.golang.todo.$(PRODUCT_NAME:rfc1034identifier)</string>
|
|
<key>CFBundleInfoDictionaryVersion</key>
|
|
<string>6.0</string>
|
|
<key>CFBundleName</key>
|
|
<string>Basic</string>
|
|
<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>
|
|
" > $WORK/main/Info.plist
|
|
mkdir -p $WORK/main/Images.xcassets/AppIcon.appiconset
|
|
echo "{
|
|
"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"
|
|
}
|
|
}
|
|
" > $WORK/main/Images.xcassets/AppIcon.appiconset/Contents.json
|
|
GOOS=darwin GOARCH=arm GOARM=7 CC=clang-iphoneos CXX=clang-iphoneos CGO_CFLAGS=-isysroot=iphoneos -arch armv7 CGO_LDFLAGS=-isysroot=iphoneos -arch armv7 CGO_ENABLED=1 go build -pkgdir=$GOMOBILE/pkg_darwin_arm -tags="" -x -tags=ios -o=$WORK/arm golang.org/x/mobile/example/basic
|
|
GOOS=darwin GOARCH=arm64 CC=clang-iphoneos CXX=clang-iphoneos CGO_CFLAGS=-isysroot=iphoneos -arch arm64 CGO_LDFLAGS=-isysroot=iphoneos -arch arm64 CGO_ENABLED=1 go build -pkgdir=$GOMOBILE/pkg_darwin_arm64 -tags="" -x -tags=ios -o=$WORK/arm64 golang.org/x/mobile/example/basic
|
|
xcrun lipo -create $WORK/arm $WORK/arm64 -o $WORK/main/main
|
|
mkdir -p $WORK/main/assets
|
|
xcrun xcodebuild -configuration Release -project $WORK/main.xcodeproj
|
|
mv $WORK/build/Release-iphoneos/main.app basic.app
|
|
`))
|