Kitura Swift应用程序未在Heroku

时间:2017-08-14 01:45:34

标签: swift heroku kitura

在本地创建Kitura应用程序并成功编译和构建。但是一段时间后尝试部署到heroku时,我得到以下输出:

/tmp/build_cbc1c98480abd8ace78731a677031c0a/.build/checkouts/Kitura.git--211144618449703330/Sources/Kitura/RouterRequest.swift:56:33:错误:使用未解析的标识符' RegularExpression' remote:let regex = try RegularExpression(pattern:pattern,options:[。caseInsensitive])remote:^ ~~~~~~~~~~~~~~~~远程:Foundation.NSRegularExpression:1:12:注意:你的意思是& #39; NSRegularExpression&#39 ;? remote:open class NSRegularExpression:Foundation.NSObject,NSCopying,NSCoding {

使用的swift版本是3.1,我通过.swift-version文件推送到heroku时指定了相同的版本。

这是使用的Package.swift

使用的Kitura版本是1个主要7个未成年人

尝试其他版本的swift,例如3.1.1挂起的结果 - 由于超时而导致heroku取消。任何帮助都感激不尽。感谢

1 个答案:

答案 0 :(得分:1)

首先,请注意您在Mac和Linux上遇到Swift的差异。您可能在Mac上检查过它,而Heroku运行Linux。

其次,public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, LocationListener, ResultCallback<LocationSettingsResult> { private static final String TAG = MainActivity.class.getSimpleName(); private Context context; private MarshMallowPermission permission; protected static final int REQUEST_CHECK_SETTINGS = 0x1; public static final long UPDATE_INTERVAL_IN_MILLISECONDS = 60000; public static final long FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS = UPDATE_INTERVAL_IN_MILLISECONDS / 2; private GoogleApiClient mGoogleApiClient; private LocationRequest mLocationRequest; private LocationSettingsRequest mLocationSettingsRequest; protected Boolean mRequestingLocationUpdates; protected Location mCurrentLocation; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.yourxml); context = this; mRequestingLocationUpdates = false; permission = new MarshMallowPermission(context); buildGoogleApiClient(); createLocationRequest(); buildLocationSettingsRequest(); try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (permission.checkPermissionForLocation()) { Log.d(TAG, "Permissions Grant"); checkLocationSettings(); } else { permission.requestPermissionForLocation(); } } else { checkLocationSettings(); } } catch (Exception e) { } } @Override protected void onStart() { super.onStart(); mGoogleApiClient.connect(); } @Override public void onResume() { super.onResume(); if (mGoogleApiClient.isConnected() && mRequestingLocationUpdates) { startLocationUpdates(); } } @Override protected void onPause() { super.onPause(); if (mGoogleApiClient.isConnected()) { stopLocationUpdates(); } } @Override protected void onStop() { super.onStop(); mGoogleApiClient.disconnect(); } protected synchronized void buildGoogleApiClient() { Log.i(TAG, "Building GoogleApiClient"); mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } protected void createLocationRequest() { mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); } protected void buildLocationSettingsRequest() { LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); builder.addLocationRequest(mLocationRequest); mLocationSettingsRequest = builder.build(); } protected void checkLocationSettings() { PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings( mGoogleApiClient, mLocationSettingsRequest ); result.setResultCallback(this); } protected void startLocationUpdates() { try { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, this ).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { mRequestingLocationUpdates = true; } }); } catch (SecurityException e) { Log.i(TAG, e.getMessage()); } } protected void stopLocationUpdates() { LocationServices.FusedLocationApi.removeLocationUpdates( mGoogleApiClient, this ).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { mRequestingLocationUpdates = false; } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { // Check for the integer request code originally supplied to startResolutionForResult(). case REQUEST_CHECK_SETTINGS: switch (resultCode) { case Activity.RESULT_OK: Log.i(TAG, "User agreed to make required location settings changes."); startLocationUpdates(); case Activity.RESULT_CANCELED: Log.i(TAG, "User chose not to make required location settings changes."); break; } break; } } @Override public void onConnected(@Nullable Bundle bundle) { Log.d(TAG, "Connected"); } @Override public void onLocationChanged(Location location) { Log.d(TAG, "LocationChanged"); if (location != null) { mCurrentLocation = location; Log.d(TAG, "Latitude: " + location.getLatitude() + "\n" + "Longitude: " + location.getLongitude()); } } @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Override public void onConnectionSuspended(int i) { } @Override public void onResult(LocationSettingsResult locationSettingsResult) { final Status status = locationSettingsResult.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: Log.i(TAG, "All location settings are satisfied."); startLocationUpdates(); break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: Log.i(TAG, "Location settings are not satisfied. Show the user a dialog to" + "upgrade location settings "); try { status.startResolutionForResult(FindPartyActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException e) { Log.i(TAG, "PendingIntent unable to execute request."); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: Log.i(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog " + "not created."); break; } } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { Log.d(TAG, "requestCode---" + requestCode + " " + "grantResults----" + grantResults); switch (requestCode) { case MarshMallowPermission.LOCATION_PERMISSION_REQUEST_CODE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Log.d(TAG, "Permissions Grant"); checkLocationSettings(); } else { //Permissions Deny } } } } 在此拉取请求https://github.com/IBM-Swift/Kitura/pull/1107中被RegularExpression取代。从Kitura 1.7.4开始,您不应该遇到这个问题。这意味着您可能在1.7.4之前使用Kitura版本,如果您有NSRegularExpression文件指定旧的Kitura版本,则可能会发生这种情况。您可以删除该文件,也可以运行Package.pins进行更新。

要验证所使用的Kitura软件包的实际版本,swift package updatecd目录,请在那里运行.build/checkouts/Kitura.git-XXXXXXXXXXX并检查最新标记。