知识库 / IOS开发 / 详情
如何设置开发环境?
如何设置开发环境?
IOS开发|大少爷|2017-07-27 10:20
回答:

1、 运行控件例子

1.1、 安装解压控件Xcode开发包

从我们官网下载MxDraw6.0iOs(20160923)TryVersion.exe文件是个 windows  rar自解压缩包,在Windows系统上,双击它解压,得到所有例子文件,开发库文件,如下:

1.png 

 

把解压的目录,拷到MAC电脑上。

1.2、 运行控件自带的例子

 

运行Xcode软件,打开控件例子,SRC\MxDraw6.0\Ios\Test\Test.xcodeproj,如:

 1.png

 

目前控件提供的开发包,只有真机运行的开发库,所以需要在MAC电脑上,连接iPhone手机,然后选择它,点运行即可。

 

 1.png

 

2、 新建工程使用控件

2.1、 新建iOS工程

运行Xcode软件,点新建工程,如下:

 1.png

点击:Next按钮,输入工程名MyTest,然后Next

 

 1.png

工程路径选择控件安装目录下的Ios目录:

 1.png

 

点击Create 创建工程完成

 

2.2、 工程设置 

设置 Other Linker Flags 增加连接设置 ,如下:

-lsisl -lTD_Alloc -lTD_Root -lTD_DbRoot -lTD_Db -lTD_Ge -lTD_Gs -lTD_Gi -lTD_SpatialIndex -lTD_ExamplesCommon -lRecomputeDimBlock -lRasterProcessor -lModelerGeometry -lModelerCommands -lRxRasterServices -lTD_Br -lTD_BrepRenderer -lTD_AcisBuilder -lTD_PdfExport -lTD_PDFToolkit -lstsflib -lqpdf -lsisl -lpcre

如下抓图:

1.png 

 

设置  Library Search Paths 库文件搜索路径 ,如下:

$(SRCROOT)/../../../3rdparty/ODA/lib/iphone $(SRCROOT)/../../../MxDraw6.0/prebuilt/iphone/release

如下抓图:

 1.png

 

设置 User Header Search Paths 头文件搜索路径,如下:

$(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d $(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos $(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/external $(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos/platform $(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos/platform/ios $(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/cocos/editor-support $(SRCROOT)/../../../3rdparty/cocos2dx/cocos2d/external/glfw3/include/mac $(SRCROOT)/../../MxInc

如下抓图:

 1.png

设置C语库使用:

 

 1.png

设置C++库使用:

 1.png

 

设置 C++语言宏定义:

Debug定义:

DEBUG=1 $(inherited) CC_TARGET_OS_IPHONE USE_FILE32API COCOS2D_DEBUG=1 CC_ENABLE_CHIPMUNK_INTEGRATION=1 _MX_MACOSX _MXDRAW_SUPPORT_DWG

 

Release定义:

CC_TARGET_OS_IPHONE USE_FILE32API COCOS2D_DEBUG=0 CC_ENABLE_CHIPMUNK_INTEGRATION=1 _MX_MACOSX _MXDRAW_SUPPORT_DWG

 

抓图如下:

1.png 

 

禁用Bitcode

 

 1.png

增加连需要库文件,在SRC\MxDraw6.0\prebuilt\iphone\release目录下,

libcocos2d iOS.a  libMxArx60iOS.a libMxBase60iOs.a libMxBaseEx60iOs.a libMxDraw60iOS.a libMxDwg60iOS.a libMxFile60iOS.a libMxGe60iOS.a  libMxKernel60iOS.a libMxPlatform60 IOS.a

 

如下图:

 

 1.png

 

 1.png

2.3、 增加梦想文件

拷贝SRC\MxDraw6.0\Ios\Test\fonts目录,到 SRC\MxDraw6.0\Ios\MyTest\fonts

拷贝SRC\MxDraw6.0\Ios\Test\mxdrawui目录,到 SRC\MxDraw6.0\Ios\MyTest\mxdrawui

font目录和mxdrawui目录当前资源增加 Xcode工程中,如下:

 1.png

 

拷贝SRC\MxDraw6.0\Ios\Test\Test\code目录,到SRC\MxDraw6.0\Ios\MyTest\MyTest\code目录。

在工程上,鼠标右键,在弹出菜单 上,点击Add Files to "MyTest"”,把code下的文件增加到当前工程,如下:

 

 1.png

把文件ViewController.m改名为ViewController.mm,并在Xcode工程中,删除ViewController.m文件的引用,然后增加ViewController.mm

 

禁用新增加的ARC功能,使用-fno-objc-arc标志,如下:

 

 1.png

2.4、 调用梦想CAD

 

在新建的工程 UI增加一个按钮,并在按钮事件响应里调用如下代码,显示MxCAD

 

修改ViewController.mm文件:

#import "platform/ios/CCEAGLView-ios.h"

#import "cocos2d.h"

#import "mxcode/MxAppDelegate.h"

#import "mxcode/RootViewController.h"

RootViewController* viewController = nullptr;

CCEAGLView *eaglView = nullptr;

static MxAppDelegate s_sharedApplication;

 

在按钮点击事件里,显示 MxCAD代码:

- (IBAction)click:(UIButton *)sender {

    

    if(viewController == nullptr)

    {

        

        cocos2d::Application *app = cocos2d::Application::getInstance();

        s_sharedApplication.InitMxProtocol();

        app->initGLContextAttrs();

        cocos2d::GLViewImpl::convertAttrs();

 

        eaglView = [CCEAGLView viewWithFrame: [UIScreen mainScreen].bounds

                                 pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat

                                 depthFormat: cocos2d::GLViewImpl::_depthFormat

                          preserveBackbuffer: NO

                                  sharegroup: nil

                               multiSampling: NO

                             numberOfSamples: 4 ];

        

 

        [eaglView setMultipleTouchEnabled:YES];

        

       

        viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];

        viewController.wantsFullScreenLayout = YES;

        viewController.view = eaglView;

        

     

        cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);

        cocos2d::Director::getInstance()->setOpenGLView(glview);

        

        

        app->run();

        

        cocos2d::Director::getInstance()->getEventDispatcher()->addCustomEventListener("returnCAD", [=](cocos2d::EventCustom* eve)

                                                                                       {

                                                                                           //call you return ;

                                                                                           

                                                                                           

                                                                                           [self present];

                                                                                           

                                                                                       });

        

    }

    [self presentViewController:viewController animated:YES completion:nil];

}

 

 

所有工作已经完成,再在可以编译运行了。

 


相关问题
梦想CAD是专业的CAD插件(控件),可轻松在网页、手机及BS/CS程序中浏览编辑DWG文件,不需安装AutoCAD即可运行。经十余年累积已非常稳定可靠,有关键的空间搜索算法,并使用汇编优化,可同时处理50万级实体,有非常高的图形显示和处理效率。
技术服务
TEL:400-888-5703
185-8173-1060
客服I QQ: 3570505660
技术I QQ: 827867134
技术II QQ:6884123
产品购买
TEL:156-8136-8971
QQ:710714273
用户交流
控件QQ交流群1:73281982
控件QQ交流群2:112199959
MxCAD软件群 1:515771658
技术I:QQ
827867134
客服I:QQ
3570505660
销售QQ
710714273
联系电话400-888-5703