Xcode iOS build fails
gitmalong opened this issue · comments
System:
Mac OS 10.12.5
Xcode 8.3.2
Swift 3.1
Meteor 1.5
It worked fine to compile the code with meteor
meteor add-platform ios
meteor build .build --server localhost:3785
When I opened the Xcode project in .build/ios it said the Swift code need to be converted to the latest version. I confirmed and the code was converted automatically. After that I tried to compile it with Xcode and got a lot of compile errors:
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleManager.swift:69:13: Initializer for conditional binding must have Optional type, not 'String'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleManager.swift:212:10: Initializer for conditional binding must have Optional type, not '() -> URL'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleManager.swift:267:65: Cannot force unwrap value of non-optional type 'String'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleManager.swift:303:97: Expression resolves to an unused function
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/WebAppLocalServer.swift:93:25: Value of type 'Int' has no member 'uintValue'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/WebAppLocalServer.swift:381:67: Value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'?
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/WebAppLocalServer.swift:457:38: Cannot force unwrap value of non-optional type 'String'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/WebAppLocalServer.swift:490:50: Cannot force unwrap value of non-optional type 'String'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/Asset.swift:6:26: Cannot force unwrap value of non-optional type 'URL'
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleDownloader.swift:162:34: Cannot assign to property: 'URLComponents' is a 'let' constant
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleDownloader.swift:164:34: Cannot assign to property: 'URLComponents' is a 'let' constant
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/AssetBundleDownloader.swift:244:31: Value of type 'Error' has no member 'userInfo'
inkstone/.build/ios/project/Swift.Error:102:16: Did you mean '_userInfo'?
inkstone/.build/ios/project/Inkstone/Plugins/cordova-plugin-meteor-webapp/Utility.swift:80:11: 'getResourceValue(_:forKey:)' is unavailable: Use struct URLResourceValues and URL.setResourceValues(_:) instead
inkstone/.build/ios/project/Foundation.URL:251:17: 'getResourceValue(_:forKey:)' has been explicitly marked unavailable here
It seems to be a common issue with meteor. I'm just testing some suggested solutions.
Thank you, too!
I got the iOS build running 👍
meteor add cordova:cordova-plugin-meteor-webapp@https://github.com/meteor/cordova-plugin-meteor-webapp.git#10d4ddbc907b57c70070e7be4eab44a4b069b966
meteor run ios-device
(Meteor expects a hash for the plugin version. I just took the latest commit.)
In Xcode I added SWIFT_VERSION = 3.0;
to the build settings (adding it to app.xcodeproj/project.pbxproj
should also work).
The app started and is downloading the files right now :-)
Update: The app seems to work fine on my iPhone 6, IOS 10.3.2. Really cool :-)
Hey, that's great that you got it working!
I wonder if it's strictly necessary to use Xcode to build the final app? The Android build script runs meteor build
to produce an Android project but then uses cordova build
to build the final app, and I think something similar could work for iOS. I'd like to get an automated build script working.
Wow. I can't get this approach to work at all. I have no idea what I'm doing!
I ran meteor run ios-device
and got dumped into this GUI that has nothing to do with the actual application that I wrote. There are hundreds of settings in there and I can't find the SWIFT_VERSION
one on the Build Settings page. Is this really how iOS development is supposed to go?
After reading the docs for three hours I got it to work! I was also able to get around both the cordova-plugin-meteor-webapp
issue and the Swift version by updating to a later Meteor.
The app works well, except that I notice that it's a little more awkward to navigate the menus without the Android back button at the bottom of the screen.
Time to see if there's enough interest to warrant getting a yearly Apple developer subscription and putting this app on the iOS app store!
I'm happy you found a reliable solution!
When I ran my last build with the workaround described above I used Meteor 1.5 as well but maybe it didn't work because of all the plugins were not updated.
Yes, I had to update to Meteor 1.5 and also update a few plugins. I also found an important bug in the implementation of one of the plugins that I had to fix in the Xcode project before the final build. Without this fix, the app will work for a while but then crash at some point due to a bug in how background processes are handled.
The latest commit in the repository includes the Meteor release and plugin updates, and the notes.txt file describes the background process fix.