JSON Parse Error: Unexpected Identifier "undefined" in Titanium-based iOS Application
occam-r opened this issue · 2 comments
I have searched and made sure there are no existing issues for the issue I am filing
- I have searched the existing issues
Description
I am facing an issue while running my Titanium-based iOS application (version 4.4.05) on Titanium SDK 12.1.2.1e3a7d3afb. The app is unable to load the index.json file, which leads to a "SyntaxError: JSON Parse error: Unexpected identifier 'undefined'" during the JSON parsing process.
`Reading stylesheet from: /private/var/containers/Bundle/Application/05C15C26-F859-4066-9F91-C4F956FC95F9/Advisor.app/stylesheet.plist
2023-07-19 11:49:14.794068+0530 Advisor[6841:1971119] [ERROR] Could not load index.json require index, error was File not found
2023-07-19 11:49:14.889741+0530 Advisor[6841:1971119] [INFO] Advisor 4.4.05 (Powered by Titanium 12.1.2.1e3a7d3afb)
2023-07-19 11:49:14.905497+0530 Advisor[6841:1971119] [ERROR] /ti.kernel.js:1073
fileIndex = JSON.parse(json);
^
SyntaxError: JSON Parse error: Unexpected identifier "undefined"
at parse ([native code])
at filenameExists (/ti.kernel.js:1073:33)
at require (/ti.kernel.js:757:36)
at doLoad (/ti.main.js:12870:34)
at loadBootstrapScripts (/ti.main.js:12893:11)
at loadAsync (/ti.main.js:12898:23)
at (/ti.main.js:12916:10)
at load (/ti.kernel.js:634:24)
at (/ti.kernel.js:1107:18)
Foundation 0x00000001cb5531ec _NSDescriptionWithLocaleFunc + 80
CoreFoundation 0x00000001d12c44a4 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 332964
CoreFoundation 0x00000001d12f71d4 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 184
CoreFoundation 0x00000001d12f3aac _CFStringCreateWithFormatAndArgumentsAux2 + 44
TitaniumKit 0x0000000101719ce8 TiLogMessage + 52
TitaniumKit 0x00000001017492e0 -[TiExceptionHandler reportScriptError:] + 60
JavaScriptCore 0x00000001e4e3b11c C9852269-BF5A-3150-AFED-2D50892B6D4B + 4796700
JavaScriptCore 0x00000001e49a9980 C9852269-BF5A-3150-AFED-2D50892B6D4B + 6528
TitaniumKit 0x0000000101729adc -[KrollBridge evalFileOnThread:context:] + 340
TitaniumKit 0x00000001017539e0 -[KrollInvocation invoke:] + 52
TitaniumKit 0x00000001017542e4 -[KrollContext invoke:] + 84
TitaniumKit 0x000000010172a2f4 -[KrollBridge didStartNewContext:] + 1084
TitaniumKit 0x00000001017549bc -[KrollContext main] + 988
libdispatch.dylib 0x0000000101448520 _dispatch_call_block_and_release + 32
libdispatch.dylib 0x000000010144a038 _dispatch_client_callout + 20
libdispatch.dylib 0x000000010145a798 _dispatch_main_queue_drain + 1196
libdispatch.dylib 0x000000010145a2dc _dispatch_main_queue_callback_4CF + 44
CoreFoundation 0x00000001d130bc28 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 625704
CoreFoundation 0x00000001d12ed560 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 501088
CoreFoundation 0x00000001d12f23ec CFRunLoopRunSpecific + 612`
Expected Behavior
Device Container should be generated : Bundle/Application/05C15C26-F859-4066-9F91-C4F956FC95F9/Advisor.app/stylesheet.plist
Actual behavior
Reading stylesheet from: /private/var/containers/Bundle/Application/05C15C26-F859-4066-9F91-C4F956FC95F9/Advisor.app/stylesheet.plist
2023-07-19 11:49:14.794068+0530 Advisor[6841:1971119] [ERROR] Could not load index.json require index, error was File not found
Reproducible sample
/ti.kernel.js:1073
fileIndex = JSON.parse(json);
Steps to reproduce
ti build -p ios
or running its from xCode and connected on connected device.
Platform
iOS
SDK version you are using
12.1.2
Alloy version you are using
2.0.2
hi, did you try the comment I've put in the stackoverflow post? Add a console.log(json)
before your parse line. As the first part of the error says Could not load index.json require index, error was File not found
It seems like you are trying to open the generated Xcode project ("or running its from xCode and connected on connected device.") which is not officially supported. If this really also happens for CLI-based builds, please provide a sample project and we can take a look :)