Browse Source

Working on iOSDeployment

Josh Engebretson 10 years ago
parent
commit
8e1b39707b

+ 1 - 1
CMake/Modules/AtomicMac.cmake

@@ -8,4 +8,4 @@ list (APPEND ATOMIC_LINK_LIBRARIES GLEW)
 
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -std=gnu++0x")
 
-set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework ForceFeedback -framework IOKit -framework OpenGL -framework CoreServices")
+set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework ForceFeedback -framework IOKit -framework OpenGL -framework CoreServices -framework Security")

+ 8 - 3
Data/AtomicEditor/Resources/EditorData/AtomicEditor/editor/ui/buildsettings_ios.tb.txt

@@ -8,17 +8,17 @@ TBLayout: axis: y, distribution: gravity, position: left
 	TBLayout: distribution: gravity
 		TBTextField: text: "App Package:"
 		TBLayout: gravity: left right, distribution-position: right bottom
-			TBEditField: id: app_package, autofocus: 1
+			TBEditField: id: app_package, autofocus: 0
 				lp: min-width: 220
 	TBLayout: distribution: gravity
 		TBTextField: text: "Company Name:"
 		TBLayout: gravity: left right, distribution-position: right bottom
-			TBEditField: id: company_name, autofocus: 1
+			TBEditField: id: company_name, autofocus: 0
 				lp: min-width: 220
 	TBLayout: distribution: gravity
 		TBTextField: text: "Product Name:"
 		TBLayout: gravity: left right, distribution-position: right bottom
-			TBEditField: id: product_name, autofocus: 1
+			TBEditField: id: product_name, autofocus: 0
 				lp: min-width: 220
 	TBSeparator: gravity: left right, skin: AESeparator
 	TBLayout: axis: y, position: left, distribution: gravity
@@ -27,6 +27,11 @@ TBLayout: axis: y, distribution: gravity, position: left
 			TBEditField: id: provision_path, autofocus: 0
 				lp: min-width: 250
 			TBButton: text: "Choose" id: choose_provision_path
+		TBLayout: distribution: gravity
+			TBTextField: text: "AppID Prefix:"
+			TBLayout: gravity: left right, distribution-position: right bottom
+				TBTextField: id: appid_prefix
+					lp: min-width: 220
 	TBSeparator: gravity: left right, skin: AESeparator
 	TBTextField: text: "Icon:"
 	TBLayout: gravity: left right, distribution-position: right bottom

+ 1 - 1
Source/AtomicEditor/CMakeLists.txt

@@ -13,7 +13,7 @@ set (SOURCE_FILES ${SOURCE_FILES} Vendor/nativefiledialog/nfd_common.c)
 
 if (APPLE)
     set (EXE_TYPE MACOSX_BUNDLE)
-    set (SOURCE_FILES ${SOURCE_FILES} Vendor/nativefiledialog/nfd_cocoa.mm Vendor/nativefiledialog/nfd.h)
+    set (SOURCE_FILES ${SOURCE_FILES} Source/Build/BuildIOSUtils.mm Vendor/nativefiledialog/nfd_cocoa.mm Vendor/nativefiledialog/nfd.h)
 else()
     include_directories (${CMAKE_CURRENT_SOURCE_DIR}/Vendor/libcurl/include)
     add_definitions(-DCURL_STATICLIB)

+ 13 - 0
Source/AtomicEditor/Source/Build/BuildIOSUtils.h

@@ -0,0 +1,13 @@
+
+#pragma once
+
+#include <Atomic/Container/Str.h>
+
+using namespace Atomic;
+
+namespace AtomicEditor
+{
+
+String GetMobileProvisionData(const char* cfilename);
+
+}

+ 76 - 0
Source/AtomicEditor/Source/Build/BuildIOSUtils.mm

