├── AIR Native Extension
├── screenshots
│ ├── options.png
│ ├── new_project.png
│ └── created_project.png
├── AIR Native Extension for iOS.xctemplate
│ ├── TemplateIcon.icns
│ ├── debugIPA.sh
│ ├── generateANE.sh
│ ├── platformoptions.xml
│ ├── extension.xml
│ ├── ___PACKAGENAMEASIDENTIFIER___.h
│ ├── ___PACKAGENAMEASIDENTIFIER___.m
│ └── TemplateInfo.plist
├── install_templates.sh
├── iOSBasic.xctemplate
│ └── TemplateInfo.plist
└── Basic.xctemplate
│ └── TemplateInfo.plist
├── license.txt
└── README.md
/AIR Native Extension/screenshots/options.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/divijkumar/xcode-template-ane/HEAD/AIR Native Extension/screenshots/options.png
--------------------------------------------------------------------------------
/AIR Native Extension/screenshots/new_project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/divijkumar/xcode-template-ane/HEAD/AIR Native Extension/screenshots/new_project.png
--------------------------------------------------------------------------------
/AIR Native Extension/screenshots/created_project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/divijkumar/xcode-template-ane/HEAD/AIR Native Extension/screenshots/created_project.png
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/TemplateIcon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/divijkumar/xcode-template-ane/HEAD/AIR Native Extension/AIR Native Extension for iOS.xctemplate/TemplateIcon.icns
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/debugIPA.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "Please provide the complete path of the IPA before building this target"
4 | PATH_TO_IPA="To BE FILLED BEFORE RUNNING THIS TARGET"
5 |
6 | IPA_DIR=`/usr/bin/dirname "$PATH_TO_IPA"`
7 | IPA_NAME=`/usr/bin/basename "$PATH_TO_IPA"`
8 | IPA_BASE_NAME=`/usr/bin/basename "$PATH_TO_IPA" .ipa`
9 |
10 | echo $IPA_DIR
11 | echo $IPA_NAME
12 | echo $IPA_BASE_NAME
13 |
14 | # change to the proper directory
15 | pushd "$IPA_DIR"
16 |
17 | # extract the IPA
18 | cp "$IPA_NAME" "$IPA_NAME".zip
19 | unzip -o "$IPA_NAME".zip
20 | rm "$IPA_NAME".zip
21 |
22 | # copy the contents of the IPA to the location xcode wants
23 | cp -r Payload/"$IPA_BASE_NAME".app/ "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/"
24 | cp -r "$IPA_BASE_NAME".app.dSYM "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/"
25 |
26 | # remove the following files and folders to avoid signature errors when installing the app
27 | rm "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/_CodeSignature/CodeResources"
28 | rmdir "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/_CodeSignature"
29 | rm "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/CodeResources"
30 | rm "${CONFIGURATION_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/PkgInfo" 2>/dev/null
31 |
32 |
33 | # restore working directory
34 | popd
35 |
36 |
37 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012, DIVIJ KUMAR
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 | 2. Redistributions in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | The views and conclusions contained in the software and documentation are those
25 | of the authors and should not be interpreted as representing official policies,
26 | either expressed or implied, of the FreeBSD Project.
27 |
28 |
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/generateANE.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo build dir = $BUILD_DIR
4 | echo project dir = $PROJECT_DIR
5 | echo configuration build dir = $CONFIGURATION_BUILD_DIR
6 | echo air sdk path = $AIR_SDK_PATH
7 |
8 | EXTENSION_SWC_FILE_NAME=`/usr/bin/basename "$NATIVEEXTENSION_SWC"`
9 | echo native extension swc = $NATIVEEXTENSION_SWC
10 |
11 | NATIVE_EXTENSION_STATIC_LIB_NAME=lib"$PRODUCT_NAME".a
12 |
13 | #copy the extension.xml from $PROJECT_DIR/$PRODUCT_NAME/extension.xml to "$CONFIGURATION_BUILD_DIR"
14 | cp -f "$PROJECT_DIR"/"$PRODUCT_NAME"/extension.xml "$CONFIGURATION_BUILD_DIR"
15 |
16 | #copy the platformoptions.xml from $PROJECT_DIR/$PRODUCT_NAME/platformoptions.xml to "$CONFIGURATION_BUILD_DIR"
17 | cp -f "$PROJECT_DIR"/"$PRODUCT_NAME"/platformoptions.xml "$CONFIGURATION_BUILD_DIR"
18 |
19 | #copy the swc from the original location to current configuration directory
20 | echo copying the swc from the original location to the "$CONFIGURATION_BUILD_DIR"
21 | cp -f "$NATIVEEXTENSION_SWC" "$CONFIGURATION_BUILD_DIR"
22 |
23 | #Extract library.swf from the swc
24 | echo "Extracting library.swf from the swc provided by the user"
25 | mkdir -p -v "$CONFIGURATION_BUILD_DIR"/swcContents
26 | /usr/bin/unzip -o "$NATIVEEXTENSION_SWC" -d "$CONFIGURATION_BUILD_DIR"/swcContents
27 | cp -f "$CONFIGURATION_BUILD_DIR"/swcContents/library.swf "$CONFIGURATION_BUILD_DIR"
28 | #remove the directory swcContents
29 | rm -rf "$CONFIGURATION_BUILD_DIR"/swcContents
30 |
31 | #Run the ADT command to generate the ANE
32 | pushd "$CONFIGURATION_BUILD_DIR"
33 | "$AIR_SDK_PATH"/bin/adt -package -target ane "$TARGET_NAME" extension.xml -swc "$EXTENSION_SWC_FILE_NAME" -platform default library.swf -platform iPhone-ARM -platformoptions platformoptions.xml "$NATIVE_EXTENSION_STATIC_LIB_NAME" library.swf
34 | popd
35 |
36 | echo "$TARGET_NAME" generated at "$CONFIGURATION_BUILD_DIR"/"$TARGET_NAME"
37 |
38 |
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/platformoptions.xml:
--------------------------------------------------------------------------------
1 |
31 |
32 |
33 | An optional description
34 | 2012 (optional)
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/AIR Native Extension/install_templates.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo 'Installing project template for AIR Native Extensions (ANE) for iOS'
4 |
5 | BASE_TEMPLATE_PATH="$HOME/Library/Developer/Xcode/Templates"
6 | PROJECT_TEMPLATE_DST_DIR="$BASE_TEMPLATE_PATH/Project Templates/AIR Native Extension/"
7 |
8 | force=
9 | forceCopy=
10 | uninstall=
11 |
12 | usage(){
13 | cat << EOF
14 | usage: $0 [options]
15 |
16 | Install/update project templates for AIR Native Extension
17 |
18 | OPTIONS:
19 | -f force overwrite if a previous version of the AIR Native Extension project templates exist
20 | -h this help
21 | -u uninstall Xcode 4 AIR Native Extension project templates. (CAUTION: This removes everything in "$PROJECT_TEMPLATE_DST_DIR". Use with extreme care)
22 | EOF
23 | }
24 |
25 | while getopts "fhu" OPTION; do
26 | case "$OPTION" in
27 | f)
28 | force=1
29 | forceCopy="-f"
30 | ;;
31 | h)
32 | usage
33 | exit 0
34 | ;;
35 | u)
36 | uninstall=1
37 | ;;
38 | esac
39 | done
40 |
41 | uninstall_xcode4_ane_project_templates(){
42 | if [[ -d $PROJECT_TEMPLATE_DST_DIR ]]; then
43 | echo "Removing project templates: \"${PROJECT_TEMPLATE_DST_DIR}\""
44 | rm -rf "$PROJECT_TEMPLATE_DST_DIR"
45 | fi
46 | }
47 |
48 | install_xcode4_ane_project_templates(){
49 | if [[ -d "$PROJECT_TEMPLATE_DST_DIR" ]]; then
50 | if [[ $force ]]; then
51 | echo "Overwriting the files in: \"${PROJECT_TEMPLATE_DST_DIR}\""
52 | else
53 | echo "Project templates already installed. To force a re-install use the '-f' parameter."
54 | exit 1
55 | fi
56 | else
57 | echo "Creating destination directory: \"${PROJECT_TEMPLATE_DST_DIR}\"..."
58 | mkdir -p "$PROJECT_TEMPLATE_DST_DIR"
59 | fi
60 |
61 | echo "Copying Project Templates..."
62 | cp -r $forceCopy "./AIR Native Extension for iOS.xctemplate" "$PROJECT_TEMPLATE_DST_DIR"
63 | cp -r $forceCopy "./Basic.xctemplate" "$PROJECT_TEMPLATE_DST_DIR"
64 | cp -r $forceCopy "./iOSBasic.xctemplate" "$PROJECT_TEMPLATE_DST_DIR"
65 | }
66 |
67 |
68 | if [[ $uninstall ]]; then
69 | uninstall_xcode4_ane_project_templates
70 | else
71 | install_xcode4_ane_project_templates
72 |
73 | fi
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/AIR Native Extension/iOSBasic.xctemplate/TemplateInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Definitions
6 |
7 | *:*:importCocoa
8 | #import <UIKit/UIKit.h>
9 |
10 | ___PACKAGENAME___-Info.plist:UISupportedInterfaceOrientations~iPad
11 | <key>UISupportedInterfaceOrientations~ipad</key>
12 | <array>
13 | <string>UIInterfaceOrientationPortrait</string>
14 | <string>UIInterfaceOrientationPortraitUpsideDown</string>
15 | <string>UIInterfaceOrientationLandscapeLeft</string>
16 | <string>UIInterfaceOrientationLandscapeRight</string>
17 | </array>
18 | ___PACKAGENAME___-Info.plist:UISupportedInterfaceOrientations~iPhone
19 | <key>UISupportedInterfaceOrientations</key>
20 | <array>
21 | <string>UIInterfaceOrientationPortrait</string>
22 | <string>UIInterfaceOrientationLandscapeLeft</string>
23 | <string>UIInterfaceOrientationLandscapeRight</string>
24 | </array>
25 |
26 | Identifier
27 | com.divij.ane.unit.iOSBasic
28 | Kind
29 | Xcode.Xcode3.ProjectTemplateUnitKind
30 | Platforms
31 |
32 | com.apple.platform.iphoneos
33 |
34 | Project
35 |
36 | Configurations
37 |
38 | Release
39 |
40 | VALIDATE_PRODUCT
41 | YES
42 |
43 |
44 | SDK
45 | iphoneos
46 | SharedSettings
47 |
48 | ARCHS
49 | $(ARCHS_STANDARD_32_BIT)
50 | CLANG_ENABLE_OBJC_ARC
51 | NO
52 | GCC_VERSION
53 | com.apple.compilers.llvmgcc42
54 | IPHONEOS_DEPLOYMENT_TARGET
55 | latest_iphoneos
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/extension.xml:
--------------------------------------------------------------------------------
1 |
31 |
32 |
33 | ___VARIABLE_bundleIdentifier:bundleIdentifier___
34 | 1
35 |
36 |
37 |
38 | lib___PACKAGENAME___.a
39 | ___VARIABLE_productName:RFC1034Identifier___ExtInitializer
40 | ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/___PACKAGENAMEASIDENTIFIER___.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (c) 2012, DIVIJ KUMAR
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | The views and conclusions contained in the software and documentation are those
27 | of the authors and should not be interpreted as representing official policies,
28 | either expressed or implied, of the FreeBSD Project.
29 |
30 |
31 | */
32 |
33 | /*
34 | * ___PACKAGENAME___
35 | *
36 | * Created by ___FULLUSERNAME___ on ___DATE___.
37 | * Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
38 | */
39 |
40 | #import
41 | #import "FlashRuntimeExtensions.h"
42 |
43 | #define ANE_FUNCTION(f) FREObject (f)(FREContext ctx, void *data, uint32_t argc, FREObject argv[])
44 | #define MAP_FUNCTION(f, data) { (const uint8_t*)(#f), (data), &(f) }
45 |
46 | /* ___VARIABLE_productName:RFC1034Identifier___ExtInitializer()
47 | * The extension initializer is called the first time the ActionScript side of the extension
48 | * calls ExtensionContext.createExtensionContext() for any context.
49 | *
50 | * Please note: this should be same as the specified in the extension.xml
51 | */
52 | void ___VARIABLE_productName:RFC1034Identifier___ExtInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet);
53 |
54 | /* ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer()
55 | * The extension finalizer is called when the runtime unloads the extension. However, it may not always called.
56 | *
57 | * Please note: this should be same as the specified in the extension.xml
58 | */
59 | void ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer(void* extData);
60 |
61 | /* ContextInitializer()
62 | * The context initializer is called when the runtime creates the extension context instance.
63 | */
64 | void ContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet);
65 |
66 | /* ContextFinalizer()
67 | * The context finalizer is called when the extension's ActionScript code
68 | * calls the ExtensionContext instance's dispose() method.
69 | * If the AIR runtime garbage collector disposes of the ExtensionContext instance, the runtime also calls ContextFinalizer().
70 | */
71 | void ContextFinalizer(FREContext ctx);
72 |
73 | /* This is a sample function that is being included as part of this template.
74 | *
75 | * Users of this template are expected to change this and add similar functions
76 | * to be able to call the native functions in the ANE from their ActionScript code
77 | */
78 | ANE_FUNCTION(isSupported);
79 |
--------------------------------------------------------------------------------
/AIR Native Extension/Basic.xctemplate/TemplateInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Kind
6 | Xcode.Xcode3.ProjectTemplateUnitKind
7 | Identifier
8 | com.divij.ane.unit.basic
9 | Options
10 |
11 |
12 | Identifier
13 | productName
14 | Required
15 |
16 | Name
17 | Extension Name
18 | NotPersisted
19 |
20 | Description
21 | Your extension's name.
22 | EmptyReplacement
23 | ExtensionName
24 | Type
25 | text
26 |
27 |
28 | Identifier
29 | extensionIdentifierPrefix
30 | Required
31 |
32 | Name
33 | Company Identifier Prefix
34 | Description
35 | Your company's extension identifier prefix.
36 | EmptyReplacement
37 | com.yourcompany
38 | Type
39 | text
40 |
41 |
42 | Identifier
43 | bundleIdentifier
44 | Name
45 | Extension Identifier
46 | NotPersisted
47 |
48 | Description
49 | Your extension identifier.
50 | Default
51 | ___VARIABLE_extensionIdentifierPrefix:bundleIdentifier___.___VARIABLE_productName:RFC1034Identifier___
52 | Type
53 | static
54 |
55 |
56 | Project
57 |
58 | SharedSettings
59 |
60 | GCC_C_LANGUAGE_STANDARD
61 | gnu99
62 | GCC_WARN_ABOUT_RETURN_TYPE
63 | YES
64 | GCC_WARN_UNUSED_VARIABLE
65 | YES
66 | GCC_WARN_ABOUT_MISSING_PROTOTYPES
67 | YES
68 | ALWAYS_SEARCH_USER_PATHS
69 | NO
70 |
71 | Configurations
72 |
73 | Debug
74 |
75 | GCC_OPTIMIZATION_LEVEL
76 | 0
77 | GCC_PREPROCESSOR_DEFINITIONS
78 | DEBUG=1 $(inherited)
79 | GCC_SYMBOLS_PRIVATE_EXTERN
80 | NO
81 | COPY_PHASE_STRIP
82 | NO
83 | GCC_DYNAMIC_NO_PIC
84 | NO
85 |
86 | Release
87 |
88 | COPY_PHASE_STRIP
89 | YES
90 |
91 |
92 |
93 | Targets
94 |
95 |
96 | Name
97 | ___PACKAGENAME___
98 | SharedSettings
99 |
100 | PRODUCT_NAME
101 | $(TARGET_NAME)
102 |
103 | Configurations
104 |
105 | Debug
106 |
107 | Release
108 |
109 |
110 |
111 |
112 | Definitions
113 |
114 | *:comments
115 | //
116 | // ___FILENAME___
117 | // ___PACKAGENAME___
118 | //
119 | // Created by ___FULLUSERNAME___ on ___DATE___.
120 | // Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
121 | //
122 |
123 | *:import:*
124 | #import "___*___"
125 |
126 | *:*:importFoundation
127 | #import <Foundation/Foundation.h>
128 |
129 | ___PACKAGENAME___-Prefix.pch
130 |
131 | Beginning
132 | //
133 | // Prefix header for all source files of the '___PACKAGENAME___' target in the '___PACKAGENAME___' project
134 | //
135 |
136 | Group
137 | Supporting Files
138 | TargetIndices
139 |
140 |
141 | ___PACKAGENAME___-Prefix.pch:objC
142 |
143 | Beginning
144 | #ifdef __OBJC__
145 | End
146 | #endif
147 | Indent
148 | 1
149 |
150 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/___PACKAGENAMEASIDENTIFIER___.m:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright (c) 2012, DIVIJ KUMAR
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | The views and conclusions contained in the software and documentation are those
27 | of the authors and should not be interpreted as representing official policies,
28 | either expressed or implied, of the FreeBSD Project.
29 |
30 |
31 | */
32 |
33 | /*
34 | * ___FILENAME___
35 | * ___PACKAGENAME___
36 | *
37 | * Created by ___FULLUSERNAME___ on ___DATE___.
38 | * Copyright (c) ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.
39 | */
40 |
41 | #import "___FILEBASENAME___.h"
42 |
43 | /* ___VARIABLE_productName:RFC1034Identifier___ExtInitializer()
44 | * The extension initializer is called the first time the ActionScript side of the extension
45 | * calls ExtensionContext.createExtensionContext() for any context.
46 | *
47 | * Please note: this should be same as the specified in the extension.xml
48 | */
49 | void ___VARIABLE_productName:RFC1034Identifier___ExtInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet)
50 | {
51 | NSLog(@"Entering ___VARIABLE_productName:RFC1034Identifier___ExtInitializer()");
52 |
53 | *extDataToSet = NULL;
54 | *ctxInitializerToSet = &ContextInitializer;
55 | *ctxFinalizerToSet = &ContextFinalizer;
56 |
57 | NSLog(@"Exiting ___VARIABLE_productName:RFC1034Identifier___ExtInitializer()");
58 | }
59 |
60 | /* ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer()
61 | * The extension finalizer is called when the runtime unloads the extension. However, it may not always called.
62 | *
63 | * Please note: this should be same as the specified in the extension.xml
64 | */
65 | void ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer(void* extData)
66 | {
67 | NSLog(@"Entering ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer()");
68 |
69 | // Nothing to clean up.
70 | NSLog(@"Exiting ___VARIABLE_productName:RFC1034Identifier___ExtFinalizer()");
71 | return;
72 | }
73 |
74 | /* ContextInitializer()
75 | * The context initializer is called when the runtime creates the extension context instance.
76 | */
77 | void ContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet)
78 | {
79 | NSLog(@"Entering ContextInitializer()");
80 |
81 | /* The following code describes the functions that are exposed by this native extension to the ActionScript code.
82 | */
83 | static FRENamedFunction func[] =
84 | {
85 | MAP_FUNCTION(isSupported, NULL),
86 | };
87 |
88 | *numFunctionsToTest = sizeof(func) / sizeof(FRENamedFunction);
89 | *functionsToSet = func;
90 |
91 | NSLog(@"Exiting ContextInitializer()");
92 | }
93 |
94 | /* ContextFinalizer()
95 | * The context finalizer is called when the extension's ActionScript code
96 | * calls the ExtensionContext instance's dispose() method.
97 | * If the AIR runtime garbage collector disposes of the ExtensionContext instance, the runtime also calls ContextFinalizer().
98 | */
99 | void ContextFinalizer(FREContext ctx)
100 | {
101 | NSLog(@"Entering ContextFinalizer()");
102 |
103 | // Nothing to clean up.
104 | NSLog(@"Exiting ContextFinalizer()");
105 | return;
106 | }
107 |
108 |
109 | /* This is a TEST function that is being included as part of this template.
110 | *
111 | * Users of this template are expected to change this and add similar functions
112 | * to be able to call the native functions in the ANE from their ActionScript code
113 | */
114 | ANE_FUNCTION(isSupported)
115 | {
116 | NSLog(@"Entering IsSupported()");
117 |
118 | FREObject fo;
119 |
120 | FREResult aResult = FRENewObjectFromBool(YES, &fo);
121 | if (aResult == FRE_OK)
122 | {
123 | NSLog(@"Result = %d", aResult);
124 | }
125 | else
126 | {
127 | NSLog(@"Result = %d", aResult);
128 | }
129 |
130 | NSLog(@"Exiting IsSupported()");
131 | return fo;
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | xcode-template-ane
2 | ==================
3 |
4 | This repository contains an XCode template that can be used to create AIR native extensions or ANEs for iOS from within XCode.
5 |
6 | This README refers to some screenshots which may not appear if you are reading it on github. To read this README with the screenshots, please go to
7 | https://github.com/divijkumar/xcode-template-ane/wiki
8 |
9 |
10 | Using XCode templates for creating ANEs for iOS
11 | ===============================================
12 |
13 | In AIR 3, Adobe introduced Native Extensions which provides Flash & AIR developers the capability to extend the AIR runtime. The native extensions mechanism allows one to write native code, wrap it with an ActionScript API and then use it with the rest of the ActionScript code inside of an AIR app.
14 |
15 | Some background about Native Extensions
16 | ---------------------------------------
17 |
18 | The following Adobe devnet articles are extremely useful if you want to know more about Native Extensions.
19 |
20 | http://www.adobe.com/devnet/air/native-extensions-for-air.html
21 |
22 | http://www.adobe.com/devnet/air/articles/transferring-data-ane-ios-pt1.html
23 |
24 | http://www.adobe.com/devnet/air/articles/extending-air.html
25 |
26 | One of the problems faced by developers working on native extensions, is that creating a native extension involves too many steps and there is no seamless integration with the native IDE (which is XCode for iOS AIR Native Extensions).
27 |
28 | Here, I am providing an XCode4 project template for iOS that helps Flash developers in getting started with writing native extensions.
29 |
30 | Before I begin, let me re-iterate that for writing an AIR application that uses a native extension one needs to create the following.
31 |
32 | 1. An ActionScript library (or swc) which contains the ActionScript code which calls into the native code.
33 | 2. The native code: On iOS one needs to create a CocoaTouch static library containing the native code which is then combined with the SWC (in step 1) and packaged into an ANE (AIR Native Extension) using the ADT tool.
34 | 3. The AIR app which uses the ANE generated in step 2.
35 |
36 | This XCode4 project template for creating ANEs for iOS will ease step 2.
37 |
38 | Installing and using the ANE XCode Project template
39 | ---------------------------------------------------
40 |
41 | Please ensure that you have XCode4 with iOS5 installed. Also its preferable to close XCode now.
42 |
43 | 1. In the attached zip (AIR Native Extension.zip) there is a bash script "install_templates.sh". From the command line:
44 |
45 | $ ./install_templates.sh
46 | This will copy the XCode4 project templates for creating AIR Native Extensions for iOS to the relevant folder in the user's home directory, from where XCode will load them when launched.
47 | 2. Now launch XCode, click File->New->New Project (Command+Shift+N). You would see a new entry for "AIR Native Extension" under iOS:
48 | [[AIR Native Extension/screenshots/new_project.png]]
49 | 3. Click Next and you would see the following options for configuring the XCode project.
50 | [[AIR Native Extension/screenshots/options.png]]
51 | * The first field is the name of the extension. Please be careful not to use any special characters like /, \, _, -, +, =, !, @, #, $, %, ^, &, *, (, ), etc.
52 | * The second field is a company prefix. Please be careful not to use any special characters like /, \, _, -, +, =, !, @, #, $, %, ^, &, *, (, ), etc.
53 | * The third field is a static field containing the extension identifier which is formed by combining the first and second fields. Please note that the extension identifier mentioned here should be the same as the one specified in the application descriptor of the AIR app that will use this ANE. If a special charater is used in the first or the second fields, then, it will be converted to a '-'.
54 | * The fourth field is the complete path to the AIR SDK. (Please ensure that you provide a complete path, without any "~" for HOME dir). The path provided here should be such that, /bin/adt exists. There is a small quirk that you'd notice here. Even though you provide the complete path to the AIR sdk, the initial "/" vanishes as soon as you tab out of this field. This will be taken care of, so you may safely ignore this.
55 | * The fifth field is the complete path to the SWC or the ActionScript library file. This is essentially the ActionScript part of your native extension. Here again as soon as you tab out of this field, the initial "/" will vanish. You may ignore this safely.
56 | 4. Click Next and you would be asked to select a folder where you want to create your XCode project and keep your native code.
57 | 5. Click Next and XCode would create a project for you.
58 | [[AIR Native Extension/screenshots/created_project.png]]
59 |
60 |
61 | Understanding the generated project ...
62 | ---------------------------------------
63 |
64 | The project file that is generated contains a source file, a header file and a few supporting files. Lets go over the Project files one by one.
65 |
66 | * Source and Header file: These contain four basic functions namely ExtInitializer, ExtFinalizer, ContextInitializer and ContextFinalizer. These functions are needed for any ANE which the template has already done for you. There is also a fifth function "IsSupported". This is being provided purely to help you get started with writing and exposing native functions that can be called from ActionScript.
67 | * extension.xml: This file contains the extension identifier and the extension's initialize (ExtInitializer)and finalize (ExtFinalizer) functions. PLEASE NOTE: If you changed the names of the extension's initializer and finalizer functions in your implementation, then they need to be changed here as well.
68 | * generateANE.sh: As the name suggests, this script is used to generate the ANE file.`
69 | * platformoptions.xml: More about this later.
70 | * Targets: The project contains two targets namely, PACKAGENAME and PACKAGENAME.ane. The first target creates a static library. The second one generates an ANE, by internally invoking the ADT command and uses the static library, extension.xml and the native extension SWC.
71 | For the Debug configuration, the ANE file will be generated in $HOME/Library/Developer/XCode/DerivedData/PROJECTNAME-xxxxxxxxxxxxxxxxxxxxxxxxxxx/Build/Products/Debug-iphoneos/
72 |
73 | This ANE may now be used in your AIR app. You may read more on how to do this at
74 | http://help.adobe.com/en_US/air/extensions/WSf268776665d7970d-2e74ffb4130044f3619-7fff.html#WSdb11516da818ea8d49ce0fe713341ed67cf-7fff
75 |
76 | Specifying additional linker options ...
77 | ----------------------------------------
78 | When you write your ANE and link it in your AIR app, the toolchain provided as part of the AIR SDK by default links the ANE against some of the iOS frameworks. However, if your native code needs to link against a framework that is not included in the default list, then you would see a linker error when you try to create your AIR app. You can specify additional linker options via the platformoptions.xml file while creating you ANE. Please refer to
79 | http://help.adobe.com/en_US/air/extensions/WSf268776665d7970d-2e74ffb4130044f3619-7fff.html#WSdb11516da818ea8d49ce0fe713341ed67cf-7fff
80 | for more details.
81 |
82 | Packaging resources with the ANE ...
83 | ------------------------------------
84 |
85 | If there are certain resource files that you want to package in your ANE apart from the native code, this can be done my modifying the generateANE.sh script. you would need to modify the ADT command that is towards the end in the generateANE.sh script.
86 |
87 | Please refer to
88 | http://www.adobe.com/devnet/air/articles/extending-air.html
89 | for more details.
90 |
91 | Feedback ...
92 | ------------
93 |
94 | I hope you find the xcode project template for ANEs on iOS useful and it helps in making the process of writing ANEs simpler for you. Do let me know if you find any bugs.
95 |
96 |
--------------------------------------------------------------------------------
/AIR Native Extension/AIR Native Extension for iOS.xctemplate/TemplateInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ancestors
6 |
7 | com.divij.ane.unit.basic
8 | com.divij.ane.unit.iOSBasic
9 |
10 | Concrete
11 |
12 | Definitions
13 |
14 | ___PACKAGENAMEASIDENTIFIER___.h
15 |
16 | Path
17 | ___PACKAGENAMEASIDENTIFIER___.h
18 |
19 | ___PACKAGENAMEASIDENTIFIER___.m
20 |
21 | Path
22 | ___PACKAGENAMEASIDENTIFIER___.m
23 |
24 | extension.xml
25 |
26 | Group
27 |
28 | Supporting Files
29 |
30 | Path
31 | ./extension.xml
32 | PathType
33 | Group
34 |
35 | platformoptions.xml
36 |
37 | Group
38 |
39 | Supporting Files
40 |
41 | Path
42 | ./platformoptions.xml
43 | PathType
44 | Group
45 |
46 | generateANE.sh
47 |
48 | Group
49 |
50 | Supporting Files
51 |
52 | Path
53 | ./generateANE.sh
54 | PathType
55 | Group
56 |
57 | debugIPA.sh
58 |
59 | Group
60 |
61 | Supporting Files
62 |
63 | Path
64 | ./debugIPA.sh
65 | PathType
66 | Group
67 |
68 | ___PACKAGENAME___-Prefix.pch:objC:importFoundation
69 | #import <Foundation/Foundation.h>
70 |
71 |
72 | Description
73 | This template builds an Adobe AIR native extension for iOS
74 | Identifier
75 | com.divij.ane.cocoatouch
76 | Kind
77 | Xcode.Xcode3.ProjectTemplateUnitKind
78 | Nodes
79 |
80 | ___PACKAGENAME___-Prefix.pch:objC:importFoundation
81 | ___PACKAGENAMEASIDENTIFIER___.h
82 | ___PACKAGENAMEASIDENTIFIER___.m
83 | extension.xml
84 | platformoptions.xml
85 | generateANE.sh
86 | debugIPA.sh
87 |
88 | Options
89 |
90 |
91 | Identifier
92 | airSDKPath
93 | Required
94 |
95 | Name
96 | Directory containing the AIR sdk: /
97 | Description
98 | This is the path to the directory containing the AIR SDK
99 | EmptyReplacement
100 | /Applications/Adobe Flash Builder 4.6/sdks/4.6.0/
101 | NotPersisted
102 |
103 | Type
104 | text
105 |
106 |
107 | Identifier
108 | extensionSWC
109 | Required
110 |
111 | Name
112 | Native extension's swc file (optional): /
113 | Description
114 | This is the native extension's swc file
115 | EmptyReplacement
116 |
117 | NotPersisted
118 |
119 | Type
120 | text
121 |
122 |
123 | Project
124 |
125 | SharedSettings
126 |
127 | CODE_SIGN_IDENTITY[sdk=iphoneos*]
128 | iPhone Developer
129 | GCC_ENABLE_CPP_EXCEPTIONS
130 | NO
131 | GCC_ENABLE_OBJC_EXCEPTIONS
132 | NO
133 |
134 | Configurations
135 |
136 | Debug
137 |
138 | USER_HEADER_SEARCH_PATHS
139 | /___VARIABLE_airSDKPath___/include/
140 |
141 | Release
142 |
143 | USER_HEADER_SEARCH_PATHS
144 | /___VARIABLE_airSDKPath___/include/
145 |
146 |
147 |
148 | Targets
149 |
150 |
151 | BuildPhases
152 |
153 |
154 | Class
155 | Sources
156 |
157 |
158 | Class
159 | Frameworks
160 |
161 |
162 | Class
163 | Headers
164 |
165 |
166 | Frameworks
167 |
168 | Foundation
169 | CoreFoundation
170 | UIKit
171 | MobileCoreServices
172 | CoreGraphics
173 | SystemConfiguration
174 | AudioToolbox
175 | CFNetwork
176 | QuartzCore
177 | OpenGLES
178 | CoreLocation
179 | CoreMedia
180 | CoreVideo
181 | AVFoundation
182 | Security
183 |
184 | ProductType
185 | com.apple.product-type.library.static
186 | SharedSettings
187 |
188 | DSTROOT
189 | /tmp/___PACKAGENAMEASIDENTIFIER___.dst
190 | GCC_PRECOMPILE_PREFIX_HEADER
191 | YES
192 | GCC_PREFIX_HEADER
193 | ___PACKAGENAME___/___PACKAGENAME___-Prefix.pch
194 | OTHER_LDFLAGS
195 | -ObjC
196 | SKIP_INSTALL
197 | YES
198 |
199 |
200 |
201 | Name
202 | ___PACKAGENAME___.ane
203 | BuildPhases
204 |
205 |
206 | Class
207 | ShellScript
208 | ShellPath
209 | /bin/bash
210 | ShellScript
211 |
212 | chmod 755 "$PROJECT_DIR/$PROJECT_NAME/generateANE.sh"
213 | "$PROJECT_DIR/$PROJECT_NAME/generateANE.sh"
214 |
215 |
216 |
217 | ProductType
218 | com.apple.product-type.library.static
219 | Dependencies
220 |
221 | 0
222 |
223 | SharedSettings
224 |
225 | PRODUCT_NAME
226 | ___PACKAGENAME___
227 | EXECUTABLE_PREFIX
228 |
229 | EXECUTABLE_EXTENSION
230 | ane
231 | NATIVEEXTENSION_SWC
232 | /___VARIABLE_extensionSWC___
233 | AIR_SDK_PATH
234 | /___VARIABLE_airSDKPath___
235 |
236 |
237 |
238 | Name
239 | Debug___PACKAGENAME___AIRApp
240 | BuildPhases
241 |
242 |
243 | Class
244 | ShellScript
245 | ShellPath
246 | /bin/bash
247 | ShellScript
248 |
249 | chmod 755 "$PROJECT_DIR/$PROJECT_NAME/debugIPA.sh"
250 | "$PROJECT_DIR/$PROJECT_NAME/debugIPA.sh"
251 |
252 |
253 |
254 | ProductType
255 | com.apple.product-type.application
256 | Dependencies
257 |
258 | 1
259 |
260 | SharedSettings
261 |
262 | PRODUCT_NAME
263 | Debug___PACKAGENAME___AIRApp
264 | NATIVEEXTENSION_SWC
265 | /___VARIABLE_extensionSWC___
266 | AIR_SDK_PATH
267 | /___VARIABLE_airSDKPath___
268 |
269 |
270 |
271 |
272 |
273 |
--------------------------------------------------------------------------------