diff options
| author | ruki <[email protected]> | 2020-04-08 23:34:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-08 15:24:59 +0800 |
| commit | 73323570007d4765824883c64036e72eabdab2cf (patch) | |
| tree | ddeaffa62543d8bdc2440f59ee700f7aaaa3c979 | |
| parent | c472bf464c4af2532d574d1063e473863f1adb54 (diff) | |
support for building xcode.app/iphoneos
| -rw-r--r-- | tests/projects/objc/iosapp/src/AppDelegate.h | 15 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/AppDelegate.m | 41 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json | 98 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/Assets.xcassets/Contents.json | 6 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/Base.lproj/LaunchScreen.storyboard | 25 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/Base.lproj/Main.storyboard | 24 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/Info.plist | 64 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/SceneDelegate.h | 16 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/SceneDelegate.m | 50 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/ViewController.h | 15 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/ViewController.m | 23 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/src/main.m | 19 | ||||
| -rw-r--r-- | tests/projects/objc/iosapp/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/build_file.lua | 26 | ||||
| -rw-r--r-- | xmake/rules/xcode/application/load.lua | 3 |
15 files changed, 428 insertions, 3 deletions
diff --git a/tests/projects/objc/iosapp/src/AppDelegate.h b/tests/projects/objc/iosapp/src/AppDelegate.h new file mode 100644 index 000000000..b01a8dc72 --- /dev/null +++ b/tests/projects/objc/iosapp/src/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// test5 +// +// Created by ruki on 2020/4/8. +// Copyright © 2020 tboox. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface AppDelegate : UIResponder <UIApplicationDelegate> + + +@end + diff --git a/tests/projects/objc/iosapp/src/AppDelegate.m b/tests/projects/objc/iosapp/src/AppDelegate.m new file mode 100644 index 000000000..0ad500bfe --- /dev/null +++ b/tests/projects/objc/iosapp/src/AppDelegate.m @@ -0,0 +1,41 @@ +// +// AppDelegate.m +// test5 +// +// Created by ruki on 2020/4/8. +// Copyright © 2020 tboox. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +#pragma mark - UISceneSession lifecycle + + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; +} + + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. +} + + +@end diff --git a/tests/projects/objc/iosapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json b/tests/projects/objc/iosapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d8db8d65f --- /dev/null +++ b/tests/projects/objc/iosapp/src/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "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" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "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" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +}
\ No newline at end of file diff --git a/tests/projects/objc/iosapp/src/Assets.xcassets/Contents.json b/tests/projects/objc/iosapp/src/Assets.xcassets/Contents.json new file mode 100644 index 000000000..da4a164c9 --- /dev/null +++ b/tests/projects/objc/iosapp/src/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +}
\ No newline at end of file diff --git a/tests/projects/objc/iosapp/src/Base.lproj/LaunchScreen.storyboard b/tests/projects/objc/iosapp/src/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..865e9329f --- /dev/null +++ b/tests/projects/objc/iosapp/src/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="EHf-IW-A2E"> + <objects> + <viewController id="01J-lp-oVM" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> + <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="53" y="375"/> + </scene> + </scenes> +</document> diff --git a/tests/projects/objc/iosapp/src/Base.lproj/Main.storyboard b/tests/projects/objc/iosapp/src/Base.lproj/Main.storyboard new file mode 100644 index 000000000..808a21ce7 --- /dev/null +++ b/tests/projects/objc/iosapp/src/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="tne-QT-ifu"> + <objects> + <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> + <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> + </objects> + </scene> + </scenes> +</document> diff --git a/tests/projects/objc/iosapp/src/Info.plist b/tests/projects/objc/iosapp/src/Info.plist new file mode 100644 index 000000000..7b6037c25 --- /dev/null +++ b/tests/projects/objc/iosapp/src/Info.plist @@ -0,0 +1,64 @@ +<?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>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>UIApplicationSceneManifest</key> + <dict> + <key>UIApplicationSupportsMultipleScenes</key> + <false/> + <key>UISceneConfigurations</key> + <dict> + <key>UIWindowSceneSessionRoleApplication</key> + <array> + <dict> + <key>UISceneConfigurationName</key> + <string>Default Configuration</string> + <key>UISceneDelegateClassName</key> + <string>SceneDelegate</string> + <key>UISceneStoryboardFile</key> + <string>Main</string> + </dict> + </array> + </dict> + </dict> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> + <key>UIMainStoryboardFile</key> + <string>Main</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> diff --git a/tests/projects/objc/iosapp/src/SceneDelegate.h b/tests/projects/objc/iosapp/src/SceneDelegate.h new file mode 100644 index 000000000..5dbf88aa6 --- /dev/null +++ b/tests/projects/objc/iosapp/src/SceneDelegate.h @@ -0,0 +1,16 @@ +// +// SceneDelegate.h +// test5 +// +// Created by ruki on 2020/4/8. +// Copyright © 2020 tboox. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface SceneDelegate : UIResponder <UIWindowSceneDelegate> + +@property (strong, nonatomic) UIWindow * window; + +@end + diff --git a/tests/projects/objc/iosapp/src/SceneDelegate.m b/tests/projects/objc/iosapp/src/SceneDelegate.m new file mode 100644 index 000000000..d6698dd7c --- /dev/null +++ b/tests/projects/objc/iosapp/src/SceneDelegate.m @@ -0,0 +1,50 @@ +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). +} + + +- (void)sceneDidDisconnect:(UIScene *)scene { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). +} + + +- (void)sceneDidBecomeActive:(UIScene *)scene { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. +} + + +- (void)sceneWillResignActive:(UIScene *)scene { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). +} + + +- (void)sceneWillEnterForeground:(UIScene *)scene { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. +} + + +- (void)sceneDidEnterBackground:(UIScene *)scene { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. +} + + +@end diff --git a/tests/projects/objc/iosapp/src/ViewController.h b/tests/projects/objc/iosapp/src/ViewController.h new file mode 100644 index 000000000..e74d2f236 --- /dev/null +++ b/tests/projects/objc/iosapp/src/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// test5 +// +// Created by ruki on 2020/4/8. +// Copyright © 2020 tboox. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface ViewController : UIViewController + + +@end + diff --git a/tests/projects/objc/iosapp/src/ViewController.m b/tests/projects/objc/iosapp/src/ViewController.m new file mode 100644 index 000000000..c3441c87a --- /dev/null +++ b/tests/projects/objc/iosapp/src/ViewController.m @@ -0,0 +1,23 @@ +// +// ViewController.m +// test5 +// +// Created by ruki on 2020/4/8. +// Copyright © 2020 tboox. All rights reserved. +// + +#import "ViewController.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + + +@end diff --git a/tests/projects/objc/iosapp/src/main.m b/tests/projects/objc/iosapp/src/main.m new file mode 100644 index 000000000..11a58afc7 --- /dev/null +++ b/tests/projects/objc/iosapp/src/main.m @@ -0,0 +1,19 @@ +// +// main.m +// test5 +// +// Created by ruki on 2020/4/8. +// Copyright © 2020 tboox. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +} diff --git a/tests/projects/objc/iosapp/xmake.lua b/tests/projects/objc/iosapp/xmake.lua new file mode 100644 index 000000000..3413e3389 --- /dev/null +++ b/tests/projects/objc/iosapp/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.debug", "mode.release") + +target("test") + add_rules("xcode.application") + add_files("src/*.m", "src/**.storyboard", "src/*.xcassets") + add_installfiles("src/Info.plist") diff --git a/xmake/rules/xcode/application/build_file.lua b/xmake/rules/xcode/application/build_file.lua index 9045fc2d4..999dc8035 100644 --- a/xmake/rules/xcode/application/build_file.lua +++ b/xmake/rules/xcode/application/build_file.lua @@ -55,13 +55,28 @@ function _build_xcassets_file(target, sourcefile, opt) table.insert(argv, "mac") table.insert(argv, "--platform") table.insert(argv, "macosx") + elseif is_plat("iphoneos") then + table.insert(argv, "--target-device") + table.insert(argv, "iphone") + table.insert(argv, "--target-device") + table.insert(argv, "ipad") + table.insert(argv, "--platform") + table.insert(argv, "iphoneos") + else + assert("unknown device!") end table.insert(argv, "--minimum-deployment-target") table.insert(argv, get_config("target_minver")) table.insert(argv, "--app-icon") table.insert(argv, "AppIcon") - table.insert(argv, "--enable-on-demand-resources") - table.insert(argv, "NO") + if is_plat("iphoneos") then + table.insert(argv, "--enable-on-demand-resources") + table.insert(argv, "YES") + table.insert(argv, "--compress-pngs") + else + table.insert(argv, "--enable-on-demand-resources") + table.insert(argv, "NO") + end table.insert(argv, "--development-region") table.insert(argv, "en") table.insert(argv, "--product-type") @@ -109,6 +124,13 @@ function _build_storyboard_file(target, sourcefile, opt) if is_plat("macosx") then table.insert(argv, "--target-device") table.insert(argv, "mac") + elseif is_plat("iphoneos") then + table.insert(argv, "--target-device") + table.insert(argv, "iphone") + table.insert(argv, "--target-device") + table.insert(argv, "ipad") + else + assert("unknown device!") end table.insert(argv, "--minimum-deployment-target") table.insert(argv, get_config("target_minver")) diff --git a/xmake/rules/xcode/application/load.lua b/xmake/rules/xcode/application/load.lua index cb9da887a..4986d454f 100644 --- a/xmake/rules/xcode/application/load.lua +++ b/xmake/rules/xcode/application/load.lua @@ -28,10 +28,11 @@ function main (target) -- get contents and resources directory local contentsdir = appdir + local resourcesdir = appdir if is_plat("macosx") then contentsdir = path.join(appdir, "Contents") + resourcesdir = path.join(appdir, "Contents", "Resources") end - local resourcesdir = path.join(contentsdir, "Resources") target:data_set("xcode.app.contentsdir", contentsdir) target:data_set("xcode.app.resourcesdir", resourcesdir) |