@@ -0,0 +1,76 @@
+/*
+Portions Copyright (c) 2013 Eugene Solodovnykov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#import <Foundation/Foundation.h>
+#import <Security/Security.h>
+
+#include "AtomicEditor.h"
+#include "BuildIOSUtils.h"
+
+namespace AtomicEditor {
+
+String GetMobileProvisionData(const char* cfilename)
+{
+    CMSDecoderRef decoder = NULL;
+    CFDataRef dataRef = NULL;
+
+    NSString *plistString = nil;
+    //NSDictionary *plist = nil;
+
+    NSString *file = [[NSString alloc]  initWithBytes:cfilename
+                                                      length:strlen(cfilename)
+                                                      encoding:NSUTF8StringEncoding];
+    @try {
+        CMSDecoderCreate(&decoder);
+        NSData *fileData = [NSData dataWithContentsOfFile:file];
+        CMSDecoderUpdateMessage(decoder, fileData.bytes, fileData.length);
+        CMSDecoderFinalizeMessage(decoder);
+        CMSDecoderCopyContent(decoder, &dataRef);
+        plistString = [[[NSString alloc] initWithData:(NSData *)dataRef encoding:NSUTF8StringEncoding] autorelease];
+        //plist = [plistString propertyList];
+    }
+    @catch (NSException *exception) {
+        printf("Could not decode file.\n");
+    }
+    @finally {
+        if (decoder) CFRelease(decoder);
+        if (dataRef) CFRelease(dataRef);
+    }
+
+    String value;
+
+    if (plistString)
+    {
+         value = [plistString UTF8String];
+         [plistString release];
+    }
+
+    [file release];
+
+    return value;
+}
+
+}
+
+
+
+

+ 3 - 0
Source/AtomicEditor/Source/Build/BuildSettings.cpp

@@ -56,6 +56,7 @@ void BuildSettings::Load(rapidjson::Value::Member* jobject)
         ios_.provisionFile = GetStringMember(jios, "provision_file");
         ios_.companyName = GetStringMember(jios, "company_name");
         ios_.productName = GetStringMember(jios, "product_name");
+        ios_.appidPrefix = GetStringMember(jios, "appid_prefix");
     }
     // END IOS ------
 
@@ -105,6 +106,8 @@ void BuildSettings::Save(rapidjson::PrettyWriter<rapidjson::FileStream>& writer)
     writer.String(ios_.companyName.CString());
     writer.String("product_name");
     writer.String(ios_.productName.CString());
+    writer.String("appid_prefix");
+    writer.String(ios_.appidPrefix.CString());
 
     writer.EndObject();
     // END IOS ------

+ 1 - 0
Source/AtomicEditor/Source/Build/BuildSettings.h

@@ -34,6 +34,7 @@ struct IOSBuildSettings
     String companyName;
     String productName;
     String provisionFile;
+    String appidPrefix;
 };
 
 

+ 71 - 1
Source/AtomicEditor/Source/UI/Modal/UIBuildSettingsIOS.cpp

@@ -3,6 +3,7 @@
 // https://github.com/AtomicGameEngine/AtomicGameEngine
 
 #include "AtomicEditor.h"
+#include <PugiXml/src/pugixml.hpp>
 #include <TurboBadger/tb_layout.h>
 #include <TurboBadger/tb_editfield.h>
 #include <TurboBadger/tb_select.h>
@@ -19,6 +20,7 @@
 #include "Subprocess/AESubprocessSystem.h"
 
 #include "Build/BuildSystem.h"
+#include "Build/BuildIOSUtils.h"
 
 #include "UIBuildSettingsIOS.h"
 
@@ -46,6 +48,9 @@ UIBuildSettingsIOS::UIBuildSettingsIOS(Context* context) :
     provisionPath_ = delegate_->GetWidgetByIDAndType<TBEditField>(TBIDC("provision_path"));
     assert(provisionPath_);
 
+    applicationIDPrefix_ = delegate_->GetWidgetByIDAndType<TBTextField>(TBIDC("appid_prefix"));
+    assert(applicationIDPrefix_);
+
     Refresh();
 }
 
@@ -82,6 +87,11 @@ void UIBuildSettingsIOS::StoreSettings()
     settings.provisionFile = text.CStr();
     text.Clear();
 
+    applicationIDPrefix_->GetText(text);
+    settings.appidPrefix = text.CStr();
+    text.Clear();
+
+
     buildSystem->GetBuildSettings()->SetIOSSettings(settings);
 
 }
@@ -97,6 +107,60 @@ void UIBuildSettingsIOS::Refresh()
     appPackageEdit_->SetText(settings.package.CString());
     productNameEdit_->SetText(settings.productName.CString());
     companyNameEdit_->SetText(settings.companyName.CString());
+    applicationIDPrefix_->SetText(settings.appidPrefix.CString());
+}
+
+bool UIBuildSettingsIOS::ParseProvisionData(const String& provisionFile)
+{
+    String pdata = GetMobileProvisionData(provisionFile.CString());
+
+    if (!pdata.Length())
+        return false;
+
+    pugi::xml_document doc;
+
+    if (!doc.load(pdata.CString()))
+    {
+        return false;
+    }
+
+    String AppIDName;
+    String ApplicationIdentifierPrefix;
+
+    pugi::xml_node dict = doc.document_element().child("dict");
+
+    for (pugi::xml_node key = dict.child("key"); key; key = key.next_sibling("key"))
+    {
+        String keyName = key.child_value();
+
+        if (keyName == "AppIDName")
+        {
+            pugi::xml_node value = key.next_sibling();
+            if (!strcmp(value.name(), "string"))
+                AppIDName = value.child_value();
+        }
+        else if (keyName == "ApplicationIdentifierPrefix")
+        {
+            pugi::xml_node array = key.next_sibling();
+            if (!strcmp(array.name(), "array"))
+            {
+                pugi::xml_node value = array.first_child();
+                if (!strcmp(value.name(), "string"))
+                    ApplicationIdentifierPrefix = value.child_value();
+            }
+
+        }
+    }
+
+    if (!ApplicationIdentifierPrefix.Length())
+        return false;
+
+    applicationIDPrefix_->SetText(ApplicationIdentifierPrefix.CString());
+    provisionPath_->SetText(provisionFile.CString());
+
+    return true;
+
+
 }
 
 bool UIBuildSettingsIOS::OnEvent(const TBWidgetEvent &ev)
@@ -109,7 +173,13 @@ bool UIBuildSettingsIOS::OnEvent(const TBWidgetEvent &ev)
         if (ev.target->GetID() == TBIDC("choose_provision_path"))
         {
             String path = utils->GetMobileProvisionPath();
-            provisionPath_->SetText(path.CString());
+            if (path.Length())
+            {
+                if (!ParseProvisionData(path))
+                    editor->PostModalError("Mobile Provision Error", "Could not parse mobile provision");
+                else
+                    StoreSettings();
+            }
             return true;
         }
     }

+ 4 - 0
Source/AtomicEditor/Source/UI/Modal/UIBuildSettingsIOS.h

@@ -13,6 +13,7 @@ namespace tb
 {
 class TBLayout;
 class TBEditField;
+class TBTextField;
 class TBSelectDropdown;
 }
 
@@ -36,6 +37,8 @@ public:
 
 private:
 
+    bool ParseProvisionData(const String& provisionFile);
+
     String targetOutput_;
     HashMap<unsigned, String> targetLookup_;
 
@@ -45,6 +48,7 @@ private:
     TBEditField* companyNameEdit_;
 
     TBEditField* provisionPath_;
+    TBTextField* applicationIDPrefix_;
 
 };