{ "id": "152036", "key": "TIMOB-19740", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2015-10-14T12:38:00.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "Community", "engArch" ], "versions": [ { "id": "16919", "description": "Critical updates", "name": "Release 4.1.1", "archived": true, "released": true, "releaseDate": "2015-07-15" } ], "issuelinks": [], "assignee": null, "updated": "2019-12-13T17:28:28.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "I am having an issue with a module I built. The iOS native module contains a xcdatamodel file which is a database for storing data, this file is not being built with app but if I copy the file to the app after it is built in xcode everything works and file is recognized in app. The problem is when I rebuild it removes the file again, or when I submit to apple store. I know you dont support core data but I just need to know how to include this file in the build process. Provide me with an email address and I can share my dropbox account with the app and module if needed.", "attachment": [], "flagged": false, "summary": "xcdatamodel file not included when building application", "creator": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Mac OS X el capitan, xCode v7", "comment": { "comments": [ { "id": "367016", "author": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hi [~jamesavilla]\r\nCould you please show me a simple sample code that reproduces the issue? Not your full application.", "updateAuthor": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2015-10-16T18:31:14.000+0000", "updated": "2015-10-16T18:31:14.000+0000" }, { "id": "367018", "author": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Please create a new project in appcelerator studio. When you run that new app I need the Xcode project that is built when ran to include the .xcdatamodel file that I sent you previously in the root of the Xcode project.", "updateAuthor": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-10-16T18:47:53.000+0000", "updated": "2015-10-16T18:47:53.000+0000" }, { "id": "369187", "author": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Could you please provide a full update on the status of the issue, I haven't received any feedback for a few weeks now.", "updateAuthor": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-06T15:02:36.000+0000", "updated": "2015-11-06T15:02:36.000+0000" }, { "id": "369447", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "[~jamesavilla], take a look at [this guide|http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Project-section-43288810_iOSModuleProject-BundleModuleAssets]", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-11-09T20:07:03.000+0000", "updated": "2015-11-09T20:07:11.000+0000" }, { "id": "369564", "author": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "body": "@Pedro Enrique I have already tried that. The xcdatamodel file does not get carried over to the built application. Please add the file to your assets folder then build your application and you will see the file does not get built with the application.", "updateAuthor": { "name": "jamesavilla", "key": "jamesavilla", "displayName": "Jim Villa", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-10T17:47:58.000+0000", "updated": "2015-11-10T17:47:58.000+0000" }, { "id": "371850", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "[~jamesavilla] We don't have support for adding files to the Xcode project yet. I can see Titanium supporting this someday.\r\n\r\nIn the meantime, you'll need to make a CLI hook. Start by creating a directory in your module project called \"hooks\". Create a .js file in that hooks folder and add the following:\r\n\r\n{code}\r\n'use strict';\r\n\r\n/** The plugin's identifier */\r\nexports.id = 'com.example.hook';\r\n\r\n/** The Titanium CLI version that this hook is compatible with */\r\nexports.cliVersion = '>=3.2';\r\n\r\n/**\r\n * Initialize the hook.\r\n *\r\n * @param {Object} logger - The logger instance\r\n * @param {Object} config - The CLI config object\r\n * @param {CLI} cli - The CLI instance\r\n * @param {Object} appc - The node-appc library\r\n */\r\nexports.init = function init(logger, config, cli, appc) {\r\n\tcli.on('build.ios.xcodeproject', function (data, callback) {\r\n\t\tconsole.log(data.args[0]);\r\n\t\tcallback();\r\n\t});\r\n};\r\n{code}\r\n\r\n{{data.args\\[0\\]}} will be a JavaScript object containing the Xcode project. You can add file references, groups, and files to build phases to this object. When you're done, call {{callback()}} and the Xcode project will be written to disk.\r\n\r\nI should point out that we don't support this. You can get it to work, but it's not for the faint of heart. You will need to understand the Xcode project file format and the Xcode NPM module (https://www.npmjs.com/package/xcode). This is not straight forward. Just to add a single file, you'll need to add 2-5 entries in various sections of the Xcode project. If you miss one, it won't work.\r\n\r\nHope this helps.", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2015-12-02T02:39:24.000+0000", "updated": "2015-12-02T02:39:24.000+0000" }, { "id": "434775", "author": { "name": "dfreniche", "key": "dfreniche", "displayName": "Diego Freniche", "active": true, "timeZone": "Africa/Ceuta" }, "body": "Just had to fix this. \r\n\r\nh2. Problem was:\r\n- I have an Alloy project, with an extension. \r\n- Inside the extension there's a Core Data Model \"file\" `xcmodeld`\r\n- That `xcmodeld` is correctly copied to the generated Xcode project\r\n- The `xcmodeld` is NOT added to the Compile Sources Build Phase of the Share Extension target. Instead you'll see an empty row\r\n\r\nh2. Fix for the problem\r\n\r\n- adding the `xcmodeld` to the target\r\n\r\nh2. How I did this\r\n\r\n1. Add a plugin definition to your `tiapp.xml`\r\n\r\n{code:java}\r\n\r\n \r\n ti.alloy\r\n\r\n core-data-fix\r\n \r\n \r\n{code}\r\n\r\n2. the idea is that using that plugin we're going to manually add the missing reference to our target\r\n3. create a plugin in your project with this structure:\r\n\r\n{noformat}\r\n\r\nplugins/core-data-fix\r\n└── 0.1\r\n └── hooks\r\n ├── fix-core-data.js\r\n └── fix-core-data.rb\r\n{noformat}\r\n\r\nYou should have the plugins directory with alloy inside.\r\n\r\n4. Your fix-core-data.js file is a hook that will launch before the Xcode project starts building. Should contain something like:\r\n\r\n\r\n{code:javaScript}\r\n\r\n// This hooks to the event \"build.ios.xcodeproject\". When building the generated Xcode project we need to add a reference\r\n// to the Core Data model file inside the Share extension. This is done inside the Ruby script:\r\n// plugins/core-data-fix/0.1/hooks/fix-core-data.rb\r\n\r\nexports.init = function (logger, config, cli, nodeappc) {\r\n cli.on(\"build.ios.xcodeproject\", function (data, callback) {\r\n var child_process = require('child_process');\r\n\r\n // exec: spawns a shell.\r\n child_process.exec('plugins/core-data-fix/0.1/hooks/fix-core-data.rb', function(error, stdout, stderr){\r\n console.log(stdout);\r\n console.log(error);\r\n });\r\n\r\n callback();\r\n });\r\n};\r\n{code}\r\n\r\n5. To fix our target I'll use xcodeproj, which is part of CocoaPods. So install CocoaPods if you don't have them already.\r\n\r\n\r\n{code:ruby}\r\n\r\n#!/usr/bin/env ruby\r\n\r\n# Problem: the extension Projects-Share contains a Core Data Model file that's not correctly added\r\n# to the generated project's extension target.\r\n# The Model Core Data file is correctly copied inside the generated Alloy Xcode project\r\n# This ruby script adds the Model file to the extension target \r\n# Dependencies: xcodeproj gem, which comes bundled with Cocoapods\r\n\r\nrequire 'pathname'\r\nrequire 'xcodeproj'\r\n\r\nclass String\r\n # colorization\r\n def colorize(color_code)\r\n \"\\e[#{color_code}m#{self}\\e[0m\"\r\n end\r\n \r\n def red\r\n colorize(31)\r\n end\r\n \r\n def green\r\n colorize(32)\r\n end\r\n \r\n def yellow\r\n colorize(33)\r\n end\r\n \r\n def blue\r\n colorize(34)\r\n end\r\n \r\n def pink\r\n colorize(35)\r\n end\r\n \r\n def light_blue\r\n colorize(36)\r\n end\r\n end\r\n\r\n\r\npath_to_core_data_model = \"extensions/Projects-Share/Projects-Share/Categories/Core\\ Data/Model.xcdatamodeld/\"\r\n\r\nputs \"************************ BEGIN SCRIPT **********************************\".light_blue\r\nputs path_to_core_data_model.blue\r\nputs \"************************* END SCRIPT ***********************************\".light_blue\r\n\r\npath_to_project = 'build/iphone/Projects.xcodeproj/'\r\n\r\nputs path_to_project\r\n\r\n\r\nproject = Xcodeproj::Project.open(path_to_project)\r\nputs project\r\n\r\ntarget = project.targets.first\r\n\r\nproject.targets.each do |t|\r\n if t.name == \"Projects-Share\"\r\n target = t\r\n break\r\n end\r\nend\r\nputs target\r\n\r\ngroup = project[\"Extensions\"][\"Projects-Share\"][\"Projects-Share\"][\"Categories\"][\"Core Data\"]\r\n\r\nputs group\r\nmodel = group.new_reference('Model.xcdatamodeld')\r\n\r\ntarget.add_file_references([model])\r\nproject.save\r\n{code}\r\n\r\nThat's all!\r\n\r\n\r\nh2. Environment:\r\n\r\n- SDK 7.0.2.GA\r\n- Xcode 9.2\r\n- macOS 10.13.3 High Sierra\r\n- cocoa pods 1.4.0", "updateAuthor": { "name": "dfreniche", "key": "dfreniche", "displayName": "Diego Freniche", "active": true, "timeZone": "Africa/Ceuta" }, "created": "2018-02-22T15:42:31.000+0000", "updated": "2018-02-22T15:58:08.000+0000" } ], "maxResults": 15, "total": 15, "startAt": 0 } } }