[TIMOB-19740] xcdatamodel file not included when building application
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Critical |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 4.1.1 |
Fix Version/s | n/a |
Components | iOS |
Labels | Community, engArch |
Reporter | Jim Villa |
Assignee | Unknown |
Created | 2015-10-14T12:38:00.000+0000 |
Updated | 2019-12-13T17:28:28.000+0000 |
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.
Hi [~jamesavilla] Could you please show me a simple sample code that reproduces the issue? Not your full application.
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.
Could you please provide a full update on the status of the issue, I haven't received any feedback for a few weeks now.
[~jamesavilla], take a look at [this guide](http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Project-section-43288810_iOSModuleProject-BundleModuleAssets)
@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.
[~jamesavilla] We don't have support for adding files to the Xcode project yet. I can see Titanium supporting this someday. In 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:
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, callcallback()
and the Xcode project will be written to disk. I 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. Hope this helps.Just had to fix this.
Problem was:
- I have an Alloy project, with an extension. - Inside the extension there's a Core Data Model "file"xcmodeld
- Thatxcmodeld
is correctly copied to the generated Xcode project - Thexcmodeld
is NOT added to the Compile Sources Build Phase of the Share Extension target. Instead you'll see an empty rowFix for the problem
- adding thexcmodeld
to the targetHow I did this
1. Add a plugin definition to yourtiapp.xml
2. the idea is that using that plugin we're going to manually add the missing reference to our target 3. create a plugin in your project with this structure: {noformat} plugins/core-data-fix └── 0.1 └── hooks ├── fix-core-data.js └── fix-core-data.rb {noformat} You should have the plugins directory with alloy inside. 4. Your fix-core-data.js file is a hook that will launch before the Xcode project starts building. Should contain something like:
5. To fix our target I'll use xcodeproj, which is part of CocoaPods. So install CocoaPods if you don't have them already.
That's all!
Environment:
- SDK 7.0.2.GA - Xcode 9.2 - macOS 10.13.3 High Sierra - cocoa pods 1.4.0