简体   繁体   English

从iOS App生成Xcode项目

[英]Generate Xcode Project from iOS App

Is there a way to create an app that generates an Xcode project that a developer can run in Xcode. 有没有一种方法可以创建可生成Xcode项目的应用程序,开发人员可以在Xcode中运行该项目。 Kind of like a code generator. 有点像代码生成器。 I'm trying to look for answers in the web but to no avail. 我正在尝试在网上寻找答案,但无济于事。 I'm also not sure where to start. 我也不知道从哪里开始。 Basically, the app will generate Xcode compatible codes which a developer can use to open to Xcode. 基本上,该应用程序将生成Xcode兼容代码,开发人员可以使用这些代码打开Xcode。

A sample application that's available in the AppStore that offers the same functionality is Interface for iOS. AppStore中提供了一个提供相同功能的示例应用程序是iOS接口。 Link: https://itunes.apple.com/en/app/interface/id360543182?mt=8 链接: https//itunes.apple.com/en/app/interface/id360543182?mt = 8

Another example is Dapp the App Creator: https://itunes.apple.com/au/app/dapp-app-creator-make-learn/id370888555?mt=8 另一个示例是应用程序创建者Dapp: https ://itunes.apple.com/au/app/dapp-app-creator-make-learn/id370888555?mt = 8

From their app description: 从他们的应用说明中:

Xcode Export, Turn Your Mockup into Live Codes Our free cloud based Xcode export service will convert your entire project into an Xcode project in just one single tap. Xcode导出,将您的模型转化为实时代码我们免费的基于云的Xcode导出服务将使您只需单击一下即可将整个项目转换为Xcode项目。

Dapp creates your complete Xcode Project for you - including code, images, videos and Xcode Storyboards! Dapp为您创建了完整的Xcode项目-包括代码,图像,视频和Xcode故事板!

UPDATE: I was thinking of including a zip file of a sample Xcode project template file inside the app that will generate codes that will be used by the template project, edit or add them in the template project, zip and export to Documents folder thru iTunes File Sharing. 更新:我当时正在考虑在应用程序中包含示例Xcode项目模板文件的zip文件,该文件将生成将由模板项目使用的代码,在模板项目中编辑或添加它们,然后通过iTunes压缩并导出到Documents文件夹文件共享。

The app whose link you have posted is just used to create mockups. 您发布其链接的应用程序仅用于创建模型。 It does not generate code. 不会生成代码。

It is not possible to make an app that will generate code that you can later somehow import in xcode and run it. 无法制作将生成代码的应用程序,您以后可以以某种方式将其导入xcode并运行它。

  1. Open Xcode, create a new project, choose Single View Application (or something that best suits what you'll be generating) click create. 打开Xcode,创建一个新项目,选择“单一视图应用程序”(或最适合您生成的内容),然后单击“创建”。

  2. Go to the directory where this project was created, zip it and include it in the project for the App that will do the generating. 转到创建此项目的目录,将其压缩并包含在要进行生成的App的项目中。

  3. When it's time to generate the code, step 1 is to create a working directory and unzip the project to it. 当需要生成代码时,步骤1是创建工作目录并将项目解压缩到该目录。

  4. Generate your classes etc. and put them into the directory where the AppDelegate.h and the other files generated for you from the Single View Application template are. 生成类等,然后将其放入AppDelegate.h和从“单视图应用程序”模板为您生成的其他文件所在的目录中。

  5. Open the xcodeproj package, at the root level there will be a file called project.pbxproj, read it into memory 打开xcodeproj包,在根目录下将有一个名为project.pbxproj的文件,将其读入内存

  6. Modify the project.pbxproj to include the generated code files, there will be a section called PBXFileReference where you can do this. 修改project.pbxproj以包括生成的代码文件,将有一个名为PBXFileReference的部分可以执行此操作。

Here's an example PBXFileReference section from a project I had handy: 这是我方便的项目中的示例PBXFileReference部分:

    /* Begin PBXFileReference section */
        DB6C03BA1B148F56007554E7 /* UIAlertController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIAlertController.app; sourceTree = BUILT_PRODUCTS_DIR; };
        DB6C03BE1B148F56007554E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
        DB6C03BF1B148F56007554E7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
        DB6C03C11B148F56007554E7 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
        DB6C03C21B148F56007554E7 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
        DB6C03C41B148F56007554E7 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
        DB6C03C51B148F56007554E7 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
        DB6C03C81B148F56007554E7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
        DB6C03CA1B148F56007554E7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
        DB6C03CD1B148F56007554E7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
        DB6C03D31B148F56007554E7 /* UIAlertControllerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIAlertControllerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
        DB6C03D81B148F56007554E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
        DB6C03D91B148F56007554E7 /* UIAlertControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIAlertControllerTests.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
  1. Write your changes to project.pbxproj (I imagine there may be more than simply the PBXFileReference depending on the complexity of what you're trying to achieve). 将您的更改写入project.pbxproj(我想根据您要实现的复杂性,可能不仅仅是PBXFileReference)。

  2. Zip the contents of your working directory for the project and email or UIDocumentInteractionController them out to the user. 将项目的工作目录内容压缩,然后通过电子邮件或UIDocumentInteractionController将其发送给用户。

This is a good article on the pbxproj file: http://danwright.info/blog/2010/10/xcode-pbxproject-files/ 这是有关pbxproj文件的好文章: http ://danwright.info/blog/2010/10/xcode-pbxproject-files/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM